#include "mnist.hh"
#include <cassert>
#include <cstdio>
#include <stdexcept>

namespace mnist
{

    namespace
    {
        static constexpr std::size_t NIMGS = 70000;
        static constexpr std::size_t IMG_SIZE = 784;
    }
    

    void load(const std::string& path, dbl_t** x, dbl_t** y)
    {

        FILE* f = fopen(path.c_str(), "rb");
        if (!f)
            throw std::runtime_error("mnist: can't open data file");

        *x = new dbl_t[NIMGS * IMG_SIZE];
        *y = new dbl_t[NIMGS * 10];

        for (std::size_t i = 0; i < NIMGS; ++i)
        {
            dbl_t* x_row = *x + i * IMG_SIZE;
            dbl_t* y_row = *y + i * 10;

            unsigned char pixs[IMG_SIZE];
            char digit;
            fread(pixs, 1, IMG_SIZE, f);
            fread(&digit, 1, 1, f);

            for (std::size_t i = 0; i < IMG_SIZE; ++i)
                x_row[i] = pixs[i] / 255.0;
            digit_to_vector(digit, y_row);
        }

        fclose(f);
    }

    void digit_to_vector(std::size_t digit, dbl_t* out)
    {
        assert(digit < 10);
        for (std::size_t i = 0; i < 10; ++i)
            out[i] = 0;
        out[digit] = 1;
    }

    std::size_t vector_to_digit(const dbl_t* v)
    {
        std::size_t res = 0;
        for (std::size_t i = 1; i < 10; ++i)
            if (v[i] > v[res])
                res = i;
        return res;
    }

    bool output_test(const dbl_t* a , const dbl_t* b)
    {
        return vector_to_digit(a) == vector_to_digit(b);
    }

}

	.file	"tmpxft_002037a8_00000000-6_mnist.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3079:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3079:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_ZN5mnist15digit_to_vectorEmPf
	.type	_ZN5mnist15digit_to_vectorEmPf, @function
_ZN5mnist15digit_to_vectorEmPf:
.LFB3074:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	movl	$10, %ecx
	xorl	%eax, %eax
	movq	%rsi, %rdi
	rep stosl
	movl	$0x3f800000, (%rsi,%rdx,4)
	ret
	.cfi_endproc
.LFE3074:
	.size	_ZN5mnist15digit_to_vectorEmPf, .-_ZN5mnist15digit_to_vectorEmPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"rb"
.LC2:
	.string	"mnist: can't open data file"
	.text
	.globl	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
	.type	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_, @function
