#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 */
struct Ann {
  int dummy;
};

/* Variables and functions */
float AnnGDEpoch(struct Ann *, float *, float *, int);
float AnnResilientBPEpoch(struct Ann *, float *, float *, int);
float AnnTrain(struct Ann *net, float *input, float *desired, float maxerr,
               int maxepochs, int setlen, int algo) {
  int i = 0;
  float e = maxerr + 1;
  while (i++ < maxepochs && e >= maxerr) {
    if (algo == 0) {
      e = AnnResilientBPEpoch(net, input, desired, setlen);
    } else if (algo == 1) {
      e = AnnGDEpoch(net, input, desired, setlen);
    }
  }
  return e;
}


x86 assembly (clang, -O0):
<AnnTrain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movss  0xead(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x2c(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%ecx
mov    %al,-0x31(%rbp)
jge    1185 <AnnTrain+0x65>
movss  -0x30(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1195 <AnnTrain+0x75>
jmp    11ea <AnnTrain+0xca>
cmpl   $0x0,-0x28(%rbp)
jne    11bd <AnnTrain+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <AnnResilientBPEpoch@plt>
movss  %xmm0,-0x30(%rbp)
jmp    11e5 <AnnTrain+0xc5>
cmpl   $0x1,-0x28(%rbp)
jne    11e0 <AnnTrain+0xc0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <AnnGDEpoch@plt>
movss  %xmm0,-0x30(%rbp)
jmp    11e5 <AnnTrain+0xc5>
jmp    115d <AnnTrain+0x3d>
movss  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AnnTrain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,0x4(%rsp)
movaps %xmm0,%xmm1
movss  0xec5(%rip),%xmm0
addss  %xmm1,%xmm0
test   %ecx,%ecx
jle    11b5 <AnnTrain+0x95>
ucomiss %xmm1,%xmm0
jb     11b5 <AnnTrain+0x95>
mov    %r9d,%ebx
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    $0x1,%r14d
movss  %xmm1,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%ebx
je     1190 <AnnTrain+0x70>
test   %ebx,%ebx
jne    11a7 <AnnTrain+0x87>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    0x4(%rsp),%ecx
call   1040 <AnnResilientBPEpoch@plt>
jmp    11a2 <AnnTrain+0x82>
nopl   (%rax)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    0x4(%rsp),%ecx
call   1030 <AnnGDEpoch@plt>
movss  (%rsp),%xmm1
cmp    %ebp,%r14d
jge    11b5 <AnnTrain+0x95>
add    $0x1,%r14d
ucomiss %xmm1,%xmm0
jae    1170 <AnnTrain+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Ann = type { i32 }
define float @AnnTrain(%struct.Ann* %0, float* %1, float* %2, float %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca %struct.Ann*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
store %struct.Ann* %0, %struct.Ann** %8
store float* %1, float** %9
store float* %2, float** %10
store float %3, float* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
store i32 0, i32* %15
%17 = load float, float* %11
%18 = fadd float %17, 1.000000e+00
store float %18, float* %16
br label %19
19: ; preds = %49, %7
%20 = load i32, i32* %15
%21 = add nsw i32 %20, 1
store i32 %21, i32* %15
%22 = load i32, i32* %12
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load float, float* %16
%26 = load float, float* %11
%27 = fcmp oge float %25, %26
br label %28
28: ; preds = %24, %19
%29 = phi i1 [ false, %19 ], [ %27, %24 ]
br i1 %29, label %30, label %50
30: ; preds = %28
%31 = load i32, i32* %14
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load %struct.Ann*, %struct.Ann** %8
%35 = load float*, float** %9
%36 = load float*, float** %10
%37 = load i32, i32* %13
%38 = call float @AnnResilientBPEpoch(%struct.Ann* %34, float* %35, float* %36, i32 %37)
store float %38, float* %16
br label %49
39: ; preds = %30
%40 = load i32, i32* %14
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load %struct.Ann*, %struct.Ann** %8
%44 = load float*, float** %9
%45 = load float*, float** %10
%46 = load i32, i32* %13
%47 = call float @AnnGDEpoch(%struct.Ann* %43, float* %44, float* %45, i32 %46)
store float %47, float* %16
br label %48
48: ; preds = %42, %39
br label %49
49: ; preds = %48, %33
br label %19
50: ; preds = %28
%51 = load float, float* %16
ret float %51
}

LLVM IR (-O2):
%struct.Ann = type { i32 }
define float @AnnTrain(%struct.Ann* %0, float* %1, float* %2, float %3, i32 %4, i32 %5, i32 %6) {
%8 = fadd float %3, 1.000000e+00
%9 = icmp sgt i32 %4, 0
%10 = fcmp oge float %8, %3
%11 = and i1 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %7, %19
%13 = phi i32 [ %21, %19 ], [ 1, %7 ]
%14 = phi float [ %20, %19 ], [ %8, %7 ]
switch i32 %6, label %19 [
i32 0, label %15
i32 1, label %17
]
15: ; preds = %12
%16 = tail call float @AnnResilientBPEpoch(%struct.Ann* %0, float* %1, float* %2, i32 %5)
br label %19
17: ; preds = %12
%18 = tail call float @AnnGDEpoch(%struct.Ann* %0, float* %1, float* %2, i32 %5)
br label %19
19: ; preds = %12, %17, %15
%20 = phi float [ %16, %15 ], [ %18, %17 ], [ %14, %12 ]
%21 = add nuw nsw i32 %13, 1
%22 = icmp slt i32 %13, %4
%23 = fcmp oge float %20, %3
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %12, label %25
25: ; preds = %19, %7
%26 = phi float [ %8, %7 ], [ %20, %19 ]
ret float %26
}