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

/* Variables and functions */
int /*<<< orphan*/ accept_input(struct network *, int /*<<< orphan*/ *);
int /*<<< orphan*/ backprop(struct network *);
int /*<<< orphan*/ *data_prepare(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ feedfwd(struct network *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct network *network_build(int, int, int);
int /*<<< orphan*/ printerr(struct network *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct network *network;
  FILE *data;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <input-data>\n", argv[0]);
    return 1;
  }
  network = network_build(4, 5, 3);
  if (!network) {
    fprintf(stderr, "Out of memory\n");
    return 1;
  }
  data = data_prepare(argv[1]);
  if (!data) {
    fprintf(stderr, "%s: Unable to open file(%s)", argv[1], strerror(errno));
    return 1;
  }
  for (;;) {
    accept_input(network, data);
    feedfwd(network);
    printerr(network);
    backprop(network);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ca <main+0x4a>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <main+0x128>
mov    $0x4,%edi
mov    $0x5,%esi
mov    $0x3,%edx
call   1050 <network_build@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1210 <main+0x90>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <main+0x128>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <data_prepare@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1276 <main+0xf6>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <main+0x128>
jmp    127b <main+0xfb>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <accept_input@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feedfwd@plt>
mov    -0x18(%rbp),%rdi
call   1040 <printerr@plt>
mov    -0x18(%rbp),%rdi
call   1070 <backprop@plt>
jmp    127b <main+0xfb>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jne    11e5 <main+0x65>
mov    $0x4,%edi
mov    $0x5,%esi
mov    $0x3,%edx
call   1050 <network_build@plt>
test   %rax,%rax
je     1201 <main+0x81>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
call   1080 <data_prepare@plt>
test   %rax,%rax
je     121a <main+0x9a>
mov    %rax,%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <accept_input@plt>
mov    %rbx,%rdi
call   1090 <feedfwd@plt>
mov    %rbx,%rdi
call   1040 <printerr@plt>
mov    %rbx,%rdi
call   1070 <backprop@plt>
jmp    11c0 <main+0x40>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    124b <main+0xcb>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    124b <main+0xcb>
mov    0x2dbf(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%r14),%r14
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xdeb(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.network = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s <input-data>\0A\00"
@.str.1 = [15 x i8] c"Out of memory\0A\00"
@.str.2 = [28 x i8] c"%s: Unable to open file(%s)\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.network*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %49
16: ; preds = %2
%17 = call %struct.network* @network_build(i32 4, i32 5, i32 3)
store %struct.network* %17, %struct.network** %6
%18 = load %struct.network*, %struct.network** %6
%19 = icmp ne %struct.network* %18, null
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %49
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @data_prepare(i8* %26)
store i32* %27, i32** %7
%28 = load i32*, i32** %7
%29 = icmp ne i32* %28, null
br i1 %29, label %38, label %30
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %36)
store i32 1, i32* %3
br label %49
38: ; preds = %23
br label %39
39: ; preds = %39, %38
%40 = load %struct.network*, %struct.network** %6
%41 = load i32*, i32** %7
%42 = call i32 @accept_input(%struct.network* %40, i32* %41)
%43 = load %struct.network*, %struct.network** %6
%44 = call i32 @feedfwd(%struct.network* %43)
%45 = load %struct.network*, %struct.network** %6
%46 = call i32 @printerr(%struct.network* %45)
%47 = load %struct.network*, %struct.network** %6
%48 = call i32 @backprop(%struct.network* %47)
br label %39
49: ; preds = %30, %20, %10
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.network = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s <input-data>\0A\00"
@.str.1 = [15 x i8] c"Out of memory\0A\00"
@.str.2 = [28 x i8] c"%s: Unable to open file(%s)\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %30
8: ; preds = %2
%9 = tail call %struct.network* @network_build(i32 4, i32 5, i32 3)
%10 = icmp eq %struct.network* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %30
14: ; preds = %8
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @data_prepare(i8* %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %23)
br label %30
25: ; preds = %14, %25
%26 = tail call i32 @accept_input(%struct.network* %9, i32* %17)
%27 = tail call i32 @feedfwd(%struct.network* %9)
%28 = tail call i32 @printerr(%struct.network* %9)
%29 = tail call i32 @backprop(%struct.network* %9)
br label %25
30: ; preds = %19, %11, %4
ret i32 1
}