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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pupple(int *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main01(void) {
  int index = 0;
  int array[100] = {0};
  char buf[100];
  FILE *p = fopen("D:\\temp\\a.txt", "r");
  while (!feof(p)) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), p);
    array[index] = atoi(buf);
    index++;
  }
  fclose(p);
  pupple(array, index);
  p = fopen("D:\\temp\\b.txt", "w");
  int i;
  for (i = 0; i < index; i++) {
    memset(buf, 0, sizeof(buf));
    sprintf(buf, "%d\n", array[i]);
    fputs(buf, p);
  }
  fclose(p);
  return 0;
}


x86 assembly (clang, -O0):
<main01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1050 <memset@plt>
lea    0xe44(%rip),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f0 <main01+0x60>
jmp    1242 <main01+0xb2>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x210(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
movslq -0x4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11cf <main01+0x3f>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10b0 <pupple@plt>
lea    0xdac(%rip),%rdi
lea    0xdb3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x218(%rbp)
movl   $0x0,-0x21c(%rbp)
mov    -0x21c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12eb <main01+0x15b>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x210(%rbp),%rdi
movslq -0x21c(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
lea    0xd61(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x21c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x21c(%rbp)
jmp    1281 <main01+0xf1>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main01>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0x70(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x190,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe46(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    121b <main01+0x8b>
xor    %ebx,%ebx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1090 <atoi@plt>
mov    %eax,0x70(%rsp,%rbx,4)
add    $0x1,%rbx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e0 <main01+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0x70(%rsp),%rdi
mov    %ebx,%esi
call   10b0 <pupple@plt>
lea    0xdda(%rip),%rdi
lea    0xde1(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
test   %ebx,%ebx
je     1292 <main01+0x102>
mov    %ebx,%r12d
xor    %ebx,%ebx
mov    %rsp,%r13
lea    0xdc8(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    0x70(%rsp,%rbx,4),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   10a0 <sprintf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1260 <main01+0xd0>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main01() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i8]
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [100 x i32]* %2 to i8*
%7 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
br label %8
8: ; preds = %13, %0
%9 = load i32*, i32** %4
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 100)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i32 @fgets(i8* %16, i32 100, i32* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @atoi(i8* %19)
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %22
store i32 %20, i32* %23
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %8
26: ; preds = %8
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %1
%31 = call i32 @pupple(i32* %29, i32 %30)
%32 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %32, i32** %4
store i32 0, i32* %5
br label %33
33: ; preds = %49, %26
%34 = load i32, i32* %5
%35 = load i32, i32* %1
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %52
37: ; preds = %33
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 100)
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%47 = load i32*, i32** %4
%48 = call i32 @fputs(i8* %46, i32* %47)
br label %49
49: ; preds = %37
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %33
52: ; preds = %33
%53 = load i32*, i32** %4
%54 = call i32 @fclose(i32* %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main01() {
%1 = alloca [100 x i32]
%2 = alloca [100 x i8]
%3 = bitcast [100 x i32]* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @feof(i32* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %0, %8
%9 = phi i64 [ %14, %8 ], [ 0, %0 ]
%10 = call i32 @memset(i8* %4, i32 0, i32 100)
%11 = call i32 @fgets(i8* %4, i32 100, i32* %5)
%12 = call i32 @atoi(i8* %4)
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %9
store i32 %12, i32* %13
%14 = add nuw i64 %9, 1
%15 = call i32 @feof(i32* %5)
%16 = icmp eq i32 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %8
%18 = trunc i64 %14 to i32
br label %19
19: ; preds = %17, %0
%20 = phi i32 [ 0, %0 ], [ %18, %17 ]
%21 = call i32 @fclose(i32* %5)
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%23 = call i32 @pupple(i32* %22, i32 %20)
%24 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %20, 0
br i1 %25, label %37, label %26
26: ; preds = %19
%27 = zext i32 %20 to i64
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %35, %28 ]
%30 = call i32 @memset(i8* %4, i32 0, i32 100)
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %29
%32 = load i32, i32* %31
%33 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = call i32 @fputs(i8* %4, i32* %24)
%35 = add nuw nsw i64 %29, 1
%36 = icmp eq i64 %35, %27
br i1 %36, label %37, label %28
37: ; preds = %28, %19
%38 = call i32 @fclose(i32* %24)
ret i32 0
}