#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 statfs {
  int f_bfree;
  int f_blocks;
  int f_bsize;
  scalar_t__ f_type;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ fs;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ list_dir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct statfs *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int statfs(char *, struct statfs *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ unlink(char *);
int main() {
  char buffer[1024] = {0};
  FILE *f = fopen("/sys/class/block/vda/size", "r");
  if (f == NULL) {
    fprintf(stderr, "Error: unable to read disk size\n");
    perror("fopen(/sys/class/block/vda/size)");
    return 1;
  } else {
    fread(buffer, 1, 512, f);
    fclose(f);
    unsigned long bytes = strtoul(buffer, NULL, 10);
    if (bytes == 0) {
      fprintf(stderr, "Error: unable to detect disk size\n");
      return 2;
    }
    printf(" [*] Detected disk size: %lu bytes\n", bytes);
  }
  struct statfs fs;
  memset(&fs, 0, sizeof(fs));
  int ret = statfs("/", &fs);
  if (ret != 0) {
    perror("statvfs(/)");
    return ret;
  }
  printf(" [*] FS type: %08x\n", (int)fs.f_type);
  printf(" [*] Free FS blocks: %lld / %lld\n", (unsigned long long)fs.f_bfree,
         (unsigned long long)fs.f_blocks);
  printf(" [*] Free space: %lld / %lld bytes\n",
         (unsigned long long)(fs.f_bfree * fs.f_bsize),
         (unsigned long long)(fs.f_blocks * fs.f_bsize));
  printf(" [*] Enclave file list:\n");
  list_dir("/", 0);
  printf(" [*] Reading test.txt using stdio\n");
  f = fopen("/test.txt", "r");
  if (f == NULL) {
    fprintf(stderr, "Error: file /test.txt not found\n");
    perror("fopen()");
    return 2;
  }
  char *res2 = fgets(buffer, sizeof(buffer), f);
  if (res2 == NULL) {
    fprintf(stderr, "Error: fgets(/test.txt) returned NULL\n");
    perror("fgets()");
    return 3;
  }
  if (strcmp("Hello, World!\n", buffer) != 0)
    fprintf(stderr, "WARN: read wrong string from /test.txt\n");
  printf(" [*] Read: '%s'\n", buffer);
  ret = fclose(f);
  if (ret != 0) {
    fprintf(stderr, "Error: close(/test.txt) returned %d\n", ret);
    perror("fclose()");
    return ret;
  }
  for (unsigned int i = 0; i < sizeof(buffer); i++)
    buffer[i] = i;
  f = fopen("/test_hugefile", "w");
  if (f == NULL) {
    perror("fopen(/test_hugefile");
    return 4;
  }
  unsigned long long total_written = 0;
  ssize_t written;
  do {
    written = fwrite(buffer, 1, sizeof(buffer), f);
    total_written += written;
  } while (written == sizeof(buffer));
  printf(" [*] Wrote %llu bytes before error\n", total_written);
  if (100 * total_written < 90 * fs.f_blocks * fs.f_bsize) {
    fprintf(stderr, "Error: write failed before reaching 90%% of HD\n");
    perror("fwrite()");
    return 5;
  }
  fclose(f);
  unlink("/test_hugefile");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    0xdf4(%rip),%rdi
lea    0xe07(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    125c <main+0x7c>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xdf2(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1677 <main+0x497>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rcx
mov    $0x1,%esi
mov    $0x200,%edx
call   1040 <fread@plt>
mov    -0x418(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    12d2 <main+0xf2>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1677 <main+0x497>
mov    -0x420(%rbp),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x438(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
lea    0xda4(%rip),%rdi
lea    -0x438(%rbp),%rsi
call   10b0 <statfs@plt>
mov    %eax,-0x43c(%rbp)
cmpl   $0x0,-0x43c(%rbp)
je     133a <main+0x15a>
lea    0xd80(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x43c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1677 <main+0x497>
mov    -0x428(%rbp),%rax
mov    %eax,%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x438(%rbp),%rsi
movslq -0x434(%rbp),%rdx
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x438(%rbp),%eax
imul   -0x430(%rbp),%eax
movslq %eax,%rsi
mov    -0x434(%rbp),%eax
imul   -0x430(%rbp),%eax
movslq %eax,%rdx
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcf5(%rip),%rdi
xor    %esi,%esi
call   10c0 <list_dir@plt>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd7c(%rip),%rdi
lea    0xc47(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    141c <main+0x23c>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xd68(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1677 <main+0x497>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
jne    1478 <main+0x298>
mov    0x2b90(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xd3b(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x3,-0x4(%rbp)
jmp    1677 <main+0x497>
lea    -0x410(%rbp),%rsi
lea    0xd24(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     14ac <main+0x2cc>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
lea    0xd14(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x418(%rbp),%rdi
call   1050 <fclose@plt>
mov    %eax,-0x43c(%rbp)
cmpl   $0x0,-0x43c(%rbp)
je     1517 <main+0x337>
mov    0x2af9(%rip),%rax
mov    (%rax),%edi
mov    -0x43c(%rbp),%edx
lea    0xcfc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xd13(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x43c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1677 <main+0x497>
movl   $0x0,-0x44c(%rbp)
mov    -0x44c(%rbp),%eax
cmp    $0x400,%rax
jae    155c <main+0x37c>
mov    -0x44c(%rbp),%eax
mov    %al,%cl
mov    -0x44c(%rbp),%eax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x44c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44c(%rbp)
jmp    1521 <main+0x341>
lea    0xcc5(%rip),%rdi
lea    0xcb6(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    159c <main+0x3bc>
lea    0xc97(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x4,-0x4(%rbp)
jmp    1677 <main+0x497>
movq   $0x0,-0x458(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1100 <fwrite@plt>
mov    %eax,-0x45c(%rbp)
movslq -0x45c(%rbp),%rax
add    -0x458(%rbp),%rax
mov    %rax,-0x458(%rbp)
movslq -0x45c(%rbp),%rax
cmp    $0x400,%rax
je     15a7 <main+0x3c7>
mov    -0x458(%rbp),%rsi
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
imul   $0x64,-0x458(%rbp),%rax
64
imul   $0x5a,-0x434(%rbp),%ecx
imul   -0x430(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1658 <main+0x478>
mov    0x29b0(%rip),%rax
mov    (%rax),%edi
lea    0xc22(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xc44(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x5,-0x4(%rbp)
jmp    1677 <main+0x497>
mov    -0x418(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xbbd(%rip),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x420,%rsp
lea    0x20(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xe7d(%rip),%rdi
lea    0xe90(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1536 <main+0x346>
mov    %rax,%rbx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
test   %rax,%rax
je     150a <main+0x31a>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
lea    0xea4(%rip),%rdi
mov    %rbx,%rsi
call   10c0 <statfs@plt>
test   %eax,%eax
jne    1561 <main+0x371>
mov    0x18(%rsp),%esi
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movslq 0x8(%rsp),%rsi
movslq 0xc(%rsp),%rdx
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movslq 0x8(%rsp),%rsi
movslq 0x10(%rsp),%rax
imul   %rax,%rsi
movslq 0xc(%rsp),%rdx
imul   %rax,%rdx
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xff1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe32(%rip),%rdi
xor    %esi,%esi
call   10d0 <list_dir@plt>
lea    0xfef(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
lea    0xd86(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1572 <main+0x382>
mov    %rax,%rbx
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1597 <main+0x3a7>
lea    0xea7(%rip),%rdi
lea    0x20(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     137d <main+0x18d>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xeb1(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %eax,%eax
jne    15c5 <main+0x3d5>
movdqa 0xc58(%rip),%xmm2
xor    %eax,%eax
movdqa 0xc5d(%rip),%xmm8
movdqa 0xc64(%rip),%xmm9
movdqa 0xc6c(%rip),%xmm3
movdqa 0xc74(%rip),%xmm4
movdqa 0xc7c(%rip),%xmm5
movdqa 0xc84(%rip),%xmm6
movdqa 0xc8c(%rip),%xmm7
movdqa 0xc94(%rip),%xmm1
nopl   0x0(%rax)
movdqa %xmm2,0x20(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm8,%xmm0
movdqa %xmm0,0x30(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm9,%xmm0
movdqa %xmm0,0x40(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm3,%xmm0
movdqa %xmm0,0x50(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm4,%xmm0
movdqa %xmm0,0x60(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm5,%xmm0
movdqa %xmm0,0x70(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm6,%xmm0
movdqa %xmm0,0x80(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm7,%xmm0
movdqa %xmm0,0x90(%rsp,%rax,1)
sub    $0xffffffffffffff80,%rax
pxor   %xmm1,%xmm2
cmp    $0x400,%rax
jne    13f0 <main+0x200>
lea    0xe05(%rip),%rdi
lea    0xdf6(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     15f3 <main+0x403>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0x20(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1110 <fwrite@plt>
cltq
add    %rax,%rbp
cmp    $0x400,%eax
je     14a0 <main+0x2b0>
lea    0xdc3(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
imul   $0x64,%rbp,%rax
movslq 0xc(%rsp),%rcx
movslq 0x10(%rsp),%rdx
imul   %rcx,%rdx
imul   $0x5a,%rdx,%rcx
cmp    %rcx,%rax
jb     160a <main+0x41a>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xd79(%rip),%rdi
call   1030 <unlink@plt>
jmp    1527 <main+0x337>
mov    0x2acf(%rip),%rax
mov    (%rax),%edi
lea    0xbd4(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%r14d
mov    %r14d,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2aa3(%rip),%rax
mov    (%rax),%edi
lea    0xb66(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xb79(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%r14d
jmp    1527 <main+0x337>
mov    %eax,%r14d
lea    0xbcc(%rip),%rdi
call   10f0 <perror@plt>
jmp    1527 <main+0x337>
mov    0x2a67(%rip),%rax
mov    (%rax),%edi
lea    0xc24(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xc37(%rip),%rdi
call   10f0 <perror@plt>
jmp    1521 <main+0x331>
mov    0x2a42(%rip),%rax
mov    (%rax),%edi
lea    0xc28(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xc41(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%r14d
jmp    1527 <main+0x337>
mov    %eax,%r14d
mov    0x2a11(%rip),%rax
mov    (%rax),%edi
lea    0xc6e(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xc82(%rip),%rdi
call   10f0 <perror@plt>
jmp    1527 <main+0x337>
lea    0xc7c(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x4,%r14d
jmp    1527 <main+0x337>
mov    0x29cf(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xcb7(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x5,%r14d
jmp    1527 <main+0x337>

LLVM IR (-O0):
%struct.statfs = type { i32, i32, i32, i64 }
@.str = [26 x i8] c"/sys/class/block/vda/size\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"Error: unable to read disk size\0A\00"
@.str.3 = [33 x i8] c"fopen(/sys/class/block/vda/size)\00"
@.str.4 = [35 x i8] c"Error: unable to detect disk size\0A\00"
@.str.5 = [36 x i8] c" [*] Detected disk size: %lu bytes\0A\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [11 x i8] c"statvfs(/)\00"
@.str.8 = [20 x i8] c" [*] FS type: %08x\0A\00"
@.str.9 = [34 x i8] c" [*] Free FS blocks: %lld / %lld\0A\00"
@.str.10 = [36 x i8] c" [*] Free space: %lld / %lld bytes\0A\00"
@.str.11 = [25 x i8] c" [*] Enclave file list:\0A\00"
@.str.12 = [35 x i8] c" [*] Reading test.txt using stdio\0A\00"
@.str.13 = [10 x i8] c"/test.txt\00"
@.str.14 = [33 x i8] c"Error: file /test.txt not found\0A\00"
@.str.15 = [8 x i8] c"fopen()\00"
@.str.16 = [39 x i8] c"Error: fgets(/test.txt) returned NULL\0A\00"
@.str.17 = [8 x i8] c"fgets()\00"
@.str.18 = [15 x i8] c"Hello, World!\0A\00"
@.str.19 = [40 x i8] c"WARN: read wrong string from /test.txt\0A\00"
@.str.20 = [17 x i8] c" [*] Read: '%s'\0A\00"
@.str.21 = [37 x i8] c"Error: close(/test.txt) returned %d\0A\00"
@.str.22 = [9 x i8] c"fclose()\00"
@.str.23 = [15 x i8] c"/test_hugefile\00"
@.str.24 = [2 x i8] c"w\00"
@.str.25 = [21 x i8] c"fopen(/test_hugefile\00"
@.str.26 = [36 x i8] c" [*] Wrote %llu bytes before error\0A\00"
@.str.27 = [48 x i8] c"Error: write failed before reaching 90%% of HD\0A\00"
@.str.28 = [9 x i8] c"fwrite()\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32*
%4 = alloca i64
%5 = alloca %struct.statfs
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [1024 x i8]* %2 to i8*
%12 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %162
19: ; preds = %0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%21 = load i32*, i32** %3
%22 = call i32 @fread(i8* %20, i32 1, i32 512, i32* %21)
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%26 = call i64 @strtoul(i8* %25, i32* null, i32 10)
store i64 %26, i64* %4
%27 = load i64, i64* %4
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %1
br label %162
32: ; preds = %19
%33 = load i64, i64* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i64 %33)
br label %35
35: ; preds = %32
%36 = call i32 @memset(%struct.statfs* %5, i32 0, i32 24)
%37 = call i32 @statfs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %struct.statfs* %5)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%42 = load i32, i32* %6
store i32 %42, i32* %1
br label %162
43: ; preds = %35
%44 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 3
%45 = load i64, i64* %44
%46 = trunc i64 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 0
%49 = load i32, i32* %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 1
%52 = load i32, i32* %51
%53 = sext i32 %52 to i64
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i64 %50, i64 %53)
%55 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 2
%58 = load i32, i32* %57
%59 = mul nsw i32 %56, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 1
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 2
%64 = load i32, i32* %63
%65 = mul nsw i32 %62, %64
%66 = sext i32 %65 to i64
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i64 %60, i64 %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0))
%69 = call i32 @list_dir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 0)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
%71 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %71, i32** %3
%72 = load i32*, i32** %3
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %78
74: ; preds = %43
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0))
%77 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
store i32 2, i32* %1
br label %162
78: ; preds = %43
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%80 = load i32*, i32** %3
%81 = call i8* @fgets(i8* %79, i32 1024, i32* %80)
store i8* %81, i8** %7
%82 = load i8*, i8** %7
%83 = icmp eq i8* %82, null
br i1 %83, label %84, label %88
84: ; preds = %78
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.16, i64 0, i64 0))
%87 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
store i32 3, i32* %1
br label %162
88: ; preds = %78
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%90 = call i64 @strcmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0))
br label %95
95: ; preds = %92, %88
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* %96)
%98 = load i32*, i32** %3
%99 = call i32 @fclose(i32* %98)
store i32 %99, i32* %6
%100 = load i32, i32* %6
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %108
102: ; preds = %95
%103 = load i32, i32* @stderr
%104 = load i32, i32* %6
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0), i32 %104)
%106 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
%107 = load i32, i32* %6
store i32 %107, i32* %1
br label %162
108: ; preds = %95
store i32 0, i32* %8
br label %109
109: ; preds = %119, %108
%110 = load i32, i32* %8
%111 = zext i32 %110 to i64
%112 = icmp ult i64 %111, 1024
br i1 %112, label %113, label %122
113: ; preds = %109
%114 = load i32, i32* %8
%115 = trunc i32 %114 to i8
%116 = load i32, i32* %8
%117 = zext i32 %116 to i64
%118 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %117
store i8 %115, i8* %118
br label %119
119: ; preds = %113
%120 = load i32, i32* %8
%121 = add i32 %120, 1
store i32 %121, i32* %8
br label %109
122: ; preds = %109
%123 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
store i32* %123, i32** %3
%124 = load i32*, i32** %3
%125 = icmp eq i32* %124, null
br i1 %125, label %126, label %128
126: ; preds = %122
%127 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.25, i64 0, i64 0))
store i32 4, i32* %1
br label %162
128: ; preds = %122
store i64 0, i64* %9
br label %129
129: ; preds = %137, %128
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%131 = load i32*, i32** %3
%132 = call i32 @fwrite(i8* %130, i32 1, i32 1024, i32* %131)
store i32 %132, i32* %10
%133 = load i32, i32* %10
%134 = sext i32 %133 to i64
%135 = load i64, i64* %9
%136 = add i64 %135, %134
store i64 %136, i64* %9
br label %137
137: ; preds = %129
%138 = load i32, i32* %10
%139 = sext i32 %138 to i64
%140 = icmp eq i64 %139, 1024
br i1 %140, label %129, label %141
141: ; preds = %137
%142 = load i64, i64* %9
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.26, i64 0, i64 0), i64 %142)
%144 = load i64, i64* %9
%145 = mul i64 100, %144
%146 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 1
%147 = load i32, i32* %146
%148 = mul nsw i32 90, %147
%149 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i32 0, i32 2
%150 = load i32, i32* %149
%151 = mul nsw i32 %148, %150
%152 = sext i32 %151 to i64
%153 = icmp ult i64 %145, %152
br i1 %153, label %154, label %158
154: ; preds = %141
%155 = load i32, i32* @stderr
%156 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.27, i64 0, i64 0))
%157 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0))
store i32 5, i32* %1
br label %162
158: ; preds = %141
%159 = load i32*, i32** %3
%160 = call i32 @fclose(i32* %159)
%161 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0))
store i32 0, i32* %1
br label %162
162: ; preds = %158, %154, %126, %102, %84, %74, %40, %29, %15
%163 = load i32, i32* %1
ret i32 %163
}

LLVM IR (-O2):
%struct.statfs = type { i32, i32, i32, i64 }
@.str = [26 x i8] c"/sys/class/block/vda/size\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"Error: unable to read disk size\0A\00"
@.str.3 = [33 x i8] c"fopen(/sys/class/block/vda/size)\00"
@.str.4 = [35 x i8] c"Error: unable to detect disk size\0A\00"
@.str.5 = [36 x i8] c" [*] Detected disk size: %lu bytes\0A\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [11 x i8] c"statvfs(/)\00"
@.str.8 = [20 x i8] c" [*] FS type: %08x\0A\00"
@.str.9 = [34 x i8] c" [*] Free FS blocks: %lld / %lld\0A\00"
@.str.10 = [36 x i8] c" [*] Free space: %lld / %lld bytes\0A\00"
@.str.13 = [10 x i8] c"/test.txt\00"
@.str.14 = [33 x i8] c"Error: file /test.txt not found\0A\00"
@.str.15 = [8 x i8] c"fopen()\00"
@.str.16 = [39 x i8] c"Error: fgets(/test.txt) returned NULL\0A\00"
@.str.17 = [8 x i8] c"fgets()\00"
@.str.18 = [15 x i8] c"Hello, World!\0A\00"
@.str.19 = [40 x i8] c"WARN: read wrong string from /test.txt\0A\00"
@.str.20 = [17 x i8] c" [*] Read: '%s'\0A\00"
@.str.21 = [37 x i8] c"Error: close(/test.txt) returned %d\0A\00"
@.str.22 = [9 x i8] c"fclose()\00"
@.str.23 = [15 x i8] c"/test_hugefile\00"
@.str.24 = [2 x i8] c"w\00"
@.str.25 = [21 x i8] c"fopen(/test_hugefile\00"
@.str.26 = [36 x i8] c" [*] Wrote %llu bytes before error\0A\00"
@.str.27 = [48 x i8] c"Error: write failed before reaching 90%% of HD\0A\00"
@.str.28 = [9 x i8] c"fwrite()\00"
@str = [24 x i8] c" [*] Enclave file list:\00"
@str.29 = [34 x i8] c" [*] Reading test.txt using stdio\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca %struct.statfs
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %142
10: ; preds = %0
%11 = call i32 @fread(i8* %3, i32 1, i32 512, i32* %4)
%12 = tail call i32 @fclose(i32* %4)
%13 = call i64 @strtoul(i8* nocapture %3, i32* null, i32 10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %142
18: ; preds = %10
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i64 %13)
%20 = bitcast %struct.statfs* %2 to i8*
%21 = call i32 @memset(%struct.statfs* %2, i32 0, i32 24)
%22 = call i32 @statfs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %struct.statfs* %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %18
%25 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %140
26: ; preds = %18
%27 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 3
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 0
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 1
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i64 %33, i64 %36)
%38 = load i32, i32* %31
%39 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 2
%40 = load i32, i32* %39
%41 = mul nsw i32 %40, %38
%42 = sext i32 %41 to i64
%43 = load i32, i32* %34
%44 = mul nsw i32 %43, %40
%45 = sext i32 %44 to i64
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i64 %42, i64 %45)
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%48 = call i32 @list_dir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 0)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.29, i64 0, i64 0))
%50 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %56
52: ; preds = %26
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0))
%55 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %140
56: ; preds = %26
%57 = call i8* @fgets(i8* %3, i32 1024, i32* %50)
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %63
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.16, i64 0, i64 0))
%62 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
br label %140
63: ; preds = %56
%64 = call i64 @strcmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* %3)
%65 = icmp eq i64 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0))
br label %69
69: ; preds = %66, %63
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* %3)
%71 = call i32 @fclose(i32* %50)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %109
73: ; preds = %69, %73
%74 = phi i64 [ %106, %73 ], [ 0, %69 ]
%75 = phi <16 x i8> [ %107, %73 ], [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %69 ]
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %74
%77 = bitcast i8* %76 to <16 x i8>*
store <16 x i8> %75, <16 x i8>* %77
%78 = or i64 %74, 16
%79 = add <16 x i8> %75, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %78
%81 = bitcast i8* %80 to <16 x i8>*
store <16 x i8> %79, <16 x i8>* %81
%82 = or i64 %74, 32
%83 = add <16 x i8> %75, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %82
%85 = bitcast i8* %84 to <16 x i8>*
store <16 x i8> %83, <16 x i8>* %85
%86 = or i64 %74, 48
%87 = add <16 x i8> %75, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %86
%89 = bitcast i8* %88 to <16 x i8>*
store <16 x i8> %87, <16 x i8>* %89
%90 = or i64 %74, 64
%91 = add <16 x i8> %75, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %90
%93 = bitcast i8* %92 to <16 x i8>*
store <16 x i8> %91, <16 x i8>* %93
%94 = or i64 %74, 80
%95 = add <16 x i8> %75, <i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80>
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %94
%97 = bitcast i8* %96 to <16 x i8>*
store <16 x i8> %95, <16 x i8>* %97
%98 = or i64 %74, 96
%99 = add <16 x i8> %75, <i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96>
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %98
%101 = bitcast i8* %100 to <16 x i8>*
store <16 x i8> %99, <16 x i8>* %101
%102 = or i64 %74, 112
%103 = add <16 x i8> %75, <i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112>
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %102
%105 = bitcast i8* %104 to <16 x i8>*
store <16 x i8> %103, <16 x i8>* %105
%106 = add nuw nsw i64 %74, 128
%107 = xor <16 x i8> %75, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%108 = icmp eq i64 %106, 1024
br i1 %108, label %113, label %73
109: ; preds = %69
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0), i32 %71)
%112 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
br label %140
113: ; preds = %73
%114 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
%115 = icmp eq i32* %114, null
br i1 %115, label %116, label %118
116: ; preds = %113
%117 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.25, i64 0, i64 0))
br label %140
118: ; preds = %113, %118
%119 = phi i64 [ %122, %118 ], [ 0, %113 ]
%120 = call i32 @fwrite(i8* %3, i32 1, i32 1024, i32* %114)
%121 = sext i32 %120 to i64
%122 = add i64 %119, %121
%123 = icmp eq i32 %120, 1024
br i1 %123, label %118, label %124
124: ; preds = %118
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.26, i64 0, i64 0), i64 %122)
%126 = mul i64 %122, 100
%127 = load i32, i32* %34
%128 = mul nsw i32 %127, 90
%129 = load i32, i32* %39
%130 = mul nsw i32 %128, %129
%131 = sext i32 %130 to i64
%132 = icmp ult i64 %126, %131
br i1 %132, label %133, label %137
133: ; preds = %124
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.27, i64 0, i64 0))
%136 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0))
br label %140
137: ; preds = %124
%138 = call i32 @fclose(i32* %114)
%139 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0))
br label %140
140: ; preds = %59, %109, %116, %137, %133, %52, %24
%141 = phi i32 [ %22, %24 ], [ 2, %52 ], [ 3, %59 ], [ %71, %109 ], [ 4, %116 ], [ 5, %133 ], [ 0, %137 ]
br label %142
142: ; preds = %15, %140, %6
%143 = phi i32 [ 1, %6 ], [ %141, %140 ], [ 2, %15 ]
ret i32 %143
}