_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_:
.LFB3073:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3073
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	leaq	.LC1(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$824, %rsp
	.cfi_def_cfa_offset 880
	movq	(%rdi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 808(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	fopen@PLT
.LEHE0:
	testq	%rax, %rax
	jne	.L4
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB1:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE1:
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	movq	_ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx
	leaq	_ZTISt13runtime_error(%rip), %rsi
	movq	%rbx, %rdi
.LEHB2:
	call	__cxa_throw@PLT
.L4:
	movl	$219520000, %edi
	movq	%rax, %rbx
	xorl	%r14d, %r14d
	xorl	%ebp, %ebp
	call	_Znam@PLT
	movl	$2800000, %edi
	movq	%rax, (%r12)
	call	_Znam@PLT
	movq	%rax, 0(%r13)
.L7:
	movq	0(%r13), %rax
	leaq	24(%rsp), %r9
	movq	%rbx, %r8
	movq	(%r12), %r15
	movq	%r9, %rdi
	movl	$784, %ecx
	movl	$1, %edx
	movl	$784, %esi
	addq	%rbp, %rax
	movq	%r9, 8(%rsp)
	addq	%r14, %r15
	movq	%rax, (%rsp)
	call	__fread_chk@PLT
	leaq	23(%rsp), %rdi
	movq	%rbx, %r8
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	__fread_chk@PLT
	movq	8(%rsp), %r9
	xorl	%eax, %eax
.L6:
	movzbl	(%r9,%rax), %edx
	cvtsi2sdl	%edx, %xmm0
	divsd	.LC3(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r15,%rax,4)
	incq	%rax
	cmpq	$784, %rax
	jne	.L6
	movsbq	23(%rsp), %rdi
	movq	(%rsp), %rsi
	addq	$40, %rbp
	addq	$3136, %r14
	call	_ZN5mnist15digit_to_vectorEmPf
	cmpq	$2800000, %rbp
	jne	.L7
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$824, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
.L12:
	.cfi_restore_state
	endbr64
	movq	%rax, %rbp
.L9:
	movq	%rbx, %rdi
	call	__cxa_free_exception@PLT
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
.L17:
	call	__stack_chk_fail@PLT
.L10:
	movq	%rbp, %rdi
	call	_Unwind_Resume@PLT
.LEHE2:
	.cfi_endproc
.LFE3073:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3073:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3073-.LLSDACSB3073
.LLSDACSB3073:
	.uleb128 .LEHB0-.LFB3073
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3073
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L12-.LFB3073
	.uleb128 0
	.uleb128 .LEHB2-.LFB3073
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3073:
	.text
	.size	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_, .-_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
	.globl	_ZN5mnist15vector_to_digitEPKf
	.type	_ZN5mnist15vector_to_digitEPKf, @function
_ZN5mnist15vector_to_digitEPKf:
.LFB3075:
	.cfi_startproc
	endbr64
	movl	$1, %eax
	xorl	%edx, %edx
.L21:
	movss	(%rdi,%rax,4), %xmm0
	comiss	(%rdi,%rdx,4), %xmm0
	jbe	.L20
	movq	%rax, %rdx
.L20:
	incq	%rax
	cmpq	$10, %rax
	jne	.L21
	movq	%rdx, %rax
	ret
	.cfi_endproc
.LFE3075:
	.size	_ZN5mnist15vector_to_digitEPKf, .-_ZN5mnist15vector_to_digitEPKf
	.globl	_ZN5mnist11output_testEPKfS1_
	.type	_ZN5mnist11output_testEPKfS1_, @function
_ZN5mnist11output_testEPKfS1_:
.LFB3076:
	.cfi_startproc
	endbr64
	call	_ZN5mnist15vector_to_digitEPKf
	movq	%rsi, %rdi
	movq	%rax, %rcx
	call	_ZN5mnist15vector_to_digitEPKf
	cmpq	%rax, %rcx
	sete	%al
	ret
	.cfi_endproc
.LFE3076:
	.size	_ZN5mnist11output_testEPKfS1_, .-_ZN5mnist11output_testEPKfS1_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3102:
	.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
.LFE3102:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1081073664
	.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 "mnist.hh"
#include <cassert>
#include <cstdio>
#include <stdexcept>

namespace mnist
{

    namespace
    {
        static constexpr std::size_t NIMGS = 70000;
        static constexpr std::size_t IMG_SIZE = 784;
    }
    

    void load(const std::string& path, dbl_t** x, dbl_t** y)
    {

        FILE* f = fopen(path.c_str(), "rb");
        if (!f)
            throw std::runtime_error("mnist: can't open data file");

        *x = new dbl_t[NIMGS * IMG_SIZE];
        *y = new dbl_t[NIMGS * 10];

        for (std::size_t i = 0; i < NIMGS; ++i)
        {
            dbl_t* x_row = *x + i * IMG_SIZE;
            dbl_t* y_row = *y + i * 10;

            unsigned char pixs[IMG_SIZE];
            char digit;
            fread(pixs, 1, IMG_SIZE, f);
            fread(&digit, 1, 1, f);

            for (std::size_t i = 0; i < IMG_SIZE; ++i)
                x_row[i] = pixs[i] / 255.0;
            digit_to_vector(digit, y_row);
        }

        fclose(f);
    }

    void digit_to_vector(std::size_t digit, dbl_t* out)
    {
        assert(digit < 10);
        for (std::size_t i = 0; i < 10; ++i)
            out[i] = 0;
        out[digit] = 1;
    }

    std::size_t vector_to_digit(const dbl_t* v)
    {
        std::size_t res = 0;
        for (std::size_t i = 1; i < 10; ++i)
            if (v[i] > v[res])
                res = i;
        return res;
    }

    bool output_test(const dbl_t* a , const dbl_t* b)
    {
        return vector_to_digit(a) == vector_to_digit(b);
    }

}

	.text
	.file	"mnist.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
.LCPI0_0:
	.quad	0x406fe00000000000              # double 255
	.text
	.globl	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
	.type	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_,@function
_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_: # @_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$824, %rsp                      # imm = 0x338
	.cfi_def_cfa_offset 880
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	(%rdi), %rdi
	movl	$.L.str, %esi
	callq	fopen
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	testq	%rax, %rax
	je	.LBB0_1
# %bb.4:
	movl	$219520000, %edi                # imm = 0xD159C00
	callq	_Znam
	movq	%rax, (%r14)
	movl	$2800000, %edi                  # imm = 0x2AB980
	callq	_Znam
	movq	%rax, (%rbx)
	xorl	%ebp, %ebp
	xorl	%r12d, %r12d
	movq	%rbx, 24(%rsp)                  # 8-byte Spill
	movq	%r14, 16(%rsp)                  # 8-byte Spill
	movq	8(%rsp), %r15                   # 8-byte Reload
.LBB0_5:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_6 Depth 2
	movq	(%rbx), %r13
	leaq	(%r12,%r12), %rax
	leaq	(%rax,%rax,4), %rbx
	movq	(%r14), %r14
	addq	%rbp, %r14
	movl	$1, %esi
	movl	$784, %edx                      # imm = 0x310
	leaq	32(%rsp), %rdi
	movq	%r15, %rcx
	callq	fread
	movl	$1, %esi
	movl	$1, %edx
	leaq	7(%rsp), %rdi
	movq	%r15, %rcx
	callq	fread
	movsd	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero
	xorl	%eax, %eax
.LBB0_6:                                #   Parent Loop BB0_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	32(%rsp,%rax), %ecx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ecx, %xmm0
	divsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	incq	%rax
	cmpq	$784, %rax                      # imm = 0x310
	jne	.LBB0_6
# %bb.7:                                #   in Loop: Header=BB0_5 Depth=1
	leaq	(,%rbx,4), %rax
	addq	%r13, %rax
	movsbq	7(%rsp), %rcx
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rax)
	movups	%xmm0, (%rax)
	movq	$0, 32(%rax)
	movl	$1065353216, (%rax,%rcx,4)      # imm = 0x3F800000
	incq	%r12
	addq	$3136, %rbp                     # imm = 0xC40
	cmpq	$70000, %r12                    # imm = 0x11170
	movq	24(%rsp), %rbx                  # 8-byte Reload
	movq	16(%rsp), %r14                  # 8-byte Reload
	jne	.LBB0_5
# %bb.8:
	movq	8(%rsp), %rdi                   # 8-byte Reload
	addq	$824, %rsp                      # imm = 0x338
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB0_1:
	.cfi_def_cfa_offset 880
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %rbx
.Ltmp0:
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp1:
# %bb.2:
	movl	$_ZTISt13runtime_error, %esi
	movl	$_ZNSt13runtime_errorD1Ev, %edx
	movq	%rbx, %rdi
	callq	__cxa_throw
.LBB0_3:
.Ltmp2:
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	__cxa_free_exception
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_, .Lfunc_end0-_ZN5mnist4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPPfS9_
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.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 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Lfunc_end0-.Ltmp1             #   Call between .Ltmp1 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_ZN5mnist15digit_to_vectorEmPf  # -- Begin function _ZN5mnist15digit_to_vectorEmPf
	.type	_ZN5mnist15digit_to_vectorEmPf,@function
_ZN5mnist15digit_to_vectorEmPf:         # @_ZN5mnist15digit_to_vectorEmPf
	.cfi_startproc
# %bb.0:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsi)
	movups	%xmm0, (%rsi)
	movq	$0, 32(%rsi)
	movl	$1065353216, (%rsi,%rdi,4)      # imm = 0x3F800000
	retq
.Lfunc_end1:
	.size	_ZN5mnist15digit_to_vectorEmPf, .Lfunc_end1-_ZN5mnist15digit_to_vectorEmPf
	.cfi_endproc
                                        # -- End function
	.globl	_ZN5mnist15vector_to_digitEPKf  # -- Begin function _ZN5mnist15vector_to_digitEPKf
	.type	_ZN5mnist15vector_to_digitEPKf,@function
_ZN5mnist15vector_to_digitEPKf:         # @_ZN5mnist15vector_to_digitEPKf
	.cfi_startproc
# %bb.0:
	movl	$1, %ecx
	xorl	%edx, %edx
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rdi,%rdx,4), %xmm0
	movq	%rcx, %rax
	ja	.LBB2_3
# %bb.2:                                #   in Loop: Header=BB2_1 Depth=1
	movq	%rdx, %rax
.LBB2_3:                                #   in Loop: Header=BB2_1 Depth=1
	incq	%rcx
	movq	%rax, %rdx
	cmpq	$10, %rcx
	jne	.LBB2_1
# %bb.4:
	retq
.Lfunc_end2:
	.size	_ZN5mnist15vector_to_digitEPKf, .Lfunc_end2-_ZN5mnist15vector_to_digitEPKf
	.cfi_endproc
                                        # -- End function
	.globl	_ZN5mnist11output_testEPKfS1_   # -- Begin function _ZN5mnist11output_testEPKfS1_
	.type	_ZN5mnist11output_testEPKfS1_,@function
_ZN5mnist11output_testEPKfS1_:          # @_ZN5mnist11output_testEPKfS1_
	.cfi_startproc
# %bb.0:
	movl	$1, %ecx
	xorl	%edx, %edx
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rdi,%rdx,4), %xmm0
	movq	%rcx, %rax
	ja	.LBB3_3
