#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ forwardPropagation(double **, int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ testReadNeuralNetwork();
void testForwardPropagation() {
  FILE *in;
  in = fopen("X.txt", "r");
  int n;
  fscanf(in, "%d", &n);
  double **X = (double **)malloc(n * sizeof(double *));
  for (int i = 0; i < n; i++) {
    X[i] = (double *)malloc(sizeof(double));
    fscanf(in, "%lf", &X[i][0]);
  }
  fclose(in);
  testReadNeuralNetwork();
  forwardPropagation(X, 0);
}


x86 assembly (clang, -O0):
<testForwardPropagation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1200 <testForwardPropagation+0xa0>
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11af <testForwardPropagation+0x4f>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1060 <testReadNeuralNetwork@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <forwardPropagation@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testForwardPropagation>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe91(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe83(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x4(%rsp),%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
cmpl   $0x0,0x4(%rsp)
jle    11ec <testForwardPropagation+0x8c>
lea    0xe5a(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <testForwardPropagation+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
call   1060 <testReadNeuralNetwork@plt>
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <forwardPropagation@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"X.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lf\00"
define void @testForwardPropagation() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca double**
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double**
store double** %13, double*** %3
store i32 0, i32* %4
br label %14
14: ; preds = %33, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = call i64 @malloc(i32 8)
%20 = inttoptr i64 %19 to double*
%21 = load double**, double*** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
store double* %20, double** %24
%25 = load i32*, i32** %1
%26 = load double**, double*** %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double*, double** %26, i64 %28
%30 = load double*, double** %29
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %31)
br label %33
33: ; preds = %18
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %14
36: ; preds = %14
%37 = load i32*, i32** %1
%38 = call i32 @fclose(i32* %37)
%39 = call i32 (...) @testReadNeuralNetwork()
%40 = load double**, double*** %3
%41 = call i32 @forwardPropagation(double** %40, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"X.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lf\00"
define void @testForwardPropagation() {
%1 = alloca i32
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 3
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double**
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %15, %0
%12 = call i32 @fclose(i32* %2)
%13 = call i32 (...) @testReadNeuralNetwork()
%14 = call i32 @forwardPropagation(double** %8, i32 0)
ret void
15: ; preds = %0, %15
%16 = phi i64 [ %21, %15 ], [ 0, %0 ]
%17 = call i64 @malloc(i32 8)
%18 = inttoptr i64 %17 to double*
%19 = getelementptr inbounds double*, double** %8, i64 %16
store double* %18, double** %19
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %18)
%21 = add nuw nsw i64 %16, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %15, label %11
}