#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *fp;
  char fname[] = "data.csv";
  int in = 0;
  int i;
  char s[16];
  printf("Practice 06\n");
  fp = fopen(fname, "r");
  if (fp == NULL) {
    printf("ERROR\n");
    return -1;
  }
  while (feof(fp) == 0) {
    fgets(s, 16, fp);
    in = atoi(s);
    for (i = 0; i < in; i++) {
      printf("#");
    }
    printf("\tin=%d\n", in);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xe88(%rip),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x19(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d1 <main+0x71>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125c <main+0xfc>
jmp    11d6 <main+0x76>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    124c <main+0xec>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x10,%esi
call   1050 <fgets@plt>
lea    -0x40(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1236 <main+0xd6>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <main+0xae>
mov    -0x20(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d6 <main+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movabs $0x7673632e61746164,%rax
63 73 76
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe57(%rip),%rsi
mov    %rsp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11db <main+0x5b>
mov    %rax,%r12
mov    %rax,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     11f9 <main+0x79>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    11ec <main+0x6c>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r14
lea    0xe06(%rip),%r15
jmp    1229 <main+0xa9>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11cf <main+0x4f>
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
mov    %r14,%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1210 <main+0x90>
mov    %ebx,%ebp
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1250 <main+0xd0>
jmp    1210 <main+0x90>

LLVM IR (-O0):
@__const.main.fname = [9 x i8] c"data.csv\00"
@.str = [13 x i8] c"Practice 06\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"ERROR\0A\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [8 x i8] c"\09in=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [9 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
store i32 0, i32* %1
%7 = bitcast [9 x i8]* %3 to i8*
store i32 0, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
15: ; preds = %0
br label %16
16: ; preds = %35, %15
%17 = load i32*, i32** %2
%18 = call i64 @feof(i32* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%22 = load i32*, i32** %2
%23 = call i32 @fgets(i8* %21, i32 16, i32* %22)
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %4
store i32 0, i32* %5
br label %26
26: ; preds = %32, %20
%27 = load i32, i32* %5
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %26
35: ; preds = %26
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %16
38: ; preds = %16
%39 = load i32*, i32** %2
%40 = call i32 @fclose(i32* %39)
store i32 0, i32* %1
br label %41
41: ; preds = %38, %13
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@__const.main.fname = [9 x i8] c"data.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [8 x i8] c"\09in=%d\0A\00"
@str = [12 x i8] c"Practice 06\00"
@str.5 = [6 x i8] c"ERROR\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%6 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i64 @feof(i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %26
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
br label %28
13: ; preds = %8, %22
%14 = call i32 @fgets(i8* %4, i32 16, i32* %6)
%15 = call i32 @atoi(i8* %4)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13, %17
%18 = phi i32 [ %20, %17 ], [ 0, %13 ]
%19 = call i32 @putchar(i32 35)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %15
br i1 %21, label %22, label %17
22: ; preds = %17, %13
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%24 = call i64 @feof(i32* %6)
%25 = icmp eq i64 %24, 0
br i1 %25, label %13, label %26
26: ; preds = %22, %8
%27 = call i32 @fclose(i32* %6)
br label %28
28: ; preds = %26, %11
%29 = phi i32 [ -1, %11 ], [ 0, %26 ]
ret i32 %29
}