# %bb.2:                                #   in Loop: Header=BB3_1 Depth=1
	movq	%rdx, %rax
.LBB3_3:                                #   in Loop: Header=BB3_1 Depth=1
	incq	%rcx
	movq	%rax, %rdx
	cmpq	$10, %rcx
	jne	.LBB3_1
# %bb.4:                                # %_ZN5mnist15vector_to_digitEPKf.exit.preheader
	movl	$1, %ecx
	xorl	%edx, %edx
.LBB3_5:                                # %_ZN5mnist15vector_to_digitEPKf.exit
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rsi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rsi,%rdx,4), %xmm0
	movq	%rcx, %rdi
	ja	.LBB3_7
# %bb.6:                                # %_ZN5mnist15vector_to_digitEPKf.exit
                                        #   in Loop: Header=BB3_5 Depth=1
	movq	%rdx, %rdi
.LBB3_7:                                # %_ZN5mnist15vector_to_digitEPKf.exit
                                        #   in Loop: Header=BB3_5 Depth=1
	incq	%rcx
	movq	%rdi, %rdx
	cmpq	$10, %rcx
	jne	.LBB3_5
# %bb.8:                                # %_ZN5mnist15vector_to_digitEPKf.exit6
	cmpq	%rdi, %rax
	sete	%al
	retq
.Lfunc_end3:
	.size	_ZN5mnist11output_testEPKfS1_, .Lfunc_end3-_ZN5mnist11output_testEPKfS1_
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"rb"
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"mnist: can't open data file"
	.size	.L.str.1, 28

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.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 __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZTISt13runtime_error
	.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
