#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 /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
};
typedef scalar_t__ ssize_t;

/* Variables and functions */
int EXIT_SUCCESS;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fchmod(int, int /*<<< orphan*/);
int /*<<< orphan*/ fchown(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
scalar_t__ fstat(int, struct stat *);
int open(char const *, int, ...);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strerror(int /*<<< orphan*/);
scalar_t__ unlink(char const *);
scalar_t__ write(int, char *, scalar_t__);
int main(int argc, const char **argv) {
  ++argv;
  for (; --argc > 0 && *argv != NULL; ++argv) {
    struct stat sb;
    ssize_t ret;
    char buffer[4096];
    int in, out;
    if ((in = open(*argv, O_RDONLY)) < 0) {
      fprintf(stderr, "Could not open %s: %s\n", *argv, strerror(errno));
      continue;
    }
    if (fstat(in, &sb) < 0) {
      fprintf(stderr, "Could not stat %s: %s\n", *argv, strerror(errno));
      continue;
    }
    if (unlink(*argv) < 0) {
      fprintf(stderr, "Could not unlink %s: %s\n", *argv, strerror(errno));
      continue;
    }
    if ((out = open(*argv, O_WRONLY | O_TRUNC | O_CREAT, sb.st_mode)) < 0) {
      fprintf(stderr, "Could not recreate/open file %s: %s\n", *argv,
              strerror(errno));
      fgets(buffer, 4, stdin);
      continue;
    }
    printf("* %s\n", *argv);
    fchown(out, sb.st_uid, sb.st_gid);
    fchmod(out, sb.st_mode);
    while ((ret = read(in, buffer, 4096)) > 0)
      if (write(out, buffer, ret) < 0) {
        fprintf(stderr,
                "Error during write() to %s: "
                "%s\n",
                *argv, strerror(errno));
        break;
      }
    if (ret < 0)
      fprintf(stderr, "Error during read() on %s: %s\n", *argv,
              strerror(errno));
    close(in);
    close(out);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1039(%rbp)
jle    1210 <main+0x50>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x1039(%rbp)
mov    -0x1039(%rbp),%al
test   $0x1,%al
jne    1223 <main+0x63>
jmp    153e <main+0x37e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2da7(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1034(%rbp)
cmp    $0x0,%eax
jge    1295 <main+0xd5>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1048(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x104c(%rbp),%edi
mov    -0x1048(%rbp),%rdx
mov    %rax,%rcx
lea    0xd75(%rip),%rsi
call   1090 <fprintf@plt>
jmp    152d <main+0x36d>
mov    -0x1034(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   10e0 <fstat@plt>
cmp    $0x0,%rax
jge    12fa <main+0x13a>
mov    0x2d0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x105c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1058(%rbp)
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x105c(%rbp),%edi
mov    -0x1058(%rbp),%rdx
mov    %rax,%rcx
lea    0xd27(%rip),%rsi
call   1090 <fprintf@plt>
jmp    152d <main+0x36d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    135c <main+0x19c>
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x106c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1068(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x106c(%rbp),%edi
mov    -0x1068(%rbp),%rdx
mov    %rax,%rcx
lea    0xcdc(%rip),%rsi
call   1090 <fprintf@plt>
jmp    152d <main+0x36d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
mov    0x2c7d(%rip),%rax
or     (%rax),%esi
mov    0x2c7c(%rip),%rax
or     (%rax),%esi
mov    -0x20(%rbp),%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1038(%rbp)
cmp    $0x0,%eax
jge    13fd <main+0x23d>
mov    0x2c22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x107c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1078(%rbp)
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x107c(%rbp),%edi
mov    -0x1078(%rbp),%rdx
mov    %rax,%rcx
lea    0xc6e(%rip),%rsi
call   1090 <fprintf@plt>
lea    -0x1030(%rbp),%rdi
mov    0x2be4(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1080 <fgets@plt>
jmp    152d <main+0x36d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xc61(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1038(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10c0 <fchown@plt>
mov    -0x1038(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10a0 <fchmod@plt>
mov    -0x1034(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jle    14c5 <main+0x305>
mov    -0x1038(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    14c0 <main+0x300>
mov    0x2b45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x108c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1088(%rbp)
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x108c(%rbp),%edi
mov    -0x1088(%rbp),%rdx
mov    %rax,%rcx
lea    0xbbc(%rip),%rsi
call   1090 <fprintf@plt>
jmp    14c5 <main+0x305>
jmp    142f <main+0x26f>
cmpq   $0x0,-0x28(%rbp)
jge    1517 <main+0x357>
mov    0x2ae9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x109c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1098(%rbp)
mov    0x2ac4(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x109c(%rbp),%edi
mov    -0x1098(%rbp),%rdx
mov    %rax,%rcx
lea    0xb80(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x1034(%rbp),%edi
call   1060 <close@plt>
mov    -0x1038(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e5 <main+0x25>
mov    0x2a6b(%rip),%rax
mov    (%rax),%eax
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
cmp    $0x2,%edi
jl     141b <main+0x25b>
mov    %rsi,%r14
mov    %edi,%r12d
mov    0x2df1(%rip),%r15
lea    0x20(%rsp),%rbp
jmp    1235 <main+0x75>
xchg   %ax,%ax
mov    0x2dc9(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%rbx
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %ebp,%edi
lea    0x20(%rsp),%rbp
lea    0xde8(%rip),%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    -0x1(%r12),%eax
cmp    $0x2,%r12d
mov    %eax,%r12d
jle    141b <main+0x25b>
mov    0x8(%r14),%rdi
test   %rdi,%rdi
je     141b <main+0x25b>
add    $0x8,%r14
mov    (%r15),%esi
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     11f0 <main+0x30>
mov    %eax,%r13d
mov    %eax,%edi
lea    0x8(%rsp),%rsi
call   10e0 <fstat@plt>
test   %rax,%rax
js     1320 <main+0x160>
mov    (%r14),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
js     1345 <main+0x185>
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
mov    0x2d13(%rip),%rax
or     (%rax),%esi
mov    (%r14),%rdi
mov    0x2d5f(%rip),%rax
or     (%rax),%esi
mov    0x8(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1375 <main+0x1b5>
mov    %eax,%r15d
mov    (%r14),%rsi
lea    0xdaf(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%esi
mov    %r15d,%edi
call   10c0 <fchown@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   10a0 <fchmod@plt>
nopl   0x0(%rax)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
test   %rax,%rax
jle    13c0 <main+0x200>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
test   %rax,%rax
jns    12e0 <main+0x120>
lea    0xd5f(%rip),%rbx
jmp    13c9 <main+0x209>
nopl   0x0(%rax,%rax,1)
mov    0x2c99(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %ebx,%edi
lea    0xcd4(%rip),%rsi
jmp    1368 <main+0x1a8>
mov    0x2c74(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %ebx,%edi
lea    0xcc6(%rip),%rsi
mov    %rbp,%rdx
lea    0x20(%rsp),%rbp
jmp    121b <main+0x5b>
mov    0x2c44(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %ebx,%edi
lea    0xcaf(%rip),%rsi
mov    %rbp,%rdx
lea    0x20(%rsp),%rbp
mov    %rax,%rcx
call   1090 <fprintf@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x4,%esi
call   1080 <fgets@plt>
jmp    140f <main+0x24f>
lea    0xccb(%rip),%rbx
jns    13ff <main+0x23f>
mov    0x2bf0(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %ebp,%edi
lea    0x20(%rsp),%rbp
mov    %rbx,%rsi
mov    0x18(%rsp),%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
mov    %r13d,%edi
call   1060 <close@plt>
mov    %r15d,%edi
call   1060 <close@plt>
mov    0x2bc2(%rip),%r15
jmp    1223 <main+0x63>
mov    0x2b8e(%rip),%rax
mov    (%rax),%eax
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"Could not open %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [23 x i8] c"Could not stat %s: %s\0A\00"
@.str.2 = [25 x i8] c"Could not unlink %s: %s\0A\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.3 = [37 x i8] c"Could not recreate/open file %s: %s\0A\00"
@stdin = global i32 0
@.str.4 = [6 x i8] c"* %s\0A\00"
@.str.5 = [32 x i8] c"Error during write() to %s: %s\0A\00"
@.str.6 = [31 x i8] c"Error during read() on %s: %s\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 %struct.stat
%7 = alloca i64
%8 = alloca [4096 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %5
br label %13
13: ; preds = %129, %2
%14 = load i32, i32* %4
%15 = add nsw i32 %14, -1
store i32 %15, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br label %21
21: ; preds = %17, %13
%22 = phi i1 [ false, %13 ], [ %20, %17 ]
br i1 %22, label %23, label %132
23: ; preds = %21
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = call i32 (i8*, i32, ...) @open(i8* %25, i32 %26)
store i32 %27, i32* %9
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %34)
br label %129
36: ; preds = %23
%37 = load i32, i32* %9
%38 = call i64 @fstat(i32 %37, %struct.stat* %6)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = load i8*, i8** %42
%44 = load i32, i32* @errno
%45 = call i8* @strerror(i32 %44)
%46 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %43, i8* %45)
br label %129
47: ; preds = %36
%48 = load i8**, i8*** %5
%49 = load i8*, i8** %48
%50 = call i64 @unlink(i8* %49)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = load i8**, i8*** %5
%55 = load i8*, i8** %54
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %55, i8* %57)
br label %129
59: ; preds = %47
%60 = load i8**, i8*** %5
%61 = load i8*, i8** %60
%62 = load i32, i32* @O_WRONLY
%63 = load i32, i32* @O_TRUNC
%64 = or i32 %62, %63
%65 = load i32, i32* @O_CREAT
%66 = or i32 %64, %65
%67 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%68 = load i32, i32* %67
%69 = call i32 (i8*, i32, ...) @open(i8* %61, i32 %66, i32 %68)
store i32 %69, i32* %10
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %81
71: ; preds = %59
%72 = load i32, i32* @stderr
%73 = load i8**, i8*** %5
%74 = load i8*, i8** %73
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %74, i8* %76)
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%79 = load i32, i32* @stdin
%80 = call i32 @fgets(i8* %78, i32 4, i32 %79)
br label %129
81: ; preds = %59
%82 = load i8**, i8*** %5
%83 = load i8*, i8** %82
%84 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %10
%86 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%87 = load i32, i32* %86
%88 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%89 = load i32, i32* %88
%90 = call i32 @fchown(i32 %85, i32 %87, i32 %89)
%91 = load i32, i32* %10
%92 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%93 = load i32, i32* %92
%94 = call i32 @fchmod(i32 %91, i32 %93)
br label %95
95: ; preds = %113, %81
%96 = load i32, i32* %9
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%98 = call i64 @read(i32 %96, i8* %97, i32 4096)
store i64 %98, i64* %7
%99 = icmp sgt i64 %98, 0
br i1 %99, label %100, label %114
100: ; preds = %95
%101 = load i32, i32* %10
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%103 = load i64, i64* %7
%104 = call i64 @write(i32 %101, i8* %102, i64 %103)
%105 = icmp slt i64 %104, 0
br i1 %105, label %106, label %113
106: ; preds = %100
%107 = load i32, i32* @stderr
%108 = load i8**, i8*** %5
%109 = load i8*, i8** %108
%110 = load i32, i32* @errno
%111 = call i8* @strerror(i32 %110)
%112 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %109, i8* %111)
br label %114
113: ; preds = %100
br label %95
114: ; preds = %106, %95
%115 = load i64, i64* %7
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %124
117: ; preds = %114
%118 = load i32, i32* @stderr
%119 = load i8**, i8*** %5
%120 = load i8*, i8** %119
%121 = load i32, i32* @errno
%122 = call i8* @strerror(i32 %121)
%123 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %120, i8* %122)
br label %124
124: ; preds = %117, %114
%125 = load i32, i32* %9
%126 = call i32 @close(i32 %125)
%127 = load i32, i32* %10
%128 = call i32 @close(i32 %127)
br label %129
129: ; preds = %124, %71, %52, %40, %29
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i32 1
store i8** %131, i8*** %5
br label %13
132: ; preds = %21
%133 = load i32, i32* @EXIT_SUCCESS
ret i32 %133
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"Could not open %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [23 x i8] c"Could not stat %s: %s\0A\00"
@.str.2 = [25 x i8] c"Could not unlink %s: %s\0A\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.3 = [37 x i8] c"Could not recreate/open file %s: %s\0A\00"
@stdin = global i32 0
@.str.4 = [6 x i8] c"* %s\0A\00"
@.str.5 = [32 x i8] c"Error during write() to %s: %s\0A\00"
@.str.6 = [31 x i8] c"Error during read() on %s: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [4096 x i8]
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %93
6: ; preds = %2
%7 = bitcast %struct.stat* %3 to i8*
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%10 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%11 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
br label %12
12: ; preds = %6, %91
%13 = phi i32 [ %0, %6 ], [ %16, %91 ]
%14 = phi i8** [ %1, %6 ], [ %15, %91 ]
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = add nsw i32 %13, -1
%17 = load i8*, i8** %15
%18 = icmp eq i8* %17, null
br i1 %18, label %93, label %19
19: ; preds = %12
%20 = load i32, i32* @O_RDONLY
%21 = call i32 (i8*, i32, ...) @open(i8* %17, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %15
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %27)
br label %91
29: ; preds = %19
%30 = call i64 @fstat(i32 %21, %struct.stat* %3)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %15
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %36)
br label %91
38: ; preds = %29
%39 = load i8*, i8** %15
%40 = call i64 @unlink(i8* %39)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %15
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %46)
br label %91
48: ; preds = %38
%49 = load i8*, i8** %15
%50 = load i32, i32* @O_WRONLY
%51 = load i32, i32* @O_TRUNC
%52 = or i32 %51, %50
%53 = load i32, i32* @O_CREAT
%54 = or i32 %52, %53
%55 = load i32, i32* %9
%56 = call i32 (i8*, i32, ...) @open(i8* %49, i32 %54, i32 %55)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %66
58: ; preds = %48
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %15
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %60, i8* %62)
%64 = load i32, i32* @stdin
%65 = call i32 @fgets(i8* %8, i32 4, i32 %64)
br label %91
66: ; preds = %48
%67 = load i8*, i8** %15
%68 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %67)
%69 = load i32, i32* %10
%70 = load i32, i32* %11
%71 = call i32 @fchown(i32 %56, i32 %69, i32 %70)
%72 = call i32 @fchmod(i32 %56, i32 %55)
br label %73
73: ; preds = %76, %66
%74 = call i64 @read(i32 %21, i8* %8, i32 4096)
%75 = icmp sgt i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = call i64 @write(i32 %56, i8* %8, i64 %74)
%78 = icmp slt i64 %77, 0
br i1 %78, label %81, label %73
79: ; preds = %73
%80 = icmp slt i64 %74, 0
br i1 %80, label %81, label %88
81: ; preds = %76, %79
%82 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), %79 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), %76 ]
%83 = load i32, i32* @stderr
%84 = load i8*, i8** %15
%85 = load i32, i32* @errno
%86 = call i8* @strerror(i32 %85)
%87 = call i32 @fprintf(i32 %83, i8* %82, i8* %84, i8* %86)
br label %88
88: ; preds = %81, %79
%89 = call i32 @close(i32 %21)
%90 = call i32 @close(i32 %56)
br label %91
91: ; preds = %88, %58, %42, %32, %23
%92 = icmp sgt i32 %13, 2
br i1 %92, label %12, label %93
93: ; preds = %12, %91, %2
%94 = load i32, i32* @EXIT_SUCCESS
ret i32 %94
}