#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 timeval {
  scalar_t__ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct stat {
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fstat(int, struct stat *);
scalar_t__ ftruncate(int, scalar_t__);
int full_read(int, char *, int);
scalar_t__ full_write(int, char *, int);
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ utimes(char *, struct timeval *);
int main(int argc, char *argv[]) {
  int i;
  for (i = 1; i < argc; i++) {
    char *filename = argv[i];
    int rfd = open(filename, O_RDONLY);
    if (rfd < 0) {
      perror(filename);
      goto next;
    }
    {
      struct stat statbuf;
      if (fstat(rfd, &statbuf) < 0) {
        perror(filename);
        goto next;
      }
      {
        int wfd = open(filename, O_RDWR);
        if (wfd < 0) {
          perror(filename);
          close(rfd);
          goto next;
        }
        {
          char buffer[4096];
          char *bufend = &buffer[4096];
          register char *srcptr = &buffer[0];
          register char *destptr;
          while (1) {
            register int count = full_read(rfd, srcptr, bufend - srcptr);
            if (count < 0) {
              perror(filename);
              close(wfd);
              close(rfd);
              goto next;
            }
            if (count == 0)
              break;
            count += (srcptr - &buffer[0]);
            destptr = srcptr = &buffer[0];
            do {
              if (*srcptr == 13) {
                if (count > 1) {
                  if (srcptr[1] == 10) {
                    *destptr++ = 10;
                    srcptr += 2;
                    count -= 2;
                  } else {
                    *destptr++ = *srcptr++;
                    count--;
                  }
                } else
                  break;
              } else {
                *destptr++ = *srcptr++;
                count--;
              }
            } while (count > 0);
            if (full_write(wfd, buffer, destptr - buffer) < 0) {
              perror(filename);
              close(wfd);
              close(rfd);
              goto next;
            }
            if (count > 0) {
              buffer[0] = *srcptr;
              srcptr = &buffer[1];
            } else {
              srcptr = &buffer[0];
            }
          }
          if (srcptr != buffer) {
            if (full_write(wfd, buffer, srcptr - buffer) < 0) {
              perror(filename);
              close(wfd);
              close(rfd);
              goto next;
            }
          }
        }
        {
          off_t length = lseek(wfd, 0, SEEK_CUR);
          if (length < 0) {
            perror(filename);
            close(wfd);
            close(rfd);
            goto next;
          }
          if (ftruncate(wfd, length) < 0) {
            perror(filename);
            close(wfd);
            close(rfd);
            goto next;
          }
        }
        close(wfd);
      }
      close(rfd);
      {
        struct timeval tv[2];
        tv[0].tv_sec = statbuf.st_atime;
        tv[0].tv_usec = 0;
        tv[1].tv_sec = statbuf.st_mtime;
        tv[1].tv_usec = 0;
        if (utimes(filename, tv) < 0) {
          perror(filename);
          goto next;
        }
      }
    }
  next:;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1090,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1617 <main+0x477>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1209 <main+0x69>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
jmp    1604 <main+0x464>
mov    -0x24(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10c0 <fstat@plt>
cmp    $0x0,%rax
jge    122d <main+0x8d>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
jmp    1604 <main+0x464>
mov    -0x20(%rbp),%rdi
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1262 <main+0xc2>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
lea    -0x1040(%rbp),%rax
add    $0x1000,%rax
mov    %rax,-0x1048(%rbp)
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1050(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x1050(%rbp),%rsi
mov    -0x1048(%rbp),%rax
mov    -0x1050(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <full_read@plt>
mov    %eax,-0x105c(%rbp)
cmpl   $0x0,-0x105c(%rbp)
jge    12d7 <main+0x137>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
cmpl   $0x0,-0x105c(%rbp)
jne    12e9 <main+0x149>
jmp    14bc <main+0x31c>
mov    -0x1050(%rbp),%rcx
lea    -0x1040(%rbp),%rax
sub    %rax,%rcx
movslq -0x105c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x105c(%rbp)
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1050(%rbp)
mov    %rax,-0x1058(%rbp)
mov    -0x1050(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    13dd <main+0x23d>
cmpl   $0x1,-0x105c(%rbp)
jle    13d3 <main+0x233>
mov    -0x1050(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
jne    1391 <main+0x1f1>
mov    -0x1058(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1058(%rbp)
movb   $0xa,(%rax)
mov    -0x1050(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x1050(%rbp)
mov    -0x105c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x105c(%rbp)
jmp    13ce <main+0x22e>
mov    -0x1050(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1050(%rbp)
mov    (%rax),%cl
mov    -0x1058(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x1058(%rbp)
mov    %cl,(%rax)
mov    -0x105c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x105c(%rbp)
jmp    13d8 <main+0x238>
jmp    142c <main+0x28c>
jmp    141a <main+0x27a>
mov    -0x1050(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1050(%rbp)
mov    (%rax),%cl
mov    -0x1058(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x1058(%rbp)
mov    %cl,(%rax)
mov    -0x105c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x105c(%rbp)
jmp    141f <main+0x27f>
cmpl   $0x0,-0x105c(%rbp)
jg     131f <main+0x17f>
mov    -0x34(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    -0x1058(%rbp),%rax
lea    -0x1040(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1080 <full_write@plt>
cmp    $0x0,%rax
jge    1476 <main+0x2d6>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
cmpl   $0x0,-0x105c(%rbp)
jle    14a9 <main+0x309>
mov    -0x1050(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1040(%rbp)
lea    -0x1040(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1050(%rbp)
jmp    14b7 <main+0x317>
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1050(%rbp)
jmp    1284 <main+0xe4>
mov    -0x1050(%rbp),%rax
lea    -0x1040(%rbp),%rcx
cmp    %rcx,%rax
je     1522 <main+0x382>
mov    -0x34(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    -0x1050(%rbp),%rax
lea    -0x1040(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1080 <full_write@plt>
cmp    $0x0,%rax
jge    151d <main+0x37d>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
jmp    1522 <main+0x382>
mov    -0x34(%rbp),%edi
mov    0x2ab4(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %rax,-0x1068(%rbp)
cmpq   $0x0,-0x1068(%rbp)
jge    1568 <main+0x3c8>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
mov    -0x34(%rbp),%edi
mov    -0x1068(%rbp),%rsi
call   1040 <ftruncate@plt>
cmp    $0x0,%rax
jge    159f <main+0x3ff>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1604 <main+0x464>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1088(%rbp)
movq   $0x0,-0x1090(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x1078(%rbp)
movq   $0x0,-0x1080(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x1090(%rbp),%rsi
call   1070 <utimes@plt>
cmp    $0x0,%rax
jge    15ff <main+0x45f>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
jmp    1604 <main+0x464>
jmp    1604 <main+0x464>
jmp    1609 <main+0x469>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c0 <main+0x20>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    %rsi,0x18(%rsp)
cmp    $0x2,%edi
jl     13d7 <main+0x237>
mov    %edi,%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r12d
lea    0x20(%rsp),%r15
jmp    11ef <main+0x4f>
mov    %rbx,%rdi
call   10a0 <perror@plt>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    0x10(%rsp),%r12
je     13d7 <main+0x237>
mov    0x18(%rsp),%rax
mov    (%rax,%r12,8),%rbx
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     11d3 <main+0x33>
mov    %eax,%r13d
mov    %eax,%edi
lea    0x8(%rsp),%rsi
call   10c0 <fstat@plt>
test   %rax,%rax
js     11d3 <main+0x33>
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     13cd <main+0x22d>
mov    %eax,%ebp
mov    %rbx,(%rsp)
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1000,%edx
call   1030 <full_read@plt>
test   %eax,%eax
js     13b0 <main+0x210>
mov    %r15,%rbx
je     131e <main+0x17e>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    %r15d,%ebx
add    %eax,%ebx
mov    %r15,%r14
mov    %r15,%rdx
jmp    1293 <main+0xf3>
nopl   (%rax)
add    $0x1,%r14
mov    %al,(%rdx)
mov    $0xffffffff,%eax
add    $0x1,%rdx
add    %eax,%ebx
jle    12d0 <main+0x130>
movzbl (%r14),%eax
cmp    $0xd,%al
jne    1280 <main+0xe0>
cmp    $0x2,%ebx
jl     12d0 <main+0x130>
cmpb   $0xa,0x1(%r14)
jne    12c0 <main+0x120>
movb   $0xa,(%rdx)
add    $0x2,%r14
mov    $0xfffffffe,%eax
jmp    128b <main+0xeb>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
movb   $0xd,(%rdx)
jmp    1286 <main+0xe6>
nopl   0x0(%rax)
sub    %r15d,%edx
mov    %ebp,%edi
mov    %r15,%rsi
call   1080 <full_write@plt>
test   %rax,%rax
js     13b0 <main+0x210>
test   %ebx,%ebx
mov    %r15,%rbx
jle    12f9 <main+0x159>
mov    (%r14),%al
mov    %al,0x20(%rsp)
lea    0x21(%rsp),%rbx
lea    0x1020(%rsp),%rax
mov    %eax,%edx
sub    %ebx,%edx
mov    %r13d,%edi
mov    %rbx,%rsi
call   1030 <full_read@plt>
test   %eax,%eax
js     13b0 <main+0x210>
jne    1270 <main+0xd0>
cmp    %r15,%rbx
je     1337 <main+0x197>
sub    %r15d,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1080 <full_write@plt>
test   %rax,%rax
js     13b0 <main+0x210>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
test   %rax,%rax
js     13b0 <main+0x210>
mov    %ebp,%edi
mov    %rax,%rsi
call   1040 <ftruncate@plt>
test   %rax,%rax
js     13b0 <main+0x210>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r13d,%edi
call   1060 <close@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
mov    %ecx,0x28(%rsp)
movq   $0x0,0x20(%rsp)
mov    %eax,0x38(%rsp)
movq   $0x0,0x30(%rsp)
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <utimes@plt>
test   %rax,%rax
jns    11e0 <main+0x40>
jmp    11d3 <main+0x33>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
call   10a0 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r13d,%edi
call   1060 <close@plt>
jmp    11e0 <main+0x40>
mov    %rbx,%rdi
call   10a0 <perror@plt>
jmp    13c0 <main+0x220>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.timeval = type { i64, i32 }
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i64
%17 = alloca [2 x %struct.timeval]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %18
18: ; preds = %238, %2
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %241
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %28, i32 %29)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = load i8*, i8** %7
%35 = call i32 @perror(i8* %34)
br label %237
36: ; preds = %22
%37 = load i32, i32* %8
%38 = call i64 @fstat(i32 %37, %struct.stat* %9)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i8*, i8** %7
%42 = call i32 @perror(i8* %41)
br label %237
43: ; preds = %36
%44 = load i8*, i8** %7
%45 = load i32, i32* @O_RDWR
%46 = call i32 @open(i8* %44, i32 %45)
store i32 %46, i32* %10
%47 = load i32, i32* %10
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = load i8*, i8** %7
%51 = call i32 @perror(i8* %50)
%52 = load i32, i32* %8
%53 = call i32 @close(i32 %52)
br label %237
54: ; preds = %43
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 4096
store i8* %55, i8** %12
%56 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8* %56, i8** %13
br label %57
57: ; preds = %54, %163
%58 = load i32, i32* %8
%59 = load i8*, i8** %13
%60 = load i8*, i8** %12
%61 = load i8*, i8** %13
%62 = ptrtoint i8* %60 to i64
%63 = ptrtoint i8* %61 to i64
%64 = sub i64 %62, %63
%65 = trunc i64 %64 to i32
%66 = call i32 @full_read(i32 %58, i8* %59, i32 %65)
store i32 %66, i32* %15
%67 = load i32, i32* %15
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %57
%70 = load i8*, i8** %7
%71 = call i32 @perror(i8* %70)
%72 = load i32, i32* %10
%73 = call i32 @close(i32 %72)
%74 = load i32, i32* %8
%75 = call i32 @close(i32 %74)
br label %237
76: ; preds = %57
%77 = load i32, i32* %15
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %76
br label %164
80: ; preds = %76
%81 = load i8*, i8** %13
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%83 = ptrtoint i8* %81 to i64
%84 = ptrtoint i8* %82 to i64
%85 = sub i64 %83, %84
%86 = load i32, i32* %15
%87 = sext i32 %86 to i64
%88 = add nsw i64 %87, %85
%89 = trunc i64 %88 to i32
store i32 %89, i32* %15
%90 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8* %90, i8** %13
store i8* %90, i8** %14
br label %91
91: ; preds = %132, %80
%92 = load i8*, i8** %13
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 13
br i1 %95, label %96, label %123
96: ; preds = %91
%97 = load i32, i32* %15
%98 = icmp sgt i32 %97, 1
br i1 %98, label %99, label %121
99: ; preds = %96
%100 = load i8*, i8** %13
%101 = getelementptr inbounds i8, i8* %100, i64 1
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 10
br i1 %104, label %105, label %112
105: ; preds = %99
%106 = load i8*, i8** %14
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %14
store i8 10, i8* %106
%108 = load i8*, i8** %13
%109 = getelementptr inbounds i8, i8* %108, i64 2
store i8* %109, i8** %13
%110 = load i32, i32* %15
%111 = sub nsw i32 %110, 2
store i32 %111, i32* %15
br label %120
112: ; preds = %99
%113 = load i8*, i8** %13
%114 = getelementptr inbounds i8, i8* %113, i32 1
store i8* %114, i8** %13
%115 = load i8, i8* %113
%116 = load i8*, i8** %14
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %14
store i8 %115, i8* %116
%118 = load i32, i32* %15
%119 = add nsw i32 %118, -1
store i32 %119, i32* %15
br label %120
120: ; preds = %112, %105
br label %122
121: ; preds = %96
br label %135
122: ; preds = %120
br label %131
123: ; preds = %91
%124 = load i8*, i8** %13
%125 = getelementptr inbounds i8, i8* %124, i32 1
store i8* %125, i8** %13
%126 = load i8, i8* %124
%127 = load i8*, i8** %14
%128 = getelementptr inbounds i8, i8* %127, i32 1
store i8* %128, i8** %14
store i8 %126, i8* %127
%129 = load i32, i32* %15
%130 = add nsw i32 %129, -1
store i32 %130, i32* %15
br label %131
131: ; preds = %123, %122
br label %132
132: ; preds = %131
%133 = load i32, i32* %15
%134 = icmp sgt i32 %133, 0
br i1 %134, label %91, label %135
135: ; preds = %132, %121
%136 = load i32, i32* %10
%137 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%138 = load i8*, i8** %14
%139 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%140 = ptrtoint i8* %138 to i64
%141 = ptrtoint i8* %139 to i64
%142 = sub i64 %140, %141
%143 = trunc i64 %142 to i32
%144 = call i64 @full_write(i32 %136, i8* %137, i32 %143)
%145 = icmp slt i64 %144, 0
br i1 %145, label %146, label %153
146: ; preds = %135
%147 = load i8*, i8** %7
%148 = call i32 @perror(i8* %147)
%149 = load i32, i32* %10
%150 = call i32 @close(i32 %149)
%151 = load i32, i32* %8
%152 = call i32 @close(i32 %151)
br label %237
153: ; preds = %135
%154 = load i32, i32* %15
%155 = icmp sgt i32 %154, 0
br i1 %155, label %156, label %161
156: ; preds = %153
%157 = load i8*, i8** %13
%158 = load i8, i8* %157
%159 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8 %158, i8* %159
%160 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 1
store i8* %160, i8** %13
br label %163
161: ; preds = %153
%162 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8* %162, i8** %13
br label %163
163: ; preds = %161, %156
br label %57
164: ; preds = %79
%165 = load i8*, i8** %13
%166 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%167 = icmp ne i8* %165, %166
br i1 %167, label %168, label %187
168: ; preds = %164
%169 = load i32, i32* %10
%170 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%171 = load i8*, i8** %13
%172 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%173 = ptrtoint i8* %171 to i64
%174 = ptrtoint i8* %172 to i64
%175 = sub i64 %173, %174
%176 = trunc i64 %175 to i32
%177 = call i64 @full_write(i32 %169, i8* %170, i32 %176)
%178 = icmp slt i64 %177, 0
br i1 %178, label %179, label %186
179: ; preds = %168
%180 = load i8*, i8** %7
%181 = call i32 @perror(i8* %180)
%182 = load i32, i32* %10
%183 = call i32 @close(i32 %182)
%184 = load i32, i32* %8
%185 = call i32 @close(i32 %184)
br label %237
186: ; preds = %168
br label %187
187: ; preds = %186, %164
%188 = load i32, i32* %10
%189 = load i32, i32* @SEEK_CUR
%190 = call i64 @lseek(i32 %188, i32 0, i32 %189)
store i64 %190, i64* %16
%191 = load i64, i64* %16
%192 = icmp slt i64 %191, 0
br i1 %192, label %193, label %200
193: ; preds = %187
%194 = load i8*, i8** %7
%195 = call i32 @perror(i8* %194)
%196 = load i32, i32* %10
%197 = call i32 @close(i32 %196)
%198 = load i32, i32* %8
%199 = call i32 @close(i32 %198)
br label %237
200: ; preds = %187
%201 = load i32, i32* %10
%202 = load i64, i64* %16
%203 = call i64 @ftruncate(i32 %201, i64 %202)
%204 = icmp slt i64 %203, 0
br i1 %204, label %205, label %212
205: ; preds = %200
%206 = load i8*, i8** %7
%207 = call i32 @perror(i8* %206)
%208 = load i32, i32* %10
%209 = call i32 @close(i32 %208)
%210 = load i32, i32* %8
%211 = call i32 @close(i32 %210)
br label %237
212: ; preds = %200
%213 = load i32, i32* %10
%214 = call i32 @close(i32 %213)
%215 = load i32, i32* %8
%216 = call i32 @close(i32 %215)
%217 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%218 = load i32, i32* %217
%219 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %17, i64 0, i64 0
%220 = getelementptr inbounds %struct.timeval, %struct.timeval* %219, i32 0, i32 1
store i32 %218, i32* %220
%221 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %17, i64 0, i64 0
%222 = getelementptr inbounds %struct.timeval, %struct.timeval* %221, i32 0, i32 0
store i64 0, i64* %222
%223 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%224 = load i32, i32* %223
%225 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %17, i64 0, i64 1
%226 = getelementptr inbounds %struct.timeval, %struct.timeval* %225, i32 0, i32 1
store i32 %224, i32* %226
%227 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %17, i64 0, i64 1
%228 = getelementptr inbounds %struct.timeval, %struct.timeval* %227, i32 0, i32 0
store i64 0, i64* %228
%229 = load i8*, i8** %7
%230 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %17, i64 0, i64 0
%231 = call i64 @utimes(i8* %229, %struct.timeval* %230)
%232 = icmp slt i64 %231, 0
br i1 %232, label %233, label %236
233: ; preds = %212
%234 = load i8*, i8** %7
%235 = call i32 @perror(i8* %234)
br label %237
236: ; preds = %212
br label %237
237: ; preds = %236, %233, %205, %193, %179, %146, %69, %49, %40, %33
br label %238
238: ; preds = %237
%239 = load i32, i32* %6
%240 = add nsw i32 %239, 1
store i32 %240, i32* %6
br label %18
241: ; preds = %18
%242 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.timeval = type { i64, i32 }
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [4096 x i8]
%5 = alloca [2 x %struct.timeval]
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %142
7: ; preds = %2
%8 = bitcast %struct.stat* %3 to i8*
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 4096
%11 = ptrtoint i8* %10 to i64
%12 = ptrtoint [4096 x i8]* %4 to i64
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 1
%14 = bitcast [2 x %struct.timeval]* %5 to i8*
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%16 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%17 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0, i32 1
%18 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0, i32 0
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1, i32 1
%21 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1, i32 0
%22 = zext i32 %0 to i64
br label %23
23: ; preds = %7, %139
%24 = phi i64 [ 1, %7 ], [ %140, %139 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @perror(i8* %26)
br label %139
32: ; preds = %23
%33 = call i64 @fstat(i32 %28, %struct.stat* %3)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @perror(i8* %26)
br label %138
37: ; preds = %32
%38 = load i32, i32* @O_RDWR
%39 = call i32 @open(i8* %26, i32 %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = call i32 @perror(i8* %26)
%43 = call i32 @close(i32 %28)
br label %138
44: ; preds = %37
%45 = call i32 @full_read(i32 %28, i8* %9, i32 4096)
%46 = icmp slt i32 %45, 0
br i1 %46, label %109, label %47
47: ; preds = %44
%48 = icmp eq i32 %45, 0
br i1 %48, label %100, label %51
49: ; preds = %93
%50 = icmp eq i32 %98, 0
br i1 %50, label %100, label %51
51: ; preds = %47, %49
%52 = phi i64 [ %95, %49 ], [ %12, %47 ]
%53 = phi i32 [ %98, %49 ], [ %45, %47 ]
%54 = sub i64 %52, %12
%55 = trunc i64 %54 to i32
%56 = add i32 %53, %55
br label %57
57: ; preds = %74, %51
%58 = phi i8* [ %9, %51 ], [ %76, %74 ]
%59 = phi i8* [ %9, %51 ], [ %78, %74 ]
%60 = phi i32 [ %56, %51 ], [ %77, %74 ]
%61 = load i8, i8* %58
%62 = icmp eq i8 %61, 13
br i1 %62, label %63, label %72
63: ; preds = %57
%64 = icmp sgt i32 %60, 1
br i1 %64, label %65, label %80
65: ; preds = %63
%66 = getelementptr inbounds i8, i8* %58, i64 1
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 10
br i1 %68, label %69, label %71
69: ; preds = %65
store i8 10, i8* %59
%70 = getelementptr inbounds i8, i8* %58, i64 2
br label %74
71: ; preds = %65
store i8 13, i8* %59
br label %74
72: ; preds = %57
%73 = getelementptr inbounds i8, i8* %58, i64 1
store i8 %61, i8* %59
br label %74
74: ; preds = %72, %69, %71
%75 = phi i32 [ -1, %72 ], [ -2, %69 ], [ -1, %71 ]
%76 = phi i8* [ %73, %72 ], [ %70, %69 ], [ %66, %71 ]
%77 = add nsw i32 %60, %75
%78 = getelementptr inbounds i8, i8* %59, i64 1
%79 = icmp sgt i32 %77, 0
br i1 %79, label %57, label %80
80: ; preds = %63, %74
%81 = phi i8* [ %76, %74 ], [ %58, %63 ]
%82 = phi i8* [ %78, %74 ], [ %59, %63 ]
%83 = phi i32 [ %77, %74 ], [ %60, %63 ]
%84 = ptrtoint i8* %82 to i64
%85 = sub i64 %84, %12
%86 = trunc i64 %85 to i32
%87 = call i64 @full_write(i32 %39, i8* %9, i32 %86)
%88 = icmp slt i64 %87, 0
br i1 %88, label %109, label %89
89: ; preds = %80
%90 = icmp sgt i32 %83, 0
br i1 %90, label %91, label %93
91: ; preds = %89
%92 = load i8, i8* %81
store i8 %92, i8* %9
br label %93
93: ; preds = %91, %89
%94 = phi i8* [ %13, %91 ], [ %9, %89 ]
%95 = ptrtoint i8* %94 to i64
%96 = sub i64 %11, %95
%97 = trunc i64 %96 to i32
%98 = call i32 @full_read(i32 %28, i8* %94, i32 %97)
%99 = icmp slt i32 %98, 0
br i1 %99, label %109, label %49
100: ; preds = %49, %47
%101 = phi i8* [ %9, %47 ], [ %94, %49 ]
%102 = icmp eq i8* %101, %9
br i1 %102, label %113, label %103
103: ; preds = %100
%104 = ptrtoint i8* %101 to i64
%105 = sub i64 %104, %12
%106 = trunc i64 %105 to i32
%107 = call i64 @full_write(i32 %39, i8* %9, i32 %106)
%108 = icmp slt i64 %107, 0
br i1 %108, label %109, label %113
109: ; preds = %80, %93, %103, %44
%110 = call i32 @perror(i8* %26)
%111 = call i32 @close(i32 %39)
%112 = call i32 @close(i32 %28)
br label %138
113: ; preds = %103, %100
%114 = load i32, i32* @SEEK_CUR
%115 = call i64 @lseek(i32 %39, i32 0, i32 %114)
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %121
117: ; preds = %113
%118 = call i32 @perror(i8* %26)
%119 = call i32 @close(i32 %39)
%120 = call i32 @close(i32 %28)
br label %138
121: ; preds = %113
%122 = call i64 @ftruncate(i32 %39, i64 %115)
%123 = icmp slt i64 %122, 0
br i1 %123, label %124, label %128
124: ; preds = %121
%125 = call i32 @perror(i8* %26)
%126 = call i32 @close(i32 %39)
%127 = call i32 @close(i32 %28)
br label %138
128: ; preds = %121
%129 = call i32 @close(i32 %39)
%130 = call i32 @close(i32 %28)
%131 = load i32, i32* %15
store i32 %131, i32* %17
store i64 0, i64* %18
%132 = load i32, i32* %19
store i32 %132, i32* %20
store i64 0, i64* %21
%133 = call i64 @utimes(i8* %26, %struct.timeval* %16)
%134 = icmp slt i64 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %128
%136 = call i32 @perror(i8* %26)
br label %137
137: ; preds = %128, %135
br label %138
138: ; preds = %117, %124, %109, %41, %137, %35
br label %139
139: ; preds = %138, %30
%140 = add nuw nsw i64 %24, 1
%141 = icmp eq i64 %140, %22
br i1 %141, label %142, label %23
142: ; preds = %139, %2
%143 = call i32 @exit(i32 0)
unreachable
}