#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 utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct stat {
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ENOMEM;
scalar_t__ chmod(char const *, int /*<<< orphan*/);
scalar_t__ chown(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ err(char *, ...);
int /*<<< orphan*/ errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ getegid();
int /*<<< orphan*/ geteuid();
char *malloc(size_t);
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ utime(char const *, struct utimbuf *);
int install_file(const char ifile[], const char ofile[], mode_t omode) {
  int rc = 0;
  FILE *ifp = NULL;
  FILE *ofp = NULL;
  char *buf = NULL;
  size_t bufsz = 0x4000;
  ifp = fopen(ifile, "rb");
  if (ifp == NULL) {
    err("%s: %s", ifile, strerror(errno));
    rc = 1;
    goto byebye;
  }
  ofp = fopen(ofile, "wb");
  if (ofp == NULL) {
    err("%s: %s", ofile, strerror(errno));
    rc = 1;
    goto byebye;
  }
  buf = malloc(bufsz);
  if (buf == NULL) {
    err(strerror(ENOMEM));
    rc = 1;
    goto byebye;
  }
  {
    size_t nbytes;
    while ((nbytes = fread(buf, 1, bufsz, ifp)) != 0) {
      if (fwrite(buf, 1, nbytes, ofp) != nbytes) {
        err("%s: write error", ofile);
        rc = 1;
        goto byebye;
      }
    }
    if (ferror(ifp)) {
      err("%s: read error", ifile);
      rc = 1;
    }
  }
  if (chown(ofile, geteuid(), getegid()) != 0) {
    err("%s: %s", ofile, strerror(errno));
    rc = 1;
    goto byebye;
  }
  if (chmod(ofile, omode) != 0) {
    err("%s: %s", ofile, strerror(errno));
    rc = 1;
    goto byebye;
  }
  {
    struct stat s;
    struct utimbuf u;
    if (stat(ifile, &s) != 0) {
      err("%s: %s", ifile, strerror(errno));
      rc = 1;
      goto byebye;
    }
    u.actime = s.st_atime;
    u.modtime = s.st_mtime;
    if (utime(ofile, &u) != 0) {
      err("%s: %s", ofile, strerror(errno));
      rc = 1;
      goto byebye;
    }
  }
byebye:
  if (ifp != NULL)
    fclose(ifp);
  if (ofp != NULL)
    if (fclose(ofp) != 0) {
      err("%s: %s", ofile, strerror(errno));
      rc = 1;
    }
  if (buf != NULL)
    free(buf);
  return rc;
}


x86 assembly (clang, -O0):
<install_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x4000,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1282 <install_file+0x92>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
mov    -0x10(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12d7 <install_file+0xe7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
mov    -0x38(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1313 <install_file+0x123>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
movslq %eax,%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
jmp    1318 <install_file+0x128>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fread@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     137f <install_file+0x18f>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
cmp    -0x40(%rbp),%rax
je     137a <install_file+0x18a>
mov    -0x10(%rbp),%rsi
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
jmp    1318 <install_file+0x128>
mov    -0x20(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     13ab <install_file+0x1bb>
mov    -0x8(%rbp),%rsi
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    $0x0,%al
call   1080 <geteuid@plt>
mov    %eax,-0x64(%rbp)
mov    $0x0,%al
call   10c0 <getegid@plt>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    %eax,%edx
call   10d0 <chown@plt>
cmp    $0x0,%rax
je     1412 <install_file+0x222>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10e0 <chmod@plt>
cmp    $0x0,%rax
je     145e <install_file+0x26e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
mov    -0x8(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
je     14b1 <install_file+0x2c1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x2b51(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
lea    0xb65(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <utime@plt>
cmp    $0x0,%rax
je     1510 <install_file+0x320>
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
lea    0xb06(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1515 <install_file+0x325>
jmp    1515 <install_file+0x325>
cmpq   $0x0,-0x20(%rbp)
je     1529 <install_file+0x339>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
cmpq   $0x0,-0x28(%rbp)
je     1583 <install_file+0x393>
mov    -0x28(%rbp),%rdi
call   1070 <fclose@plt>
cmp    $0x0,%rax
je     157e <install_file+0x38e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    0x2a7f(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xa93(%rip),%rdi
mov    $0x0,%al
call   10a0 <err@plt>
movl   $0x1,-0x18(%rbp)
jmp    1583 <install_file+0x393>
cmpq   $0x0,-0x30(%rbp)
je     1597 <install_file+0x3a7>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<install_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0xdf3(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     12af <install_file+0xbf>
mov    %rax,%r15
lea    0xde5(%rip),%rsi
mov    %r14,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     12da <install_file+0xea>
mov    %rax,%r12
mov    $0x4000,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     130d <install_file+0x11d>
mov    %rax,%rbx
mov    %ebp,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x4000,%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1060 <fread@plt>
test   %rax,%rax
je     1329 <install_file+0x139>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r12,%rcx
call   1100 <fwrite@plt>
cmp    %rbp,%rax
je     1260 <install_file+0x70>
lea    0xd6d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <err@plt>
jmp    13a5 <install_file+0x1b5>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd3f(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <err@plt>
mov    $0x1,%ebp
jmp    13f2 <install_file+0x202>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd14(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <err@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0x1,%ebp
jmp    13f2 <install_file+0x202>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
movslq %eax,%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <err@plt>
jmp    13a5 <install_file+0x1b5>
mov    %r15,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     134e <install_file+0x15e>
lea    0xce0(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <err@plt>
mov    $0x1,%ebp
jmp    1350 <install_file+0x160>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <geteuid@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   10c0 <getegid@plt>
mov    %r14,%rdi
mov    (%rsp),%esi
mov    %eax,%edx
call   10d0 <chown@plt>
test   %rax,%rax
jne    1384 <install_file+0x194>
mov    %r14,%rdi
mov    0x4(%rsp),%esi
call   10e0 <chmod@plt>
test   %rax,%rax
je     1403 <install_file+0x213>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc6a(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <err@plt>
mov    $0x1,%ebp
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r12,%rdi
call   1070 <fclose@plt>
test   %rax,%rax
je     13e5 <install_file+0x1f5>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc2f(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <err@plt>
mov    $0x1,%ebp
test   %rbx,%rbx
je     13f2 <install_file+0x202>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   1090 <stat@plt>
test   %rax,%rax
jne    1438 <install_file+0x248>
mov    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <utime@plt>
mov    %r14,%r13
test   %rax,%rax
je     13aa <install_file+0x1ba>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xbb6(%rip),%rdi
mov    %r13,%rsi
jmp    139c <install_file+0x1ac>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
@.str = [3 x i8] c"rb\00"
@.str.1 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
@.str.2 = [3 x i8] c"wb\00"
@ENOMEM = global i32 0
@.str.3 = [16 x i8] c"%s: write error\00"
@.str.4 = [15 x i8] c"%s: read error\00"
define i32 @install_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca %struct.stat
%14 = alloca %struct.utimbuf
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32* null, i32** %8
store i32* null, i32** %9
store i8* null, i8** %10
store i64 16384, i64* %11
%15 = load i8*, i8** %4
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %22)
store i32 1, i32* %7
br label %116
24: ; preds = %3
%25 = load i8*, i8** %5
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %9
%27 = load i32*, i32** %9
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = load i32, i32* @errno
%32 = call i32 @strerror(i32 %31)
%33 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %30, i32 %32)
store i32 1, i32* %7
br label %116
34: ; preds = %24
%35 = load i64, i64* %11
%36 = call i8* @malloc(i64 %35)
store i8* %36, i8** %10
%37 = load i8*, i8** %10
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = load i32, i32* @ENOMEM
%41 = call i32 @strerror(i32 %40)
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i8*
%44 = call i32 (i8*, ...) @err(i8* %43)
store i32 1, i32* %7
br label %116
45: ; preds = %34
br label %46
46: ; preds = %62, %45
%47 = load i8*, i8** %10
%48 = load i64, i64* %11
%49 = load i32*, i32** %8
%50 = call i64 @fread(i8* %47, i32 1, i64 %48, i32* %49)
store i64 %50, i64* %12
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %63
52: ; preds = %46
%53 = load i8*, i8** %10
%54 = load i64, i64* %12
%55 = load i32*, i32** %9
%56 = call i64 @fwrite(i8* %53, i32 1, i64 %54, i32* %55)
%57 = load i64, i64* %12
%58 = icmp ne i64 %56, %57
br i1 %58, label %59, label %62
59: ; preds = %52
%60 = load i8*, i8** %5
%61 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %60)
store i32 1, i32* %7
br label %116
62: ; preds = %52
br label %46
63: ; preds = %46
%64 = load i32*, i32** %8
%65 = call i64 @ferror(i32* %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i8*, i8** %4
%69 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %68)
store i32 1, i32* %7
br label %70
70: ; preds = %67, %63
%71 = load i8*, i8** %5
%72 = call i32 (...) @geteuid()
%73 = call i32 (...) @getegid()
%74 = call i64 @chown(i8* %71, i32 %72, i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %70
%77 = load i8*, i8** %5
%78 = load i32, i32* @errno
%79 = call i32 @strerror(i32 %78)
%80 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %77, i32 %79)
store i32 1, i32* %7
br label %116
81: ; preds = %70
%82 = load i8*, i8** %5
%83 = load i32, i32* %6
%84 = call i64 @chmod(i8* %82, i32 %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = load i8*, i8** %5
%88 = load i32, i32* @errno
%89 = call i32 @strerror(i32 %88)
%90 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %87, i32 %89)
store i32 1, i32* %7
br label %116
91: ; preds = %81
%92 = load i8*, i8** %4
%93 = call i64 @stat(i8* %92, %struct.stat* %13)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %91
%96 = load i8*, i8** %4
%97 = load i32, i32* @errno
%98 = call i32 @strerror(i32 %97)
%99 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %96, i32 %98)
store i32 1, i32* %7
br label %116
100: ; preds = %91
%101 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 1
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %14, i32 0, i32 1
store i32 %102, i32* %103
%104 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 0
%105 = load i32, i32* %104
%106 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %14, i32 0, i32 0
store i32 %105, i32* %106
%107 = load i8*, i8** %5
%108 = call i64 @utime(i8* %107, %struct.utimbuf* %14)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %100
%111 = load i8*, i8** %5
%112 = load i32, i32* @errno
%113 = call i32 @strerror(i32 %112)
%114 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %111, i32 %113)
store i32 1, i32* %7
br label %116
115: ; preds = %100
br label %116
116: ; preds = %115, %110, %95, %86, %76, %59, %39, %29, %19
%117 = load i32*, i32** %8
%118 = icmp ne i32* %117, null
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load i32*, i32** %8
%121 = call i64 @fclose(i32* %120)
br label %122
122: ; preds = %119, %116
%123 = load i32*, i32** %9
%124 = icmp ne i32* %123, null
br i1 %124, label %125, label %135
125: ; preds = %122
%126 = load i32*, i32** %9
%127 = call i64 @fclose(i32* %126)
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %125
%130 = load i8*, i8** %5
%131 = load i32, i32* @errno
%132 = call i32 @strerror(i32 %131)
%133 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %130, i32 %132)
store i32 1, i32* %7
br label %134
134: ; preds = %129, %125
br label %135
135: ; preds = %134, %122
%136 = load i8*, i8** %10
%137 = icmp ne i8* %136, null
br i1 %137, label %138, label %141
138: ; preds = %135
%139 = load i8*, i8** %10
%140 = call i32 @free(i8* %139)
br label %141
141: ; preds = %138, %135
%142 = load i32, i32* %7
ret i32 %142
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
@.str = [3 x i8] c"rb\00"
@.str.1 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
@.str.2 = [3 x i8] c"wb\00"
@ENOMEM = global i32 0
@.str.3 = [16 x i8] c"%s: write error\00"
@.str.4 = [15 x i8] c"%s: read error\00"
define i32 @install_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca %struct.stat
%5 = alloca %struct.utimbuf
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %10)
br label %95
12: ; preds = %3
%13 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = tail call i32 @strerror(i32 %16)
%18 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %17)
%19 = call i64 @fclose(i32* %6)
br label %95
20: ; preds = %12
%21 = tail call dereferenceable_or_null(16384) i8* @malloc(i64 16384)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* @ENOMEM
%25 = tail call i32 @strerror(i32 %24)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8*
%28 = tail call i32 (i8*, ...) @err(i8* %27)
br label %80
29: ; preds = %20, %32
%30 = tail call i64 @fread(i8* %21, i32 1, i64 16384, i32* %6)
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = tail call i64 @fwrite(i8* %21, i32 1, i64 %30, i32* %13)
%34 = icmp eq i64 %33, %30
br i1 %34, label %29, label %40
35: ; preds = %29
%36 = tail call i64 @ferror(i32* %6)
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %42
40: ; preds = %32
%41 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %80
42: ; preds = %38, %35
%43 = phi i32 [ 0, %35 ], [ 1, %38 ]
%44 = tail call i32 (...) @geteuid()
%45 = tail call i32 (...) @getegid()
%46 = tail call i64 @chown(i8* %1, i32 %44, i32 %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %42
%49 = load i32, i32* @errno
%50 = tail call i32 @strerror(i32 %49)
%51 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %50)
br label %80
52: ; preds = %42
%53 = tail call i64 @chmod(i8* %1, i32 %2)
%54 = icmp eq i64 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %52
%56 = load i32, i32* @errno
%57 = tail call i32 @strerror(i32 %56)
%58 = tail call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %57)
br label %80
59: ; preds = %52
%60 = bitcast %struct.stat* %4 to i8*
%61 = bitcast %struct.utimbuf* %5 to i8*
%62 = call i64 @stat(i8* %0, %struct.stat* %4)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %59
%65 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%66 = load i32, i32* %65
%67 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 1
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 0
store i32 %69, i32* %70
%71 = call i64 @utime(i8* %1, %struct.utimbuf* %5)
%72 = icmp eq i64 %71, 0
br i1 %72, label %78, label %73
73: ; preds = %64, %59
%74 = phi i8* [ %0, %59 ], [ %1, %64 ]
%75 = load i32, i32* @errno
%76 = call i32 @strerror(i32 %75)
%77 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %74, i32 %76)
br label %78
78: ; preds = %73, %64
%79 = phi i32 [ %43, %64 ], [ 1, %73 ]
br label %80
80: ; preds = %48, %55, %78, %40, %23
%81 = phi i8* [ null, %23 ], [ %21, %40 ], [ %21, %78 ], [ %21, %55 ], [ %21, %48 ]
%82 = phi i32 [ 1, %23 ], [ 1, %40 ], [ %79, %78 ], [ 1, %55 ], [ 1, %48 ]
%83 = call i64 @fclose(i32* %6)
%84 = call i64 @fclose(i32* %13)
%85 = icmp eq i64 %84, 0
br i1 %85, label %90, label %86
86: ; preds = %80
%87 = load i32, i32* @errno
%88 = call i32 @strerror(i32 %87)
%89 = call i32 (i8*, ...) @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %88)
br label %90
90: ; preds = %80, %86
%91 = phi i32 [ 1, %86 ], [ %82, %80 ]
%92 = icmp eq i8* %81, null
br i1 %92, label %95, label %93
93: ; preds = %90
%94 = call i32 @free(i8* %81)
br label %95
95: ; preds = %15, %8, %90, %93
%96 = phi i32 [ 1, %8 ], [ %91, %90 ], [ %91, %93 ], [ 1, %15 ]
ret i32 %96
}