#include "BmpSave.cuh"
#include <fstream>
#include <string>
namespace BmpSave {
__host__ __device__ Color::Color(unsigned char rr, unsigned char gg,
                                 unsigned char bb)
    : r(rr), g(gg), b(bb){};

__host__ __device__ Color::Color(int col) {
  r = (col & 0xFF0000) >> 16;
  g = (col & 0x00FF00) >> 8;
  b = col & 0x0000FF;
}
__host__ __device__ Color::Color() {
  r = 0;
  g = 0;
  b = 0;
}

void saveBmp(const std::string &filename, const int width, const int height,
             Color *pixels) {
  BmpHeader header(width, height);
  std::ofstream fout(filename.c_str(), std::ios::binary);
  fout.write(reinterpret_cast<char *>(&header), sizeof(BmpHeader));
  fout.write(reinterpret_cast<char *>(pixels), width * height * sizeof(Color));
}

} // namespace BmpSave

	.file	"tmpxft_003b7e79_00000000-6_BmpSave.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4144:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4144:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN7BmpSave5ColorC2Ehhh
	.type	_ZN7BmpSave5ColorC2Ehhh, @function
_ZN7BmpSave5ColorC2Ehhh:
.LFB4133:
	.cfi_startproc
	endbr64
	movb	%cl, (%rdi)
	movb	%dl, 1(%rdi)
	movb	%sil, 2(%rdi)
	ret
	.cfi_endproc
.LFE4133:
	.size	_ZN7BmpSave5ColorC2Ehhh, .-_ZN7BmpSave5ColorC2Ehhh
	.globl	_ZN7BmpSave5ColorC1Ehhh
	.set	_ZN7BmpSave5ColorC1Ehhh,_ZN7BmpSave5ColorC2Ehhh
	.align 2
	.globl	_ZN7BmpSave5ColorC2Ei
	.type	_ZN7BmpSave5ColorC2Ei, @function
_ZN7BmpSave5ColorC2Ei:
.LFB4136:
	.cfi_startproc
	endbr64
	movl	%esi, %eax
	movw	%si, (%rdi)
	sarl	$16, %eax
	movb	%al, 2(%rdi)
	ret
	.cfi_endproc
.LFE4136:
	.size	_ZN7BmpSave5ColorC2Ei, .-_ZN7BmpSave5ColorC2Ei
	.globl	_ZN7BmpSave5ColorC1Ei
	.set	_ZN7BmpSave5ColorC1Ei,_ZN7BmpSave5ColorC2Ei
	.align 2
	.globl	_ZN7BmpSave5ColorC2Ev
	.type	_ZN7BmpSave5ColorC2Ev, @function
_ZN7BmpSave5ColorC2Ev:
.LFB4139:
	.cfi_startproc
	endbr64
	movw	$0, (%rdi)
	movb	$0, 2(%rdi)
	ret
	.cfi_endproc
.LFE4139:
	.size	_ZN7BmpSave5ColorC2Ev, .-_ZN7BmpSave5ColorC2Ev
	.globl	_ZN7BmpSave5ColorC1Ev
	.set	_ZN7BmpSave5ColorC1Ev,_ZN7BmpSave5ColorC2Ev
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4167:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4167:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.text
	.globl	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE
	.type	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE, @function
