#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*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(void) {
  FILE *fps[2048];
  char filename[100];
  for (int i = 0; i < 2048; i++) {
    sprintf(filename, "/home/wgtdkp/mount_hmfs/orphan_%d.txt", i);
    printf("%s\n", filename);
    fps[i] = fopen(filename, "r");
    if (!fps[i])
      printf("error!\n");
  }
  while (1) {
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4090,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4084(%rbp)
cmpl   $0x800,-0x4084(%rbp)
jge    11ec <main+0xbc>
lea    -0x4080(%rbp),%rdi
mov    -0x4084(%rbp),%edx
lea    0xe90(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x4080(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4080(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
movslq -0x4084(%rbp),%rax
mov    %rcx,-0x4010(%rbp,%rax,8)
ff
movslq -0x4084(%rbp),%rax
cmpq   $0x0,-0x4010(%rbp,%rax,8)
jne    11d3 <main+0xa3>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xa8>
mov    -0x4084(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4084(%rbp)
jmp    114c <main+0x1c>
jmp    11f1 <main+0xc1>
jmp    11f1 <main+0xc1>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
xor    %ebx,%ebx
lea    0xeba(%rip),%r14
mov    %rsp,%r15
lea    0xed6(%rip),%r12
lea    0xed1(%rip),%r13
jmp    116b <main+0x3b>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x800,%ebx
je     11a0 <main+0x70>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <fopen@plt>
test   %rax,%rax
jne    1160 <main+0x30>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1160 <main+0x30>
nopw   0x0(%rax,%rax,1)
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@.str = [38 x i8] c"/home/wgtdkp/mount_hmfs/orphan_%d.txt\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [8 x i8] c"error!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2048 x i32*]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %27, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2048
br i1 %7, label %8, label %30
8: ; preds = %5
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [2048 x i32*], [2048 x i32*]* %2, i64 0, i64 %17
store i32* %15, i32** %18
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2048 x i32*], [2048 x i32*]* %2, i64 0, i64 %20
%22 = load i32*, i32** %21
%23 = icmp ne i32* %22, null
br i1 %23, label %26, label %24
24: ; preds = %8
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %8
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %5
30: ; preds = %5
br label %31
31: ; preds = %30, %31
br label %31
}

LLVM IR (-O2):
@.str = [38 x i8] c"/home/wgtdkp/mount_hmfs/orphan_%d.txt\00"
@.str.2 = [2 x i8] c"r\00"
@str = [7 x i8] c"error!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %11
%4 = phi i32 [ 0, %0 ], [ %12, %11 ]
%5 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @puts(i8* %2)
%7 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %3, %9
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 2048
br i1 %13, label %14, label %3
14: ; preds = %11, %14
br label %14
}