#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;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ in_fsize;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int O_CREAT;
int O_RDONLY;
int O_WRONLY;
int S_IROTH;
int S_IRWXG;
int S_IRWXU;
int S_IXGRP;
int S_IXOTH;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fstat(int, struct stat *);
char *malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, char *, int);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int truncate(char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int in_fd, out_fd, nr;
  struct stat st;
  ssize_t in_fsize, new_size;
  char *buf;
  int in_flags = O_RDONLY;
  int out_flags = O_WRONLY | O_CREAT;
  int out_mode = S_IRWXU | S_IXGRP | S_IRWXG | S_IROTH | S_IXOTH;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <input file><output file>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  in_fd = open(argv[1], in_flags);
  if (in_fd == -1) {
    fprintf(stderr, "Err. open() input failed: %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  out_fd = open(argv[2], out_flags, out_mode);
  if (out_fd == -1) {
    fprintf(stderr, "Err. open() output failed: %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (fstat(in_fd, &st) == -1) {
    fprintf(stderr, "Err. fstat() inpput failed: %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  in_fsize = st.st_size;
  buf = malloc(sizeof(in_fsize));
  if ((nr = read(in_fd, buf, in_fsize)) != -1)
    write(out_fd, buf, in_fsize);
  close(in_fd);
  ((in_fsize % 2) == 0) ? (new_size = in_fsize / 2)
                        : (new_size = (in_fsize - 1) / 2);
  if (truncate(argv[2], new_size) == -1) {
    fprintf(stderr, "Err. truncate() failed: %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (fstat(out_fd, &st) == -1) {
    fprintf(stderr, "Err. fstat() inpput failed: %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("The original size of \'%s\': %d\n", argv[1], in_fsize);
  printf("The size after truncation of \'%s\': %d\n", argv[2], (int)st.st_size);
  close(out_fd);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    0x2e16(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    0x2dc9(%rip),%rcx
or     (%rcx),%eax
mov    0x2dd0(%rip),%rcx
or     (%rcx),%eax
mov    0x2d97(%rip),%rcx
or     (%rcx),%eax
mov    0x2dc6(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     124b <main+0x9b>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc8(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x34(%rbp),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12a4 <main+0xf4>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xd94(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1300 <main+0x150>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xd57(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    134f <main+0x19f>
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xd28(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     138d <main+0x1dd>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13bc <main+0x20c>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
jmp    13cd <main+0x21d>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x28(%rbp),%esi
call   1080 <truncate@plt>
cmp    $0xffffffff,%eax
jne    1420 <main+0x270>
mov    0x2bc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%rdx
lea    0xc78(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    146f <main+0x2bf>
mov    0x2b74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%rdx
lea    0xc08(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x24(%rbp),%edx
lea    0xc21(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x20(%rbp),%edx
lea    0xc29(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    0x2ae4(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    131c <main+0x16c>
mov    0x2db1(%rip),%rax
mov    0x2e22(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
mov    0x2dff(%rip),%rax
mov    0x2dd8(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    0x2ddd(%rip),%rax
or     (%rax),%ebx
mov    0x2da4(%rip),%rax
or     (%rax),%ebx
mov    0x2dd3(%rip),%rax
or     (%rax),%ebx
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
mov    0x8(%r14),%rdi
xor    %eax,%eax
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     1331 <main+0x181>
mov    %eax,%r12d
mov    0x10(%r14),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     1351 <main+0x1a1>
mov    %eax,%r15d
lea    0x8(%rsp),%rsi
mov    %r12d,%edi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
je     12fc <main+0x14c>
mov    0x8(%rsp),%ebp
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %rax,%rsi
mov    %ebp,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1288 <main+0xd8>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
mov    %r12d,%edi
call   1050 <close@plt>
mov    %ebp,%esi
sar    %esi
mov    0x10(%r14),%rdi
call   1080 <truncate@plt>
cmp    $0xffffffff,%eax
je     1371 <main+0x1c1>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
je     12fc <main+0x14c>
mov    0x8(%r14),%rsi
lea    0xddf(%rip),%rdi
mov    %ebp,%edx
call   1040 <printf@plt>
mov    0x10(%r14),%rsi
mov    0x8(%rsp),%edx
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
mov    %r15d,%edi
call   1050 <close@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cad(%rip),%rax
mov    (%rax),%ebx
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd4a(%rip),%rsi
jmp    138f <main+0x1df>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcd1(%rip),%rsi
jmp    1394 <main+0x1e4>
mov    0x2c78(%rip),%rax
mov    (%rax),%ebx
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xcd6(%rip),%rsi
jmp    138f <main+0x1df>
mov    0x2c58(%rip),%rax
mov    (%rax),%ebx
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xcd5(%rip),%rsi
jmp    138f <main+0x1df>
mov    0x2c38(%rip),%rax
mov    (%rax),%ebx
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xcf6(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@S_IXGRP = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Usage: %s <input file><output file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Err. open() input failed: %s.\0A\00"
@errno = global i32 0
@.str.2 = [32 x i8] c"Err. open() output failed: %s.\0A\00"
@.str.3 = [33 x i8] c"Err. fstat() inpput failed: %s.\0A\00"
@.str.4 = [29 x i8] c"Err. truncate() failed: %s.\0A\00"
@.str.5 = [31 x i8] c"The original size of '%s': %d\0A\00"
@.str.6 = [39 x i8] c"The size after truncation of '%s': %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @O_RDONLY
store i32 %16, i32* %13
%17 = load i32, i32* @O_WRONLY
%18 = load i32, i32* @O_CREAT
%19 = or i32 %17, %18
store i32 %19, i32* %14
%20 = load i32, i32* @S_IRWXU
%21 = load i32, i32* @S_IXGRP
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRWXG
%24 = or i32 %22, %23
%25 = load i32, i32* @S_IROTH
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IXOTH
%28 = or i32 %26, %27
store i32 %28, i32* %15
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 3
br i1 %30, label %31, label %39
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %2
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i32, i32* %13
%44 = call i32 (i8*, i32, ...) @open(i8* %42, i32 %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %54
47: ; preds = %39
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %39
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = load i32, i32* %14
%59 = load i32, i32* %15
%60 = call i32 (i8*, i32, ...) @open(i8* %57, i32 %58, i32 %59)
store i32 %60, i32* %7
%61 = load i32, i32* %7
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %70
63: ; preds = %54
%64 = load i32, i32* @stderr
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %54
%71 = load i32, i32* %6
%72 = call i32 @fstat(i32 %71, %struct.stat* %9)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %81
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %70
%82 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%83 = load i32, i32* %82
store i32 %83, i32* %10
%84 = call i8* @malloc(i32 4)
store i8* %84, i8** %12
%85 = load i32, i32* %6
%86 = load i8*, i8** %12
%87 = load i32, i32* %10
%88 = call i32 @read(i32 %85, i8* %86, i32 %87)
store i32 %88, i32* %8
%89 = icmp ne i32 %88, -1
br i1 %89, label %90, label %95
90: ; preds = %81
%91 = load i32, i32* %7
%92 = load i8*, i8** %12
%93 = load i32, i32* %10
%94 = call i32 @write(i32 %91, i8* %92, i32 %93)
br label %95
95: ; preds = %90, %81
%96 = load i32, i32* %6
%97 = call i32 @close(i32 %96)
%98 = load i32, i32* %10
%99 = srem i32 %98, 2
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %95
%102 = load i32, i32* %10
%103 = sdiv i32 %102, 2
store i32 %103, i32* %11
br label %108
104: ; preds = %95
%105 = load i32, i32* %10
%106 = sub nsw i32 %105, 1
%107 = sdiv i32 %106, 2
store i32 %107, i32* %11
br label %108
108: ; preds = %104, %101
%109 = phi i32 [ %103, %101 ], [ %107, %104 ]
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 2
%112 = load i8*, i8** %111
%113 = load i32, i32* %11
%114 = call i32 @truncate(i8* %112, i32 %113)
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %123
116: ; preds = %108
%117 = load i32, i32* @stderr
%118 = load i32, i32* @errno
%119 = call i8* @strerror(i32 %118)
%120 = call i32 @fprintf(i32 %117, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %119)
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %108
%124 = load i32, i32* %7
%125 = call i32 @fstat(i32 %124, %struct.stat* %9)
%126 = icmp eq i32 %125, -1
br i1 %126, label %127, label %134
127: ; preds = %123
%128 = load i32, i32* @stderr
%129 = load i32, i32* @errno
%130 = call i8* @strerror(i32 %129)
%131 = call i32 @fprintf(i32 %128, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %130)
%132 = load i32, i32* @EXIT_FAILURE
%133 = call i32 @exit(i32 %132)
unreachable
134: ; preds = %123
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 1
%137 = load i8*, i8** %136
%138 = load i32, i32* %10
%139 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %137, i32 %138)
%140 = load i8**, i8*** %5
%141 = getelementptr inbounds i8*, i8** %140, i64 2
%142 = load i8*, i8** %141
%143 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%144 = load i32, i32* %143
%145 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %142, i32 %144)
%146 = load i32, i32* %7
%147 = call i32 @close(i32 %146)
%148 = load i32, i32* @EXIT_SUCCESS
ret i32 %148
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@S_IXGRP = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Usage: %s <input file><output file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Err. open() input failed: %s.\0A\00"
@errno = global i32 0
@.str.2 = [32 x i8] c"Err. open() output failed: %s.\0A\00"
@.str.3 = [33 x i8] c"Err. fstat() inpput failed: %s.\0A\00"
@.str.4 = [29 x i8] c"Err. truncate() failed: %s.\0A\00"
@.str.5 = [31 x i8] c"The original size of '%s': %d\0A\00"
@.str.6 = [39 x i8] c"The size after truncation of '%s': %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = load i32, i32* @S_IRWXU
%9 = load i32, i32* @S_IXGRP
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IRWXG
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IROTH
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IXOTH
%16 = or i32 %14, %15
%17 = icmp eq i32 %0, 3
br i1 %17, label %24, label %18
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = load i32, i32* @O_RDONLY
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 (i8*, i32, ...) @open(i8* %27, i32 %25)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %37
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %24
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = load i8*, i8** %38
%40 = tail call i32 (i8*, i32, ...) @open(i8* %39, i32 %7, i32 %16)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = tail call i32 @exit(i32 %47)
unreachable
49: ; preds = %37
%50 = call i32 @fstat(i32 %28, %struct.stat* %3)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = tail call i8* @strerror(i32 %54)
%56 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %49
%60 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%61 = load i32, i32* %60
%62 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%63 = tail call i32 @read(i32 %28, i8* %62, i32 %61)
%64 = icmp eq i32 %63, -1
br i1 %64, label %67, label %65
65: ; preds = %59
%66 = tail call i32 @write(i32 %40, i8* %62, i32 %61)
br label %67
67: ; preds = %65, %59
%68 = tail call i32 @close(i32 %28)
%69 = and i32 %61, -2
%70 = sdiv i32 %69, 2
%71 = load i8*, i8** %38
%72 = tail call i32 @truncate(i8* %71, i32 %70)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %81
74: ; preds = %67
%75 = load i32, i32* @stderr
%76 = load i32, i32* @errno
%77 = tail call i8* @strerror(i32 %76)
%78 = tail call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = tail call i32 @exit(i32 %79)
unreachable
81: ; preds = %67
%82 = call i32 @fstat(i32 %40, %struct.stat* %3)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %91
84: ; preds = %81
%85 = load i32, i32* @stderr
%86 = load i32, i32* @errno
%87 = tail call i8* @strerror(i32 %86)
%88 = tail call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @EXIT_FAILURE
%90 = tail call i32 @exit(i32 %89)
unreachable
91: ; preds = %81
%92 = load i8*, i8** %26
%93 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %92, i32 %61)
%94 = load i8*, i8** %38
%95 = load i32, i32* %60
%96 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %94, i32 %95)
%97 = tail call i32 @close(i32 %40)
%98 = load i32, i32* @EXIT_SUCCESS
ret i32 %98
}