#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int nn_answer(float *, float *);
int /*<<< orphan*/ printf(char *, int, int);
int nn_question(unsigned char *xdata, int ydata, int isize) {
  int i, ans;
  int x[784 + 1];
  float x2[784 + 1];
  float y[10] = {
      0.0,
  };
  x2[0] = 1.0;
  for (i = 0; i < isize; i++) {
    x[i + 1] = (int)xdata[i];
    x2[i + 1] = (float)x[i + 1] / 255.0;
  }
  y[ydata] = 1.0;
  ans = nn_answer(x2, y);
  printf("What is this(%d)?, It is %d.\n", ydata, ans);
  return (ydata == ans) ? 1 : 0;
}


x86 assembly (clang, -O0):
<nn_question>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x18e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movss  0xea0(%rip),%xmm0
movss  %xmm0,-0x18b0(%rbp)
ff
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11da <nn_question+0xaa>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0xc60(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
cvtsi2ssl -0xc60(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  0xe55(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movss  %xmm0,-0x18b0(%rbp,%rax,4)
ff ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <nn_question+0x3f>
movslq -0xc(%rbp),%rax
movss  0xe1a(%rip),%xmm0
movss  %xmm0,-0x18e0(%rbp,%rax,4)
ff ff
lea    -0x18b0(%rbp),%rdi
lea    -0x18e0(%rbp),%rsi
call   1050 <nn_answer@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
add    $0x18e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nn_question>:
push   %rbp
push   %rbx
sub    $0xc78,%rsp
pxor   %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
movl   $0x3f800000,0x30(%rsp)
3f
test   %edx,%edx
jle    1292 <nn_question+0x172>
mov    %edx,%eax
cmp    $0x4,%edx
jae    115f <nn_question+0x3f>
xor    %ecx,%ecx
jmp    1265 <nn_question+0x145>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rbx
shr    $0x2,%rbx
add    $0x1,%rbx
test   %rdx,%rdx
je     12cc <nn_question+0x1ac>
mov    %rbx,%rbp
and    $0xfffffffffffffffe,%rbp
xor    %edx,%edx
pxor   %xmm0,%xmm0
movapd 0xe6f(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movd   (%rdi,%rdx,1),%xmm2
punpcklbw %xmm0,%xmm2
punpcklwd %xmm0,%xmm2
cvtdq2pd %xmm2,%xmm3
pshufd $0xee,%xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
divpd  %xmm1,%xmm2
divpd  %xmm1,%xmm3
cvtpd2ps %xmm3,%xmm3
cvtpd2ps %xmm2,%xmm2
unpcklpd %xmm2,%xmm3
movupd %xmm3,0x34(%rsp,%rdx,4)
movd   0x4(%rdi,%rdx,1),%xmm2
punpcklbw %xmm0,%xmm2
punpcklwd %xmm0,%xmm2
cvtdq2pd %xmm2,%xmm3
pshufd $0xee,%xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
divpd  %xmm1,%xmm2
divpd  %xmm1,%xmm3
cvtpd2ps %xmm3,%xmm3
cvtpd2ps %xmm2,%xmm2
unpcklpd %xmm2,%xmm3
movupd %xmm3,0x44(%rsp,%rdx,4)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rbp
jne    11a0 <nn_question+0x80>
test   $0x1,%bl
je     1260 <nn_question+0x140>
movd   (%rdi,%rdx,1),%xmm0
xorpd  %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm1
pshufd $0xee,%xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd 0xdc2(%rip),%xmm2
divpd  %xmm2,%xmm0
divpd  %xmm2,%xmm1
cvtpd2ps %xmm1,%xmm1
cvtpd2ps %xmm0,%xmm0
shl    $0x2,%rdx
unpcklpd %xmm0,%xmm1
or     $0x4,%rdx
movupd %xmm1,0x30(%rsp,%rdx,1)
cmp    %rax,%rcx
je     1292 <nn_question+0x172>
movsd  0xda3(%rip),%xmm0
nopl   (%rax)
movzbl (%rdi,%rcx,1),%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,0x34(%rsp,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1270 <nn_question+0x150>
movslq %esi,%rbx
movl   $0x3f800000,(%rsp,%rbx,4)
lea    0x30(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <nn_answer@plt>
mov    %eax,%ebp
lea    0xd66(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
cmp    %ebx,%ebp
sete   %al
add    $0xc78,%rsp
pop    %rbx
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%bl
jne    1218 <nn_question+0xf8>
jmp    1260 <nn_question+0x140>

LLVM IR (-O0):
@.str = [30 x i8] c"What is this(%d)?, It is %d.\0A\00"
define i32 @nn_question(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [785 x i32]
%10 = alloca [785 x float]
%11 = alloca [10 x float]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = bitcast [10 x float]* %11 to i8*
%13 = getelementptr inbounds [785 x float], [785 x float]* %10, i64 0, i64 0
store float 1.000000e+00, float* %13
store i32 0, i32* %7
br label %14
14: ; preds = %42, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [785 x i32], [785 x i32]* %9, i64 0, i64 %27
store i32 %24, i32* %28
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [785 x i32], [785 x i32]* %9, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to float
%35 = fpext float %34 to double
%36 = fdiv double %35, 2.550000e+02
%37 = fptrunc double %36 to float
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [785 x float], [785 x float]* %10, i64 0, i64 %40
store float %37, float* %41
br label %42
42: ; preds = %18
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %14
45: ; preds = %14
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [10 x float], [10 x float]* %11, i64 0, i64 %47
store float 1.000000e+00, float* %48
%49 = getelementptr inbounds [785 x float], [785 x float]* %10, i64 0, i64 0
%50 = getelementptr inbounds [10 x float], [10 x float]* %11, i64 0, i64 0
%51 = call i32 @nn_answer(float* %49, float* %50)
store i32 %51, i32* %8
%52 = load i32, i32* %5
%53 = load i32, i32* %8
%54 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %52, i32 %53)
%55 = load i32, i32* %5
%56 = load i32, i32* %8
%57 = icmp eq i32 %55, %56
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 1, i32 0
ret i32 %59
}

LLVM IR (-O2):
@.str = [30 x i8] c"What is this(%d)?, It is %d.\0A\00"
define i32 @nn_question(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [785 x float]
%5 = alloca [10 x float]
%6 = bitcast [785 x float]* %4 to i8*
%7 = bitcast [10 x float]* %5 to i8*
%8 = getelementptr inbounds [785 x float], [785 x float]* %4, i64 0, i64 0
store float 1.000000e+00, float* %8
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %74
10: ; preds = %3
%11 = zext i32 %2 to i64
%12 = icmp ult i32 %2, 4
br i1 %12, label %62, label %13
13: ; preds = %10
%14 = and i64 %11, 4294967292
%15 = add nsw i64 %14, -4
%16 = lshr exact i64 %15, 2
%17 = add nuw nsw i64 %16, 1
%18 = and i64 %17, 1
%19 = icmp eq i64 %15, 0
br i1 %19, label %47, label %20
20: ; preds = %13
%21 = and i64 %17, 9223372036854775806
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %44, %22 ]
%24 = phi i64 [ 0, %20 ], [ %45, %22 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %23
%26 = bitcast i8* %25 to <4 x i8>*
%27 = load <4 x i8>, <4 x i8>* %26
%28 = or i64 %23, 1
%29 = uitofp <4 x i8> %27 to <4 x double>
%30 = fdiv <4 x double> %29, <double 2.550000e+02, double 2.550000e+02, double 2.550000e+02, double 2.550000e+02>
%31 = fptrunc <4 x double> %30 to <4 x float>
%32 = getelementptr inbounds [785 x float], [785 x float]* %4, i64 0, i64 %28
%33 = bitcast float* %32 to <4 x float>*
store <4 x float> %31, <4 x float>* %33
%34 = or i64 %23, 4
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = bitcast i8* %35 to <4 x i8>*
%37 = load <4 x i8>, <4 x i8>* %36
%38 = or i64 %23, 5
%39 = uitofp <4 x i8> %37 to <4 x double>
%40 = fdiv <4 x double> %39, <double 2.550000e+02, double 2.550000e+02, double 2.550000e+02, double 2.550000e+02>
%41 = fptrunc <4 x double> %40 to <4 x float>
%42 = getelementptr inbounds [785 x float], [785 x float]* %4, i64 0, i64 %38
%43 = bitcast float* %42 to <4 x float>*
store <4 x float> %41, <4 x float>* %43
%44 = add nuw i64 %23, 8
%45 = add i64 %24, 2
%46 = icmp eq i64 %45, %21
br i1 %46, label %47, label %22
47: ; preds = %22, %13
%48 = phi i64 [ 0, %13 ], [ %44, %22 ]
%49 = icmp eq i64 %18, 0
br i1 %49, label %60, label %50
50: ; preds = %47
%51 = getelementptr inbounds i8, i8* %0, i64 %48
%52 = bitcast i8* %51 to <4 x i8>*
%53 = load <4 x i8>, <4 x i8>* %52
%54 = or i64 %48, 1
%55 = uitofp <4 x i8> %53 to <4 x double>
%56 = fdiv <4 x double> %55, <double 2.550000e+02, double 2.550000e+02, double 2.550000e+02, double 2.550000e+02>
%57 = fptrunc <4 x double> %56 to <4 x float>
%58 = getelementptr inbounds [785 x float], [785 x float]* %4, i64 0, i64 %54
%59 = bitcast float* %58 to <4 x float>*
store <4 x float> %57, <4 x float>* %59
br label %60
60: ; preds = %47, %50
%61 = icmp eq i64 %14, %11
br i1 %61, label %74, label %62
62: ; preds = %10, %60
%63 = phi i64 [ 0, %10 ], [ %14, %60 ]
br label %64
64: ; preds = %62, %64
%65 = phi i64 [ %68, %64 ], [ %63, %62 ]
%66 = getelementptr inbounds i8, i8* %0, i64 %65
%67 = load i8, i8* %66
%68 = add nuw nsw i64 %65, 1
%69 = uitofp i8 %67 to double
%70 = fdiv double %69, 2.550000e+02
%71 = fptrunc double %70 to float
%72 = getelementptr inbounds [785 x float], [785 x float]* %4, i64 0, i64 %68
store float %71, float* %72
%73 = icmp eq i64 %68, %11
br i1 %73, label %74, label %64
74: ; preds = %64, %60, %3
%75 = sext i32 %1 to i64
%76 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 %75
store float 1.000000e+00, float* %76
%77 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 0
%78 = call i32 @nn_answer(float* %8, float* %77)
%79 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %78)
%80 = icmp eq i32 %78, %1
%81 = zext i1 %80 to i32
ret i32 %81
}