_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE:
.LFB4141:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4141
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	xorl	%edx, %edx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rcx, %r12
	xorl	%ecx, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
	subq	$584, %rsp
	.cfi_def_cfa_offset 624
	movq	%fs:40, %rax
	movq	%rax, 568(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rbp
	movq	%rdx, 34(%rsp)
	movabsq	$11258999071965184, %rax
	movq	%rax, 10(%rsp)
	xorl	%eax, %eax
	movq	%rax, 18(%rsp)
	movl	$2097153, %eax
	salq	$16, %rax
	movl	%esi, 20(%rsp)
	movq	%rax, 26(%rsp)
	movl	%esi, %eax
	movq	(%rdi), %rsi
	movq	%rbp, %rdi
	imull	%r13d, %eax
	movq	%rdx, 42(%rsp)
	movl	$4, %edx
	movq	$19778, 2(%rsp)
	movl	%ecx, 50(%rsp)
	leal	54(,%rax,4), %eax
	movw	$0, 54(%rsp)
	movl	%r13d, 24(%rsp)
	movl	%eax, 4(%rsp)
.LEHB0:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	leaq	2(%rsp), %rsi
	movl	$54, %edx
	movq	%rbp, %rdi
.LEHB1:
	call	_ZNSo5writeEPKcl@PLT
	imull	%r13d, %ebx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	movslq	%ebx, %rdx
	salq	$2, %rdx
	call	_ZNSo5writeEPKcl@PLT
.LEHE1:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	568(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	jmp	.L12
.L11:
	endbr64
	movq	%rax, %rbx
.L8:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	568(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L12:
	call	__stack_chk_fail@PLT
.L10:
	addq	$584, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4141:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4141:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4141-.LLSDACSB4141
.LLSDACSB4141:
	.uleb128 .LEHB0-.LFB4141
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4141
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L11-.LFB4141
	.uleb128 0
	.uleb128 .LEHB2-.LFB4141
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE4141:
	.text
	.size	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE, .-_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include "BmpSave.cuh"
#include <fstream>
#include <string>
namespace BmpSave {
__host__ __device__ Color::Color(unsigned char rr, unsigned char gg,
                                 unsigned char bb)
    : r(rr), g(gg), b(bb){};

__host__ __device__ Color::Color(int col) {
  r = (col & 0xFF0000) >> 16;
  g = (col & 0x00FF00) >> 8;
  b = col & 0x0000FF;
}
__host__ __device__ Color::Color() {
  r = 0;
  g = 0;
  b = 0;
}

void saveBmp(const std::string &filename, const int width, const int height,
             Color *pixels) {
  BmpHeader header(width, height);
  std::ofstream fout(filename.c_str(), std::ios::binary);
  fout.write(reinterpret_cast<char *>(&header), sizeof(BmpHeader));
  fout.write(reinterpret_cast<char *>(pixels), width * height * sizeof(Color));
}

} // namespace BmpSave

	.text
	.file	"BmpSave.hip"
	.globl	_ZN7BmpSave5ColorC2Ehhh         # -- Begin function _ZN7BmpSave5ColorC2Ehhh
	.p2align	1, 0x90
	.type	_ZN7BmpSave5ColorC2Ehhh,@function
_ZN7BmpSave5ColorC2Ehhh:                # @_ZN7BmpSave5ColorC2Ehhh
	.cfi_startproc
# %bb.0:
	movb	%cl, (%rdi)
	movb	%dl, 1(%rdi)
	movb	%sil, 2(%rdi)
	retq
.Lfunc_end0:
	.size	_ZN7BmpSave5ColorC2Ehhh, .Lfunc_end0-_ZN7BmpSave5ColorC2Ehhh
	.cfi_endproc
                                        # -- End function
	.globl	_ZN7BmpSave5ColorC2Ei           # -- Begin function _ZN7BmpSave5ColorC2Ei
	.p2align	1, 0x90
	.type	_ZN7BmpSave5ColorC2Ei,@function
_ZN7BmpSave5ColorC2Ei:                  # @_ZN7BmpSave5ColorC2Ei
	.cfi_startproc
# %bb.0:
	movl	%esi, %eax
	movl	%esi, %ecx
	shrl	$16, %ecx
	movb	%cl, 2(%rdi)
	movb	%ah, 1(%rdi)
	movb	%al, (%rdi)
	retq
.Lfunc_end1:
	.size	_ZN7BmpSave5ColorC2Ei, .Lfunc_end1-_ZN7BmpSave5ColorC2Ei
	.cfi_endproc
                                        # -- End function
	.globl	_ZN7BmpSave5ColorC2Ev           # -- Begin function _ZN7BmpSave5ColorC2Ev
	.p2align	1, 0x90
	.type	_ZN7BmpSave5ColorC2Ev,@function
_ZN7BmpSave5ColorC2Ev:                  # @_ZN7BmpSave5ColorC2Ev
	.cfi_startproc
# %bb.0:
	movb	$0, 2(%rdi)
	movw	$0, (%rdi)
	retq
.Lfunc_end2:
	.size	_ZN7BmpSave5ColorC2Ev, .Lfunc_end2-_ZN7BmpSave5ColorC2Ev
	.cfi_endproc
                                        # -- End function
	.globl	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE # -- Begin function _ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE
	.type	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE,@function
_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE: # @_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$568, %rsp                      # imm = 0x238
	.cfi_def_cfa_offset 608
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %rbx
	movl	%esi, %r14d
	leaq	2(%rsp), %r15
	movw	$19778, (%r15)                  # imm = 0x4D42
	movabsq	$231928233984, %rax             # imm = 0x3600000000
	movq	%rax, 6(%r15)
	movl	$40, 14(%r15)
	movl	$2097153, 26(%r15)              # imm = 0x200001
	xorps	%xmm0, %xmm0
	movups	%xmm0, 30(%r15)
	movq	$0, 46(%r15)
	movl	%esi, 18(%r15)
	movl	%edx, 22(%r15)
	imull	%edx, %r14d
	leal	54(,%r14,4), %eax
	movl	%eax, 2(%r15)
	movq	(%rdi), %rsi
	leaq	56(%rsp), %r12
	movq	%r12, %rdi
	movl	$4, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp0:
	movl	$54, %edx
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	_ZNSo5writeEPKcl
.Ltmp1:
# %bb.1:
	movslq	%r14d, %rdx
	shlq	$2, %rdx
.Ltmp2:
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	callq	_ZNSo5writeEPKcl
.Ltmp3:
# %bb.2:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	64(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 56(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	304(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	addq	$568, %rsp                      # imm = 0x238
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_3:
	.cfi_def_cfa_offset 608
.Ltmp4:
	movq	%rax, %rbx
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE, .Lfunc_end3-_ZN7BmpSave7saveBmpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiPNS_5ColorE
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp3-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp3
	.uleb128 .Ltmp4-.Lfunc_begin0           #     jumps to .Ltmp4
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Lfunc_end3-.Ltmp3             #   Call between .Ltmp3 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.globl	_ZN7BmpSave5ColorC1Ehhh
	.type	_ZN7BmpSave5ColorC1Ehhh,@function
.set _ZN7BmpSave5ColorC1Ehhh, _ZN7BmpSave5ColorC2Ehhh
	.globl	_ZN7BmpSave5ColorC1Ei
	.type	_ZN7BmpSave5ColorC1Ei,@function
.set _ZN7BmpSave5ColorC1Ei, _ZN7BmpSave5ColorC2Ei
	.globl	_ZN7BmpSave5ColorC1Ev
	.type	_ZN7BmpSave5ColorC1Ev,@function
.set _ZN7BmpSave5ColorC1Ev, _ZN7BmpSave5ColorC2Ev
	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
