#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 atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int n;
  int i;
  FILE *f;
  if (argc < 2) {
    printf(
        "\n\nThis program generates an input vector for the neural network.\n");
    printf(" You must specify the  size of the input vector.\n");
    printf(
        " The size of the input vector must be close to number of inputs in\n");
    printf(" the neural network.\n\n");
    printf(" For example: %s 10\n\n", argv[0]);
    return 0;
  }
  n = atoi(argv[1]);
  f = fopen("input.dat", "wt");
  perror(NULL);
  for (i = 0; i < n; i++)
    fprintf(f, "%f ", (float)i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c9 <main+0x79>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1236 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xf05(%rip),%rdi
lea    0xf08(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <perror@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <main+0xdf>
mov    -0x20(%rbp),%rdi
cvtsi2ssl -0x18(%rbp),%xmm0
lea    0xed6(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1200 <main+0xb0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11bd <main+0x5d>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
lea    0xe46(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
call   1070 <perror@plt>
test   %r15d,%r15d
jle    11b0 <main+0x50>
lea    0xe2f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1200 <main+0xa0>
jmp    11b0 <main+0x50>

LLVM IR (-O0):
@.str = [66 x i8] c"\0A\0AThis program generates an input vector for the neural network.\0A\00"
@.str.1 = [50 x i8] c" You must specify the size of the input vector.\0A\00"
@.str.2 = [68 x i8] c" The size of the input vector must be close to number of inputs in\0A\00"
@.str.3 = [23 x i8] c" the neural network.\0A\0A\00"
@.str.4 = [22 x i8] c" For example: %s 10\0A\0A\00"
@.str.5 = [10 x i8] c"input.dat\00"
@.str.6 = [3 x i8] c"wt\00"
@.str.7 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %18)
store i32 0, i32* %3
br label %40
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %25, i32** %8
%26 = call i32 @perror(i32* null)
store i32 0, i32* %7
br label %27
27: ; preds = %36, %20
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i32*, i32** %8
%33 = load i32, i32* %7
%34 = sitofp i32 %33 to float
%35 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), float %34)
br label %36
36: ; preds = %31
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %27
39: ; preds = %27
store i32 0, i32* %3
br label %40
40: ; preds = %39, %11
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str.4 = [22 x i8] c" For example: %s 10\0A\0A\00"
@.str.5 = [10 x i8] c"input.dat\00"
@.str.6 = [3 x i8] c"wt\00"
@.str.7 = [4 x i8] c"%f \00"
@str = [65 x i8] c"\0A\0AThis program generates an input vector for the neural network.\00"
@str.8 = [49 x i8] c" You must specify the size of the input vector.\00"
@str.9 = [67 x i8] c" The size of the input vector must be close to number of inputs in\00"
@str.10 = [22 x i8] c" the neural network.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %24
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%16 = tail call i32 @perror(i32* null)
%17 = icmp sgt i32 %14, 0
br i1 %17, label %18, label %24
18: ; preds = %11, %18
%19 = phi i32 [ %22, %18 ], [ 0, %11 ]
%20 = sitofp i32 %19 to float
%21 = tail call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), float %20)
%22 = add nuw nsw i32 %19, 1
%23 = icmp eq i32 %22, %14
br i1 %23, label %24, label %18
24: ; preds = %18, %11, %4
ret i32 0
}