#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 stat {
  int st_size;
};

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int fstat(int, struct stat *);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ v_printf(char *, ...);
int /*<<< orphan*/ write(int, char *, int const);
int process(const int rounds, const int num_files, const int write_size,
            const int write_iters) {
  int failed = 0;
  int fd[num_files];
  struct stat sbuf[num_files];
  char ch = 'A';
  char buf[write_size];
  char basename[4096];
  char filename[4096];
  int ret;
  v_printf("r%d n%d s%d i%d\n", rounds, num_files, write_size, write_iters);
  for (int idx = 0; idx < write_size; idx++) {
    buf[idx] = ch;
    ++ch;
    if (ch > 'z')
      ch = 'A';
  }
  strcpy(basename, "zerolength-");
  for (int hdx = 0; hdx < rounds; hdx++) {
    v_printf("Round: %d\n", hdx);
    for (int idx = 0; idx < num_files; idx++) {
      int curidx = idx;
      sprintf(filename, "%s%d", basename, curidx);
      if (hdx == 0)
        unlink(filename);
      fd[curidx] = open(filename, O_RDWR | O_CREAT | O_APPEND, 0);
      ret = fstat(fd[curidx], &sbuf[curidx]);
      if (ret < 0) {
        v_printf("ERROR on fstat\n");
        ++failed;
      } else {
        int expected_size;
        if (hdx == 0)
          expected_size = 0;
        else if (idx % 2 == 0)
          expected_size = 0;
        else
          expected_size =
              (hdx * (num_files - idx)) * (write_iters * write_size);
        if (sbuf[curidx].st_size == expected_size) {
          v_printf("%d. %s On create, got expected size %d\n", hdx, filename,
                   sbuf[curidx].st_size);
        } else {
          v_printf("%d: %s On create, ERROR expected %d size is %d\n", hdx,
                   filename, expected_size, sbuf[curidx].st_size);
          ++failed;
        }
      }
      for (int jdx = 0; jdx <= curidx; jdx++) {
        for (int kdx = 0; kdx < write_iters; kdx++) {
          write(fd[jdx], buf, write_size);
        }
      }
    }
    for (int idx = 0; idx < num_files; idx++) {
      ret = fstat(fd[idx], &sbuf[idx]);
      if (ret < 0) {
        v_printf("ERROR on fstat\n");
        ++failed;
      } else {
        int expected_size;
        if (idx % 2 == 0) {
          expected_size = (num_files - idx) * (write_iters * write_size);
        } else {
          expected_size =
              ((hdx + 1) * (num_files - idx)) * (write_iters * write_size);
        }
        if (sbuf[idx].st_size == expected_size) {
          v_printf("%d. zerolength-%d After write, got expected size of %d\n",
                   hdx, idx, sbuf[idx].st_size);
        } else {
          v_printf(
              "%d. zerolength-%d After write, ERROR expected %d size is %d\n",
              hdx, idx, expected_size, sbuf[idx].st_size);
          ++failed;
        }
      }
      close(fd[idx]);
    }
    for (int idx = 0; idx < num_files; idx++) {
      int curidx = idx;
      int flags;
      sprintf(filename, "%s%d", basename, curidx);
      if (idx % 2 == 0)
        flags = O_RDWR | O_TRUNC;
      else
        flags = O_RDWR;
      fd[curidx] = open(filename, flags, 0);
      ret = fstat(fd[curidx], &sbuf[curidx]);
      if (ret < 0) {
        v_printf("ERROR on fstat\n");
        ++failed;
      } else {
        int expected_size;
        if (flags & O_TRUNC)
          expected_size = 0;
        else
          expected_size = sbuf[curidx].st_size;
        if (sbuf[curidx].st_size == expected_size) {
          v_printf("%d. %s After reopen, expect %d size is %d\n", hdx, filename,
                   expected_size, sbuf[curidx].st_size);
        } else {
          v_printf("%d. %s After reopen, ERROR expect %d size is %d\n", hdx,
                   filename, expected_size, sbuf[curidx].st_size);
          ++failed;
        }
      }
    }
  }
  return failed;
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2090,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x2090(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x2088(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movb   $0x41,-0x31(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x2080(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
movl   $0x0,-0x2048(%rbp)
mov    -0x2048(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128b <process+0x10b>
mov    -0x2080(%rbp),%rax
mov    -0x31(%rbp),%dl
movslq -0x2048(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x31(%rbp),%al
add    $0x1,%al
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
cmp    $0x7a,%eax
jle    1272 <process+0xf2>
movb   $0x41,-0x31(%rbp)
jmp    1277 <process+0xf7>
mov    -0x2048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2048(%rbp)
jmp    1236 <process+0xb6>
lea    -0x1040(%rbp),%rdi
lea    0xd78(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x204c(%rbp)
mov    -0x204c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    18d7 <process+0x757>
mov    -0x204c(%rbp),%esi
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
movl   $0x0,-0x2050(%rbp)
mov    -0x2050(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    154b <process+0x3cb>
mov    -0x2050(%rbp),%eax
mov    %eax,-0x2054(%rbp)
lea    -0x2040(%rbp),%rdi
lea    -0x1040(%rbp),%rdx
mov    -0x2054(%rbp),%ecx
lea    0xd1d(%rip),%rsi
call   1080 <sprintf@plt>
cmpl   $0x0,-0x204c(%rbp)
jne    1329 <process+0x1a9>
lea    -0x2040(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x2040(%rbp),%rdi
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    0x2cb8(%rip),%rax
or     (%rax),%esi
mov    0x2c77(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1070 <open@plt>
mov    -0x2088(%rbp),%rsi
mov    %eax,%edx
mov    -0x2090(%rbp),%rax
movslq -0x2054(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x2054(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
movslq -0x2054(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   10a0 <fstat@plt>
mov    %eax,-0x2044(%rbp)
cmpl   $0x0,-0x2044(%rbp)
jge    13b8 <process+0x238>
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14b0 <process+0x330>
cmpl   $0x0,-0x204c(%rbp)
jne    13d4 <process+0x254>
movl   $0x0,-0x2058(%rbp)
jmp    1421 <process+0x2a1>
mov    -0x2050(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13fa <process+0x27a>
movl   $0x0,-0x2058(%rbp)
jmp    141c <process+0x29c>
mov    -0x204c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x2050(%rbp),%ecx
imul   %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2058(%rbp)
jmp    1421 <process+0x2a1>
mov    -0x2088(%rbp),%rax
movslq -0x2054(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x2058(%rbp),%eax
jne    146f <process+0x2ef>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
lea    -0x2040(%rbp),%rdx
movslq -0x2054(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xbda(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
jmp    14ab <process+0x32b>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
lea    -0x2040(%rbp),%rdx
mov    -0x2058(%rbp),%ecx
movslq -0x2054(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xbca(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14b0 <process+0x330>
movl   $0x0,-0x205c(%rbp)
mov    -0x205c(%rbp),%eax
cmp    -0x2054(%rbp),%eax
jg     1532 <process+0x3b2>
movl   $0x0,-0x2060(%rbp)
mov    -0x2060(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1519 <process+0x399>
mov    -0x2080(%rbp),%rsi
mov    -0x2090(%rbp),%rax
movslq -0x205c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0xc(%rbp),%edx
call   1050 <write@plt>
mov    -0x2060(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2060(%rbp)
jmp    14d6 <process+0x356>
jmp    151e <process+0x39e>
mov    -0x205c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x205c(%rbp)
jmp    14ba <process+0x33a>
jmp    1537 <process+0x3b7>
mov    -0x2050(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2050(%rbp)
jmp    12d5 <process+0x155>
movl   $0x0,-0x2064(%rbp)
mov    -0x2064(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    16cf <process+0x54f>
mov    -0x2088(%rbp),%rsi
mov    -0x2090(%rbp),%rax
movslq -0x2064(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
movslq -0x2064(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   10a0 <fstat@plt>
mov    %eax,-0x2044(%rbp)
cmpl   $0x0,-0x2044(%rbp)
jge    15be <process+0x43e>
lea    0xa84(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    16a5 <process+0x525>
mov    -0x2064(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    15f3 <process+0x473>
mov    -0x8(%rbp),%eax
sub    -0x2064(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2068(%rbp)
jmp    1618 <process+0x498>
mov    -0x204c(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%ecx
sub    -0x2064(%rbp),%ecx
imul   %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2068(%rbp)
mov    -0x2088(%rbp),%rax
movslq -0x2064(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x2068(%rbp),%eax
jne    1665 <process+0x4e5>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
mov    -0x2064(%rbp),%edx
movslq -0x2064(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xa3c(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
jmp    16a0 <process+0x520>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
mov    -0x2064(%rbp),%edx
mov    -0x2068(%rbp),%ecx
movslq -0x2064(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xa3d(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    16a5 <process+0x525>
mov    -0x2090(%rbp),%rax
movslq -0x2064(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1060 <close@plt>
mov    -0x2064(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2064(%rbp)
jmp    1555 <process+0x3d5>
movl   $0x0,-0x206c(%rbp)
mov    -0x206c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    18be <process+0x73e>
mov    -0x206c(%rbp),%eax
mov    %eax,-0x2070(%rbp)
lea    -0x2040(%rbp),%rdi
lea    -0x1040(%rbp),%rdx
mov    -0x2070(%rbp),%ecx
lea    0x919(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x206c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1748 <process+0x5c8>
mov    0x28a6(%rip),%rax
mov    (%rax),%eax
mov    0x28b5(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x2074(%rbp)
jmp    1757 <process+0x5d7>
mov    0x2889(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2074(%rbp)
lea    -0x2040(%rbp),%rdi
mov    -0x2074(%rbp),%esi
xor    %edx,%edx
call   1070 <open@plt>
mov    -0x2088(%rbp),%rsi
mov    %eax,%edx
mov    -0x2090(%rbp),%rax
movslq -0x2070(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x2070(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
movslq -0x2070(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   10a0 <fstat@plt>
mov    %eax,-0x2044(%rbp)
cmpl   $0x0,-0x2044(%rbp)
jge    17d1 <process+0x651>
lea    0x871(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    18a5 <process+0x725>
mov    -0x2074(%rbp),%eax
mov    0x2812(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     17f8 <process+0x678>
movl   $0x0,-0x2078(%rbp)
jmp    180f <process+0x68f>
mov    -0x2088(%rbp),%rax
movslq -0x2070(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2078(%rbp)
mov    -0x2088(%rbp),%rax
movslq -0x2070(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x2078(%rbp),%eax
jne    1864 <process+0x6e4>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
lea    -0x2040(%rbp),%rdx
mov    -0x2078(%rbp),%ecx
movslq -0x2070(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0x8b2(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
jmp    18a0 <process+0x720>
mov    -0x2088(%rbp),%rax
mov    -0x204c(%rbp),%esi
lea    -0x2040(%rbp),%rdx
mov    -0x2078(%rbp),%ecx
movslq -0x2070(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0x8a5(%rip),%rdi
mov    $0x0,%al
call   1090 <v_printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    18a5 <process+0x725>
jmp    18aa <process+0x72a>
mov    -0x206c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x206c(%rbp)
jmp    16d9 <process+0x559>
jmp    18c3 <process+0x743>
mov    -0x204c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204c(%rbp)
jmp    12a8 <process+0x128>
mov    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2068,%rsp
mov    %ecx,%r8d
mov    %edx,%r13d
mov    %esi,%edx
mov    %edi,%esi
mov    %edx,%eax
mov    %rsp,%rcx
mov    %rax,-0x70(%rbp)
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %r13d,%r14d
mov    %rsp,%r15
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe1b(%rip),%rdi
movl   $0x0,-0x2c(%rbp)
mov    %esi,-0x5c(%rbp)
mov    %edx,-0x3c(%rbp)
mov    %r13d,%ecx
mov    %r8d,-0x4c(%rbp)
xor    %eax,%eax
call   1090 <v_printf@plt>
test   %r13d,%r13d
jle    1248 <process+0xc8>
lea    -0x1(%r14),%rcx
mov    %r14d,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    161b <process+0x49b>
mov    $0x41,%dl
xor    %ecx,%ecx
test   %rax,%rax
je     1248 <process+0xc8>
add    %r15,%rcx
xor    %esi,%esi
mov    $0x41,%edi
nopl   0x0(%rax)
mov    %dl,(%rcx,%rsi,1)
add    $0x1,%dl
cmp    $0x7b,%dl
movzbl %dl,%edx
cmovge %edi,%edx
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1230 <process+0xb0>
lea    0xdc2(%rip),%rsi
lea    -0x2090(%rbp),%rdi
call   1040 <strcpy@plt>
cmpl   $0x0,-0x5c(%rbp)
mov    -0x58(%rbp),%r14
jle    1609 <process+0x489>
mov    -0x4c(%rbp),%eax
imul   %r13d,%eax
mov    %eax,-0x60(%rbp)
mov    -0x70(%rbp),%rax
lea    0x0(,%rax,4),%rax
mov    %rax,-0x88(%rbp)
lea    -0x1090(%rbp),%r12
movl   $0x0,-0x2c(%rbp)
xor    %ebx,%ebx
jmp    12b7 <process+0x137>
nopl   0x0(%rax,%rax,1)
mov    -0x48(%rbp),%rbx
add    $0x1,%ebx
cmp    -0x5c(%rbp),%ebx
lea    -0x1090(%rbp),%r12
je     1609 <process+0x489>
lea    0xd5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <v_printf@plt>
cmpl   $0x0,-0x3c(%rbp)
mov    %rbx,-0x48(%rbp)
jle    12a0 <process+0x120>
mov    -0x60(%rbp),%eax
imul   %ebx,%eax
mov    %eax,-0x7c(%rbp)
mov    $0x1,%eax
mov    %rax,-0x38(%rbp)
xor    %ebx,%ebx
jmp    1312 <process+0x192>
nopw   0x0(%rax,%rax,1)
mov    -0x78(%rbp),%rbx
add    $0x1,%rbx
addq   $0x1,-0x38(%rbp)
cmp    -0x70(%rbp),%rbx
mov    -0x58(%rbp),%r14
lea    -0x1090(%rbp),%r12
je     1420 <process+0x2a0>
mov    %r12,%rdi
lea    0xd0c(%rip),%rsi
lea    -0x2090(%rbp),%rdx
mov    %ebx,%ecx
call   1080 <sprintf@plt>
cmpl   $0x0,-0x48(%rbp)
jne    1338 <process+0x1b8>
mov    %r12,%rdi
call   1030 <unlink@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
mov    0x2c90(%rip),%rax
or     (%rax),%esi
mov    0x2c6f(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    -0x68(%rbp),%rcx
mov    %eax,(%rcx,%rbx,4)
lea    (%r14,%rbx,4),%r14
mov    %eax,%edi
mov    %r14,%rsi
call   10a0 <fstat@plt>
test   %eax,%eax
mov    %rbx,-0x78(%rbp)
js     13b0 <process+0x230>
mov    -0x3c(%rbp),%ecx
sub    %ebx,%ecx
mov    %ebx,%eax
and    $0x1,%eax
neg    %eax
imul   -0x7c(%rbp),%ecx
and    %eax,%ecx
mov    -0x48(%rbp),%rsi
test   %esi,%esi
cmove  %esi,%ecx
mov    (%r14),%r8d
cmp    %ecx,%r8d
jne    13c0 <process+0x240>
lea    0xc99(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <v_printf@plt>
jmp    13d5 <process+0x255>
lea    0xc76(%rip),%rdi
xor    %eax,%eax
call   1090 <v_printf@plt>
jmp    13d1 <process+0x251>
lea    0xc9e(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <v_printf@plt>
addl   $0x1,-0x2c(%rbp)
xor    %r14d,%r14d
jmp    13ee <process+0x26e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    -0x38(%rbp),%r14
je     12f0 <process+0x170>
cmpl   $0x0,-0x4c(%rbp)
jle    13e0 <process+0x260>
mov    -0x68(%rbp),%rax
mov    (%rax,%r14,4),%ebx
mov    -0x4c(%rbp),%r12d
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   1050 <write@plt>
add    $0xffffffff,%r12d
jne    1400 <process+0x280>
jmp    13e0 <process+0x260>
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x0,-0x3c(%rbp)
jle    12a0 <process+0x120>
mov    -0x48(%rbp),%rax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    %r14,%r12
xor    %ebx,%ebx
jmp    147d <process+0x2fd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xbd6(%rip),%rdi
xor    %eax,%eax
call   1090 <v_printf@plt>
addl   $0x1,-0x2c(%rbp)
mov    %r14d,%edi
mov    -0x58(%rbp),%r14
call   1060 <close@plt>
add    $0x1,%rbx
add    $0x4,%r12
addq   $0xffffffffffffffff,-0x38(%rbp)
je     14f0 <process+0x370>
mov    -0x68(%rbp),%rax
mov    (%rax,%rbx,4),%edi
mov    %edi,%r14d
mov    %r12,%rsi
call   10a0 <fstat@plt>
test   %eax,%eax
js     1450 <process+0x2d0>
test   $0x1,%bl
mov    -0x78(%rbp),%eax
mov    $0x1,%ecx
cmove  %ecx,%eax
imul   -0x60(%rbp),%eax
mov    -0x38(%rbp),%rcx
imul   %eax,%ecx
mov    (%r12),%r8d
cmp    %ecx,%r8d
jne    14d0 <process+0x350>
lea    0xbd9(%rip),%rdi
mov    -0x48(%rbp),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1090 <v_printf@plt>
jmp    1462 <process+0x2e2>
nopl   0x0(%rax,%rax,1)
lea    0xbf6(%rip),%rdi
mov    -0x48(%rbp),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1090 <v_printf@plt>
jmp    145e <process+0x2de>
nopl   0x0(%rax)
cmpl   $0x0,-0x3c(%rbp)
jle    12a0 <process+0x120>
xor    %r12d,%r12d
xor    %ebx,%ebx
jmp    1539 <process+0x3b9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xb16(%rip),%rdi
xor    %eax,%eax
call   1090 <v_printf@plt>
addl   $0x1,-0x2c(%rbp)
mov    -0x38(%rbp),%ebx
add    $0x1,%ebx
add    $0x4,%r12
cmp    %r12,-0x88(%rbp)
je     12a0 <process+0x120>
lea    -0x1090(%rbp),%rdi
lea    0xae1(%rip),%rsi
lea    -0x2090(%rbp),%rdx
mov    %ebx,%ecx
call   1080 <sprintf@plt>
mov    %ebx,%eax
mov    $0x0,%ebx
mov    %eax,-0x38(%rbp)
test   $0x1,%al
jne    156c <process+0x3ec>
mov    0x2a86(%rip),%rax
mov    (%rax),%ebx
mov    0x2a65(%rip),%rax
or     (%rax),%ebx
lea    -0x1090(%rbp),%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1070 <open@plt>
mov    -0x68(%rbp),%rcx
mov    %eax,(%rcx,%r12,1)
lea    (%r14,%r12,1),%rsi
mov    %eax,%edi
call   10a0 <fstat@plt>
test   %eax,%eax
js     1510 <process+0x390>
mov    (%r14,%r12,1),%r8d
mov    0x2a45(%rip),%rax
test   %ebx,(%rax)
je     15e0 <process+0x460>
test   %r8d,%r8d
mov    -0x38(%rbp),%ebx
je     15e5 <process+0x465>
lea    0xb77(%rip),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x1090(%rbp),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1090 <v_printf@plt>
addl   $0x1,-0x2c(%rbp)
jmp    1525 <process+0x3a5>
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%ebx
jmp    15e8 <process+0x468>
xor    %r8d,%r8d
lea    0xb1b(%rip),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x1090(%rbp),%rdx
mov    %r8d,%ecx
xor    %eax,%eax
call   1090 <v_printf@plt>
jmp    1525 <process+0x3a5>
mov    -0x2c(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%r14d
mov    $0x41,%bl
xor    %ecx,%ecx
jmp    163f <process+0x4bf>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x4,%rcx
mov    %edx,%ebx
cmp    %rcx,%r14
je     121d <process+0x9d>
mov    %bl,(%r15,%rcx,1)
add    $0x1,%bl
mov    $0x41,%edx
mov    $0x41,%esi
cmp    $0x7b,%bl
jge    1658 <process+0x4d8>
movzbl %bl,%esi
mov    %sil,0x1(%r15,%rcx,1)
add    $0x1,%sil
mov    $0x41,%edi
cmp    $0x7b,%sil
jge    1670 <process+0x4f0>
movzbl %sil,%edi
mov    %dil,0x2(%r15,%rcx,1)
add    $0x1,%dil
mov    $0x41,%esi
cmp    $0x7b,%dil
jge    1688 <process+0x508>
movzbl %dil,%esi
mov    %sil,0x3(%r15,%rcx,1)
add    $0x1,%sil
cmp    $0x7b,%sil
jge    1630 <process+0x4b0>
movzbl %sil,%edx
jmp    1630 <process+0x4b0>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [17 x i8] c"r%d n%d s%d i%d\0A\00"
@.str.1 = [12 x i8] c"zerolength-\00"
@.str.2 = [11 x i8] c"Round: %d\0A\00"
@.str.3 = [5 x i8] c"%s%d\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.4 = [16 x i8] c"ERROR on fstat\0A\00"
@.str.5 = [40 x i8] c"%d. %s On create, got expected size %d\0A\00"
@.str.6 = [48 x i8] c"%d: %s On create, ERROR expected %d size is %d\0A\00"
@.str.7 = [56 x i8] c"%d. zerolength-%d After write, got expected size of %d\0A\00"
@.str.8 = [61 x i8] c"%d. zerolength-%d After write, ERROR expected %d size is %d\0A\00"
@O_TRUNC = global i32 0
@.str.9 = [43 x i8] c"%d. %s After reopen, expect %d size is %d\0A\00"
@.str.10 = [49 x i8] c"%d. %s After reopen, ERROR expect %d size is %d\0A\00"
define i32 @process(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8
%14 = alloca i64
%15 = alloca [4096 x i8]
%16 = alloca [4096 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%31 = load i32, i32* %6
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %10
%34 = alloca i32, i64 %32
store i64 %32, i64* %11
%35 = load i32, i32* %6
%36 = zext i32 %35 to i64
%37 = alloca %struct.stat, i64 %36
store i64 %36, i64* %12
store i8 65, i8* %13
%38 = load i32, i32* %7
%39 = zext i32 %38 to i64
%40 = alloca i8, i64 %39
store i64 %39, i64* %14
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %41, i32 %42, i32 %43, i32 %44)
store i32 0, i32* %18
br label %46
46: ; preds = %62, %4
%47 = load i32, i32* %18
%48 = load i32, i32* %7
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %65
50: ; preds = %46
%51 = load i8, i8* %13
%52 = load i32, i32* %18
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %40, i64 %53
store i8 %51, i8* %54
%55 = load i8, i8* %13
%56 = add i8 %55, 1
store i8 %56, i8* %13
%57 = load i8, i8* %13
%58 = sext i8 %57 to i32
%59 = icmp sgt i32 %58, 122
br i1 %59, label %60, label %61
60: ; preds = %50
store i8 65, i8* %13
br label %61
61: ; preds = %60, %50
br label %62
62: ; preds = %61
%63 = load i32, i32* %18
%64 = add nsw i32 %63, 1
store i32 %64, i32* %18
br label %46
65: ; preds = %46
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%67 = call i32 @strcpy(i8* %66, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %19
br label %68
68: ; preds = %364, %65
%69 = load i32, i32* %19
%70 = load i32, i32* %5
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %367
72: ; preds = %68
%73 = load i32, i32* %19
%74 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %73)
store i32 0, i32* %20
br label %75
75: ; preds = %190, %72
%76 = load i32, i32* %20
%77 = load i32, i32* %6
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %193
79: ; preds = %75
%80 = load i32, i32* %20
store i32 %80, i32* %21
%81 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%83 = load i32, i32* %21
%84 = call i32 @sprintf(i8* %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %82, i32 %83)
%85 = load i32, i32* %19
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %79
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%89 = call i32 @unlink(i8* %88)
br label %90
90: ; preds = %87, %79
%91 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%92 = load i32, i32* @O_RDWR
%93 = load i32, i32* @O_CREAT
%94 = or i32 %92, %93
%95 = load i32, i32* @O_APPEND
%96 = or i32 %94, %95
%97 = call i32 @open(i8* %91, i32 %96, i32 0)
%98 = load i32, i32* %21
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i32, i32* %34, i64 %99
store i32 %97, i32* %100
%101 = load i32, i32* %21
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %34, i64 %102
%104 = load i32, i32* %103
%105 = load i32, i32* %21
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %106
%108 = call i32 @fstat(i32 %104, %struct.stat* %107)
store i32 %108, i32* %17
%109 = load i32, i32* %17
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %90
%112 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%113 = load i32, i32* %9
%114 = add nsw i32 %113, 1
store i32 %114, i32* %9
br label %165
115: ; preds = %90
%116 = load i32, i32* %19
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %115
store i32 0, i32* %22
br label %135
119: ; preds = %115
%120 = load i32, i32* %20
%121 = srem i32 %120, 2
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %119
store i32 0, i32* %22
br label %134
124: ; preds = %119
%125 = load i32, i32* %19
%126 = load i32, i32* %6
%127 = load i32, i32* %20
%128 = sub nsw i32 %126, %127
%129 = mul nsw i32 %125, %128
%130 = load i32, i32* %8
%131 = load i32, i32* %7
%132 = mul nsw i32 %130, %131
%133 = mul nsw i32 %129, %132
store i32 %133, i32* %22
br label %134
134: ; preds = %124, %123
br label %135
135: ; preds = %134, %118
%136 = load i32, i32* %21
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %137
%139 = getelementptr inbounds %struct.stat, %struct.stat* %138, i32 0, i32 0
%140 = load i32, i32* %139
%141 = load i32, i32* %22
%142 = icmp eq i32 %140, %141
br i1 %142, label %143, label %152
143: ; preds = %135
%144 = load i32, i32* %19
%145 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%146 = load i32, i32* %21
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %147
%149 = getelementptr inbounds %struct.stat, %struct.stat* %148, i32 0, i32 0
%150 = load i32, i32* %149
%151 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %144, i8* %145, i32 %150)
br label %164
152: ; preds = %135
%153 = load i32, i32* %19
%154 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%155 = load i32, i32* %22
%156 = load i32, i32* %21
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %157
%159 = getelementptr inbounds %struct.stat, %struct.stat* %158, i32 0, i32 0
%160 = load i32, i32* %159
%161 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %153, i8* %154, i32 %155, i32 %160)
%162 = load i32, i32* %9
%163 = add nsw i32 %162, 1
store i32 %163, i32* %9
br label %164
164: ; preds = %152, %143
br label %165
165: ; preds = %164, %111
store i32 0, i32* %23
br label %166
166: ; preds = %186, %165
%167 = load i32, i32* %23
%168 = load i32, i32* %21
%169 = icmp sle i32 %167, %168
br i1 %169, label %170, label %189
170: ; preds = %166
store i32 0, i32* %24
br label %171
171: ; preds = %182, %170
%172 = load i32, i32* %24
%173 = load i32, i32* %8
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %185
175: ; preds = %171
%176 = load i32, i32* %23
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i32, i32* %34, i64 %177
%179 = load i32, i32* %178
%180 = load i32, i32* %7
%181 = call i32 @write(i32 %179, i8* %40, i32 %180)
br label %182
182: ; preds = %175
%183 = load i32, i32* %24
%184 = add nsw i32 %183, 1
store i32 %184, i32* %24
br label %171
185: ; preds = %171
br label %186
186: ; preds = %185
%187 = load i32, i32* %23
%188 = add nsw i32 %187, 1
store i32 %188, i32* %23
br label %166
189: ; preds = %166
br label %190
190: ; preds = %189
%191 = load i32, i32* %20
%192 = add nsw i32 %191, 1
store i32 %192, i32* %20
br label %75
193: ; preds = %75
store i32 0, i32* %25
br label %194
194: ; preds = %272, %193
%195 = load i32, i32* %25
%196 = load i32, i32* %6
%197 = icmp slt i32 %195, %196
br i1 %197, label %198, label %275
198: ; preds = %194
%199 = load i32, i32* %25
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds i32, i32* %34, i64 %200
%202 = load i32, i32* %201
%203 = load i32, i32* %25
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %204
%206 = call i32 @fstat(i32 %202, %struct.stat* %205)
store i32 %206, i32* %17
%207 = load i32, i32* %17
%208 = icmp slt i32 %207, 0
br i1 %208, label %209, label %213
209: ; preds = %198
%210 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%211 = load i32, i32* %9
%212 = add nsw i32 %211, 1
store i32 %212, i32* %9
br label %266
213: ; preds = %198
%214 = load i32, i32* %25
%215 = srem i32 %214, 2
%216 = icmp eq i32 %215, 0
br i1 %216, label %217, label %225
217: ; preds = %213
%218 = load i32, i32* %6
%219 = load i32, i32* %25
%220 = sub nsw i32 %218, %219
%221 = load i32, i32* %8
%222 = load i32, i32* %7
%223 = mul nsw i32 %221, %222
%224 = mul nsw i32 %220, %223
store i32 %224, i32* %26
br label %236
225: ; preds = %213
%226 = load i32, i32* %19
%227 = add nsw i32 %226, 1
%228 = load i32, i32* %6
%229 = load i32, i32* %25
%230 = sub nsw i32 %228, %229
%231 = mul nsw i32 %227, %230
%232 = load i32, i32* %8
%233 = load i32, i32* %7
%234 = mul nsw i32 %232, %233
%235 = mul nsw i32 %231, %234
store i32 %235, i32* %26
br label %236
236: ; preds = %225, %217
%237 = load i32, i32* %25
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %238
%240 = getelementptr inbounds %struct.stat, %struct.stat* %239, i32 0, i32 0
%241 = load i32, i32* %240
%242 = load i32, i32* %26
%243 = icmp eq i32 %241, %242
br i1 %243, label %244, label %253
244: ; preds = %236
%245 = load i32, i32* %19
%246 = load i32, i32* %25
%247 = load i32, i32* %25
%248 = sext i32 %247 to i64
%249 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %248
%250 = getelementptr inbounds %struct.stat, %struct.stat* %249, i32 0, i32 0
%251 = load i32, i32* %250
%252 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %245, i32 %246, i32 %251)
br label %265
253: ; preds = %236
%254 = load i32, i32* %19
%255 = load i32, i32* %25
%256 = load i32, i32* %26
%257 = load i32, i32* %25
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %258
%260 = getelementptr inbounds %struct.stat, %struct.stat* %259, i32 0, i32 0
%261 = load i32, i32* %260
%262 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %254, i32 %255, i32 %256, i32 %261)
%263 = load i32, i32* %9
%264 = add nsw i32 %263, 1
store i32 %264, i32* %9
br label %265
265: ; preds = %253, %244
br label %266
266: ; preds = %265, %209
%267 = load i32, i32* %25
%268 = sext i32 %267 to i64
%269 = getelementptr inbounds i32, i32* %34, i64 %268
%270 = load i32, i32* %269
%271 = call i32 @close(i32 %270)
br label %272
272: ; preds = %266
%273 = load i32, i32* %25
%274 = add nsw i32 %273, 1
store i32 %274, i32* %25
br label %194
275: ; preds = %194
store i32 0, i32* %27
br label %276
276: ; preds = %360, %275
%277 = load i32, i32* %27
%278 = load i32, i32* %6
%279 = icmp slt i32 %277, %278
br i1 %279, label %280, label %363
280: ; preds = %276
%281 = load i32, i32* %27
store i32 %281, i32* %28
%282 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%283 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%284 = load i32, i32* %28
%285 = call i32 @sprintf(i8* %282, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %283, i32 %284)
%286 = load i32, i32* %27
%287 = srem i32 %286, 2
%288 = icmp eq i32 %287, 0
br i1 %288, label %289, label %293
289: ; preds = %280
%290 = load i32, i32* @O_RDWR
%291 = load i32, i32* @O_TRUNC
%292 = or i32 %290, %291
store i32 %292, i32* %29
br label %295
293: ; preds = %280
%294 = load i32, i32* @O_RDWR
store i32 %294, i32* %29
br label %295
295: ; preds = %293, %289
%296 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%297 = load i32, i32* %29
%298 = call i32 @open(i8* %296, i32 %297, i32 0)
%299 = load i32, i32* %28
%300 = sext i32 %299 to i64
%301 = getelementptr inbounds i32, i32* %34, i64 %300
store i32 %298, i32* %301
%302 = load i32, i32* %28
%303 = sext i32 %302 to i64
%304 = getelementptr inbounds i32, i32* %34, i64 %303
%305 = load i32, i32* %304
%306 = load i32, i32* %28
%307 = sext i32 %306 to i64
%308 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %307
%309 = call i32 @fstat(i32 %305, %struct.stat* %308)
store i32 %309, i32* %17
%310 = load i32, i32* %17
%311 = icmp slt i32 %310, 0
br i1 %311, label %312, label %316
312: ; preds = %295
%313 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%314 = load i32, i32* %9
%315 = add nsw i32 %314, 1
store i32 %315, i32* %9
br label %359
316: ; preds = %295
%317 = load i32, i32* %29
%318 = load i32, i32* @O_TRUNC
%319 = and i32 %317, %318
%320 = icmp ne i32 %319, 0
br i1 %320, label %321, label %322
321: ; preds = %316
store i32 0, i32* %30
br label %328
322: ; preds = %316
%323 = load i32, i32* %28
%324 = sext i32 %323 to i64
%325 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %324
%326 = getelementptr inbounds %struct.stat, %struct.stat* %325, i32 0, i32 0
%327 = load i32, i32* %326
store i32 %327, i32* %30
br label %328
328: ; preds = %322, %321
%329 = load i32, i32* %28
%330 = sext i32 %329 to i64
%331 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %330
%332 = getelementptr inbounds %struct.stat, %struct.stat* %331, i32 0, i32 0
%333 = load i32, i32* %332
%334 = load i32, i32* %30
%335 = icmp eq i32 %333, %334
br i1 %335, label %336, label %346
336: ; preds = %328
%337 = load i32, i32* %19
%338 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%339 = load i32, i32* %30
%340 = load i32, i32* %28
%341 = sext i32 %340 to i64
%342 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %341
%343 = getelementptr inbounds %struct.stat, %struct.stat* %342, i32 0, i32 0
%344 = load i32, i32* %343
%345 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %337, i8* %338, i32 %339, i32 %344)
br label %358
346: ; preds = %328
%347 = load i32, i32* %19
%348 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%349 = load i32, i32* %30
%350 = load i32, i32* %28
%351 = sext i32 %350 to i64
%352 = getelementptr inbounds %struct.stat, %struct.stat* %37, i64 %351
%353 = getelementptr inbounds %struct.stat, %struct.stat* %352, i32 0, i32 0
%354 = load i32, i32* %353
%355 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i32 %347, i8* %348, i32 %349, i32 %354)
%356 = load i32, i32* %9
%357 = add nsw i32 %356, 1
store i32 %357, i32* %9
br label %358
358: ; preds = %346, %336
br label %359
359: ; preds = %358, %312
br label %360
360: ; preds = %359
%361 = load i32, i32* %27
%362 = add nsw i32 %361, 1
store i32 %362, i32* %27
br label %276
363: ; preds = %276
br label %364
364: ; preds = %363
%365 = load i32, i32* %19
%366 = add nsw i32 %365, 1
store i32 %366, i32* %19
br label %68
367: ; preds = %68
%368 = load i32, i32* %9
%369 = load i8*, i8** %10
ret i32 %368
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [17 x i8] c"r%d n%d s%d i%d\0A\00"
@.str.1 = [12 x i8] c"zerolength-\00"
@.str.2 = [11 x i8] c"Round: %d\0A\00"
@.str.3 = [5 x i8] c"%s%d\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.4 = [16 x i8] c"ERROR on fstat\0A\00"
@.str.5 = [40 x i8] c"%d. %s On create, got expected size %d\0A\00"
@.str.6 = [48 x i8] c"%d: %s On create, ERROR expected %d size is %d\0A\00"
@.str.7 = [56 x i8] c"%d. zerolength-%d After write, got expected size of %d\0A\00"
@.str.8 = [61 x i8] c"%d. zerolength-%d After write, ERROR expected %d size is %d\0A\00"
@O_TRUNC = global i32 0
@.str.9 = [43 x i8] c"%d. %s After reopen, expect %d size is %d\0A\00"
@.str.10 = [49 x i8] c"%d. %s After reopen, ERROR expect %d size is %d\0A\00"
define i32 @process(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = zext i32 %1 to i64
%8 = alloca i32, i64 %7
%9 = alloca %struct.stat, i64 %7
%10 = zext i32 %2 to i64
%11 = alloca i8, i64 %10
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%14 = tail call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i32 %3)
%15 = icmp sgt i32 %2, 0
br i1 %15, label %16, label %37
16: ; preds = %4
%17 = add nsw i64 %10, -1
%18 = and i64 %10, 3
%19 = icmp ult i64 %17, 3
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = and i64 %10, 4294967292
br label %44
22: ; preds = %44, %16
%23 = phi i64 [ 0, %16 ], [ %67, %44 ]
%24 = phi i8 [ 65, %16 ], [ %66, %44 ]
%25 = icmp eq i64 %18, 0
br i1 %25, label %37, label %26
26: ; preds = %22, %26
%27 = phi i64 [ %34, %26 ], [ %23, %22 ]
%28 = phi i8 [ %33, %26 ], [ %24, %22 ]
%29 = phi i64 [ %35, %26 ], [ 0, %22 ]
%30 = getelementptr inbounds i8, i8* %11, i64 %27
store i8 %28, i8* %30
%31 = add i8 %28, 1
%32 = icmp sgt i8 %31, 122
%33 = select i1 %32, i8 65, i8 %31
%34 = add nuw nsw i64 %27, 1
%35 = add i64 %29, 1
%36 = icmp eq i64 %35, %18
br i1 %36, label %37, label %26
37: ; preds = %22, %26, %4
%38 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp sgt i32 %0, 0
br i1 %39, label %40, label %70
40: ; preds = %37
%41 = icmp sgt i32 %1, 0
%42 = mul i32 %3, %2
%43 = icmp sgt i32 %3, 0
br label %72
44: ; preds = %44, %20
%45 = phi i64 [ 0, %20 ], [ %67, %44 ]
%46 = phi i8 [ 65, %20 ], [ %66, %44 ]
%47 = phi i64 [ 0, %20 ], [ %68, %44 ]
%48 = getelementptr inbounds i8, i8* %11, i64 %45
store i8 %46, i8* %48
%49 = add i8 %46, 1
%50 = icmp sgt i8 %49, 122
%51 = select i1 %50, i8 65, i8 %49
%52 = or i64 %45, 1
%53 = getelementptr inbounds i8, i8* %11, i64 %52
store i8 %51, i8* %53
%54 = add i8 %51, 1
%55 = icmp sgt i8 %54, 122
%56 = select i1 %55, i8 65, i8 %54
%57 = or i64 %45, 2
%58 = getelementptr inbounds i8, i8* %11, i64 %57
store i8 %56, i8* %58
%59 = add i8 %56, 1
%60 = icmp sgt i8 %59, 122
%61 = select i1 %60, i8 65, i8 %59
%62 = or i64 %45, 3
%63 = getelementptr inbounds i8, i8* %11, i64 %62
store i8 %61, i8* %63
%64 = add i8 %61, 1
%65 = icmp sgt i8 %64, 122
%66 = select i1 %65, i8 65, i8 %64
%67 = add nuw nsw i64 %45, 4
%68 = add i64 %47, 4
%69 = icmp eq i64 %68, %21
br i1 %69, label %22, label %44
70: ; preds = %171, %37
%71 = phi i32 [ 0, %37 ], [ %172, %171 ]
ret i32 %71
72: ; preds = %40, %171
%73 = phi i32 [ 0, %40 ], [ %172, %171 ]
%74 = phi i32 [ 0, %40 ], [ %173, %171 ]
%75 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %74)
br i1 %41, label %76, label %171
76: ; preds = %72
%77 = icmp eq i32 %74, 0
%78 = mul i32 %42, %74
br label %82
79: ; preds = %126
br i1 %41, label %80, label %171
80: ; preds = %79
%81 = add nuw nsw i32 %74, 1
br label %139
82: ; preds = %76, %126
%83 = phi i64 [ 0, %76 ], [ %127, %126 ]
%84 = phi i64 [ 1, %76 ], [ %128, %126 ]
%85 = phi i32 [ %73, %76 ], [ %120, %126 ]
%86 = trunc i64 %83 to i32
%87 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %12, i32 %86)
br i1 %77, label %88, label %90
88: ; preds = %82
%89 = call i32 @unlink(i8* %13)
br label %90
90: ; preds = %88, %82
%91 = load i32, i32* @O_RDWR
%92 = load i32, i32* @O_CREAT
%93 = or i32 %92, %91
%94 = load i32, i32* @O_APPEND
%95 = or i32 %93, %94
%96 = call i32 @open(i8* %13, i32 %95, i32 0)
%97 = getelementptr inbounds i32, i32* %8, i64 %83
store i32 %96, i32* %97
%98 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 %83
%99 = call i32 @fstat(i32 %96, %struct.stat* %98)
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %90
%102 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%103 = add nsw i32 %85, 1
br label %119
104: ; preds = %90
%105 = and i32 %86, 1
%106 = icmp eq i32 %105, 0
%107 = or i1 %77, %106
%108 = sub nsw i32 %1, %86
%109 = mul i32 %78, %108
%110 = select i1 %107, i32 0, i32 %109
%111 = getelementptr inbounds %struct.stat, %struct.stat* %98, i64 0, i32 0
%112 = load i32, i32* %111
%113 = icmp eq i32 %112, %110
br i1 %113, label %114, label %116
114: ; preds = %104
%115 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %74, i8* %13, i32 %110)
br label %119
116: ; preds = %104
%117 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %74, i8* %13, i32 %110, i32 %112)
%118 = add nsw i32 %85, 1
br label %119
119: ; preds = %114, %116, %101
%120 = phi i32 [ %103, %101 ], [ %85, %114 ], [ %118, %116 ]
br label %121
121: ; preds = %119, %130
%122 = phi i64 [ 0, %119 ], [ %131, %130 ]
br i1 %43, label %123, label %130
123: ; preds = %121
%124 = getelementptr inbounds i32, i32* %8, i64 %122
%125 = load i32, i32* %124
br label %133
126: ; preds = %130
%127 = add nuw nsw i64 %83, 1
%128 = add nuw nsw i64 %84, 1
%129 = icmp eq i64 %127, %7
br i1 %129, label %79, label %82
130: ; preds = %133, %121
%131 = add nuw nsw i64 %122, 1
%132 = icmp eq i64 %131, %84
br i1 %132, label %126, label %121
133: ; preds = %123, %133
%134 = phi i32 [ 0, %123 ], [ %136, %133 ]
%135 = call i32 @write(i32 %125, i8* %11, i32 %2)
%136 = add nuw nsw i32 %134, 1
%137 = icmp eq i32 %136, %3
br i1 %137, label %130, label %133
138: ; preds = %166
br i1 %41, label %175, label %171
139: ; preds = %80, %166
%140 = phi i64 [ 0, %80 ], [ %169, %166 ]
%141 = phi i32 [ %120, %80 ], [ %167, %166 ]
%142 = getelementptr inbounds i32, i32* %8, i64 %140
%143 = load i32, i32* %142
%144 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 %140
%145 = call i32 @fstat(i32 %143, %struct.stat* %144)
%146 = icmp slt i32 %145, 0
br i1 %146, label %147, label %150
147: ; preds = %139
%148 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%149 = add nsw i32 %141, 1
br label %166
150: ; preds = %139
%151 = trunc i64 %140 to i32
%152 = and i32 %151, 1
%153 = icmp eq i32 %152, 0
%154 = sub nsw i32 %1, %151
%155 = select i1 %153, i32 1, i32 %81
%156 = mul i32 %42, %155
%157 = mul i32 %156, %154
%158 = getelementptr inbounds %struct.stat, %struct.stat* %144, i64 0, i32 0
%159 = load i32, i32* %158
%160 = icmp eq i32 %159, %157
br i1 %160, label %161, label %163
161: ; preds = %150
%162 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %74, i32 %151, i32 %157)
br label %166
163: ; preds = %150
%164 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %74, i32 %151, i32 %157, i32 %159)
%165 = add nsw i32 %141, 1
br label %166
166: ; preds = %161, %163, %147
%167 = phi i32 [ %149, %147 ], [ %141, %161 ], [ %165, %163 ]
%168 = call i32 @close(i32 %143)
%169 = add nuw nsw i64 %140, 1
%170 = icmp eq i64 %169, %7
br i1 %170, label %138, label %139
171: ; preds = %208, %72, %79, %138
%172 = phi i32 [ %167, %138 ], [ %120, %79 ], [ %73, %72 ], [ %209, %208 ]
%173 = add nuw nsw i32 %74, 1
%174 = icmp eq i32 %173, %0
br i1 %174, label %70, label %72
175: ; preds = %138, %208
%176 = phi i64 [ %210, %208 ], [ 0, %138 ]
%177 = phi i32 [ %209, %208 ], [ %167, %138 ]
%178 = trunc i64 %176 to i32
%179 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %12, i32 %178)
%180 = and i32 %178, 1
%181 = icmp eq i32 %180, 0
%182 = load i32, i32* @O_RDWR
%183 = load i32, i32* @O_TRUNC
%184 = select i1 %181, i32 %183, i32 0
%185 = or i32 %184, %182
%186 = call i32 @open(i8* %13, i32 %185, i32 0)
%187 = getelementptr inbounds i32, i32* %8, i64 %176
store i32 %186, i32* %187
%188 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 %176
%189 = call i32 @fstat(i32 %186, %struct.stat* %188)
%190 = icmp slt i32 %189, 0
br i1 %190, label %191, label %194
191: ; preds = %175
%192 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%193 = add nsw i32 %177, 1
br label %208
194: ; preds = %175
%195 = load i32, i32* @O_TRUNC
%196 = and i32 %195, %185
%197 = icmp eq i32 %196, 0
%198 = getelementptr inbounds %struct.stat, %struct.stat* %188, i64 0, i32 0
%199 = load i32, i32* %198
br i1 %197, label %202, label %200
200: ; preds = %194
%201 = icmp eq i32 %199, 0
br i1 %201, label %202, label %205
202: ; preds = %194, %200
%203 = phi i32 [ 0, %200 ], [ %199, %194 ]
%204 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %74, i8* %13, i32 %203, i32 %203)
br label %208
205: ; preds = %200
%206 = call i32 (i8*, ...) @v_printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i32 %74, i8* %13, i32 0, i32 %199)
%207 = add nsw i32 %177, 1
br label %208
208: ; preds = %202, %205, %191
%209 = phi i32 [ %193, %191 ], [ %177, %202 ], [ %207, %205 ]
%210 = add nuw nsw i64 %176, 1
%211 = icmp eq i64 %210, %7
br i1 %211, label %171, label %175
}