#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;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int close(int);
int creat(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ oops(char *, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *strndup(char *, int);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s source destination\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int src_fd = open(argv[1], O_RDONLY);
  if (src_fd == -1) {
    oops("Can not open", argv[1]);
  }
  struct stat stat_buf;
  if (stat(argv[2], &stat_buf) == -1) {
    oops("Failed to read stat", argv[2]);
  }
  if (S_ISDIR(stat_buf.st_mode)) {
    int src_len = strlen(argv[1]);
    int dst_len = strlen(argv[2]);
    if (argv[2][dst_len - 1] != '/') {
      argv[2] = strndup(argv[2], dst_len + 1 + src_len);
      strcat(argv[2], "/");
    } else {
      argv[2] = strndup(argv[2], dst_len + src_len);
    }
    strcat(argv[2], argv[1]);
  }
  printf("argv[2]: %s\n", argv[2]);
  int dst_fd = creat(argv[2], 0644);
  if (dst_fd == -1) {
    oops("Can not create", argv[2]);
  }
  char buf[4096];
  int buf_size;
  while ((buf_size = read(src_fd, buf, 4096)) > 0)
    if (write(dst_fd, buf, buf_size) != buf_size)
      oops("Failed to create", argv[2]);
  if (buf_size == -1)
    oops("Failed to read", argv[1]);
  if (close(src_fd) == -1 || close(dst_fd) == -1)
    oops("Faile to close files.", "");
  free(argv[2]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     123d <main+0x4d>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd6(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1274 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdaf(%rip),%rdi
call   1050 <oops@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0xffffffff,%eax
jne    12a2 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd8e(%rip),%rdi
call   1050 <oops@plt>
mov    -0x18(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     135f <main+0x16f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     132c <main+0x13c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x20(%rbp),%esi
add    $0x1,%esi
add    -0x1c(%rbp),%esi
call   10b0 <strndup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd1d(%rip),%rsi
call   10f0 <strcat@plt>
jmp    134a <main+0x15a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x20(%rbp),%esi
add    -0x1c(%rbp),%esi
call   10b0 <strndup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10f0 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xcd3(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x1a4,%esi
call   1100 <creat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    13a6 <main+0x1b6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xcad(%rip),%rdi
call   1050 <oops@plt>
jmp    13ab <main+0x1bb>
mov    -0x14(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,-0x1034(%rbp)
cmp    $0x0,%eax
jle    1408 <main+0x218>
mov    -0x24(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    -0x1034(%rbp),%edx
call   1040 <write@plt>
cmp    -0x1034(%rbp),%eax
je     1403 <main+0x213>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xc5f(%rip),%rdi
call   1050 <oops@plt>
jmp    13ab <main+0x1bb>
cmpl   $0xffffffff,-0x1034(%rbp)
jne    1429 <main+0x239>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xc4a(%rip),%rdi
call   1050 <oops@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
je     144b <main+0x25b>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    145e <main+0x26e>
lea    0xc2b(%rip),%rdi
lea    0xbc4(%rip),%rsi
call   1050 <oops@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    0x2b56(%rip),%rax
mov    (%rax),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    13cb <main+0x1db>
mov    0x8(%r14),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1237 <main+0x47>
mov    0x8(%r14),%rsi
lea    0xdec(%rip),%rdi
call   1050 <oops@plt>
mov    0x10(%r14),%rdi
lea    0x8(%rsp),%rsi
call   10d0 <stat@plt>
cmp    $0xffffffff,%eax
jne    125a <main+0x6a>
mov    0x10(%r14),%rsi
lea    0xdd6(%rip),%rdi
call   1050 <oops@plt>
mov    0x8(%rsp),%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     12c5 <main+0xd5>
mov    0x8(%r14),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    0x10(%r14),%rdi
call   1060 <strlen@plt>
mov    0x10(%r14),%rdi
cltq
add    %eax,%ebx
cmpb   $0x2f,-0x1(%rax,%rdi,1)
jne    129b <main+0xab>
mov    %ebx,%esi
call   10b0 <strndup@plt>
mov    %rax,%rdi
mov    %rax,0x10(%r14)
jmp    12bc <main+0xcc>
add    $0x1,%ebx
mov    %ebx,%esi
call   10b0 <strndup@plt>
mov    %rax,0x10(%r14)
lea    0xd8f(%rip),%rsi
mov    %rax,%rdi
call   10f0 <strcat@plt>
mov    0x10(%r14),%rdi
mov    0x8(%r14),%rsi
call   10f0 <strcat@plt>
mov    0x10(%r14),%rsi
lea    0xd71(%rip),%rdi
call   1070 <printf@plt>
mov    0x10(%r14),%rdi
mov    $0x1a4,%esi
call   1100 <creat@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
jne    12fb <main+0x10b>
mov    0x10(%r14),%rsi
lea    0xd58(%rip),%rdi
call   1050 <oops@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1365 <main+0x175>
lea    0x10(%rsp),%rbp
lea    0xd3e(%rip),%r12
jmp    1346 <main+0x156>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1365 <main+0x175>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
je     1330 <main+0x140>
mov    0x10(%r14),%rsi
mov    %r12,%rdi
call   1050 <oops@plt>
jmp    1330 <main+0x140>
cmp    $0xffffffff,%ebx
jne    137a <main+0x18a>
mov    0x8(%r14),%rsi
lea    0xcf9(%rip),%rdi
call   1050 <oops@plt>
mov    %r15d,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
je     1394 <main+0x1a4>
mov    %r13d,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    13a7 <main+0x1b7>
lea    0xce2(%rip),%rdi
lea    0xc7b(%rip),%rsi
call   1050 <oops@plt>
mov    0x10(%r14),%rdi
call   1030 <free@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc22(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source destination\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [13 x i8] c"Can not open\00"
@.str.2 = [20 x i8] c"Failed to read stat\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [13 x i8] c"argv[2]: %s\0A\00"
@.str.5 = [15 x i8] c"Can not create\00"
@.str.6 = [17 x i8] c"Failed to create\00"
@.str.7 = [15 x i8] c"Failed to read\00"
@.str.8 = [22 x i8] c"Faile to close files.\00"
@.str.9 = [1 x i8] zeroinitializer
@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 %struct.stat
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @oops(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %23
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @stat(i8* %39, %struct.stat* %7)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %47
42: ; preds = %36
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @oops(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %42, %36
%48 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i64 @S_ISDIR(i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %104
52: ; preds = %47
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 @strlen(i8* %55)
store i32 %56, i32* %8
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
store i32 %60, i32* %9
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = load i32, i32* %9
%65 = sub nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %63, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 47
br i1 %70, label %71, label %86
71: ; preds = %52
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
%77 = load i32, i32* %8
%78 = add nsw i32 %76, %77
%79 = call i8* @strndup(i8* %74, i32 %78)
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 2
store i8* %79, i8** %81
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = call i32 @strcat(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %96
86: ; preds = %52
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 2
%89 = load i8*, i8** %88
%90 = load i32, i32* %9
%91 = load i32, i32* %8
%92 = add nsw i32 %90, %91
%93 = call i8* @strndup(i8* %89, i32 %92)
%94 = load i8**, i8*** %5
%95 = getelementptr inbounds i8*, i8** %94, i64 2
store i8* %93, i8** %95
br label %96
96: ; preds = %86, %71
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 2
%99 = load i8*, i8** %98
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = call i32 @strcat(i8* %99, i8* %102)
br label %104
104: ; preds = %96, %47
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 2
%107 = load i8*, i8** %106
%108 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %107)
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 2
%111 = load i8*, i8** %110
%112 = call i32 @creat(i8* %111, i32 420)
store i32 %112, i32* %10
%113 = load i32, i32* %10
%114 = icmp eq i32 %113, -1
br i1 %114, label %115, label %120
115: ; preds = %104
%116 = load i8**, i8*** %5
%117 = getelementptr inbounds i8*, i8** %116, i64 2
%118 = load i8*, i8** %117
%119 = call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %118)
br label %120
120: ; preds = %115, %104
br label %121
121: ; preds = %138, %120
%122 = load i32, i32* %6
%123 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%124 = call i32 @read(i32 %122, i8* %123, i32 4096)
store i32 %124, i32* %12
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %139
126: ; preds = %121
%127 = load i32, i32* %10
%128 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%129 = load i32, i32* %12
%130 = call i32 @write(i32 %127, i8* %128, i32 %129)
%131 = load i32, i32* %12
%132 = icmp ne i32 %130, %131
br i1 %132, label %133, label %138
133: ; preds = %126
%134 = load i8**, i8*** %5
%135 = getelementptr inbounds i8*, i8** %134, i64 2
%136 = load i8*, i8** %135
%137 = call i32 @oops(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %136)
br label %138
138: ; preds = %133, %126
br label %121
139: ; preds = %121
%140 = load i32, i32* %12
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %147
142: ; preds = %139
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 1
%145 = load i8*, i8** %144
%146 = call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %145)
br label %147
147: ; preds = %142, %139
%148 = load i32, i32* %6
%149 = call i32 @close(i32 %148)
%150 = icmp eq i32 %149, -1
br i1 %150, label %155, label %151
151: ; preds = %147
%152 = load i32, i32* %10
%153 = call i32 @close(i32 %152)
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %157
155: ; preds = %151, %147
%156 = call i32 @oops(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %157
157: ; preds = %155, %151
%158 = load i8**, i8*** %5
%159 = getelementptr inbounds i8*, i8** %158, i64 2
%160 = load i8*, i8** %159
%161 = call i32 @free(i8* %160)
%162 = load i32, i32* @EXIT_SUCCESS
ret i32 %162
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source destination\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [13 x i8] c"Can not open\00"
@.str.2 = [20 x i8] c"Failed to read stat\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [13 x i8] c"argv[2]: %s\0A\00"
@.str.5 = [15 x i8] c"Can not create\00"
@.str.6 = [17 x i8] c"Failed to create\00"
@.str.7 = [15 x i8] c"Failed to read\00"
@.str.8 = [22 x i8] c"Faile to close files.\00"
@.str.9 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [4096 x i8]
%5 = icmp eq i32 %0, 3
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 @open(i8* %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %13
%20 = tail call i32 @oops(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %12
%22 = bitcast %struct.stat* %3 to i8*
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @stat(i8* %24, %struct.stat* %3)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i8*, i8** %23
%29 = tail call i32 @oops(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %21
%31 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i64 @S_ISDIR(i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %58, label %35
35: ; preds = %30
%36 = load i8*, i8** %13
%37 = tail call i32 @strlen(i8* %36)
%38 = load i8*, i8** %23
%39 = tail call i32 @strlen(i8* %38)
%40 = load i8*, i8** %23
%41 = add nsw i32 %39, -1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 47
%46 = add i32 %39, %37
br i1 %45, label %52, label %47
47: ; preds = %35
%48 = add i32 %46, 1
%49 = tail call i8* @strndup(i8* %40, i32 %48)
store i8* %49, i8** %23
%50 = tail call i32 @strcat(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = load i8*, i8** %23
br label %54
52: ; preds = %35
%53 = tail call i8* @strndup(i8* %40, i32 %46)
store i8* %53, i8** %23
br label %54
54: ; preds = %52, %47
%55 = phi i8* [ %53, %52 ], [ %51, %47 ]
%56 = load i8*, i8** %13
%57 = tail call i32 @strcat(i8* %55, i8* %56)
br label %58
58: ; preds = %54, %30
%59 = load i8*, i8** %23
%60 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = load i8*, i8** %23
%62 = tail call i32 @creat(i8* %61, i32 420)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %58
%65 = load i8*, i8** %23
%66 = tail call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %58
%68 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%69 = call i32 @read(i32 %16, i8* %68, i32 4096)
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %81
71: ; preds = %67, %78
%72 = phi i32 [ %79, %78 ], [ %69, %67 ]
%73 = call i32 @write(i32 %62, i8* %68, i32 %72)
%74 = icmp eq i32 %73, %72
br i1 %74, label %78, label %75
75: ; preds = %71
%76 = load i8*, i8** %23
%77 = tail call i32 @oops(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %75, %71
%79 = call i32 @read(i32 %16, i8* %68, i32 4096)
%80 = icmp sgt i32 %79, 0
br i1 %80, label %71, label %81
81: ; preds = %78, %67
%82 = phi i32 [ %69, %67 ], [ %79, %78 ]
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i8*, i8** %13
%86 = tail call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %84, %81
%88 = tail call i32 @close(i32 %16)
%89 = icmp eq i32 %88, -1
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = tail call i32 @close(i32 %62)
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %95
93: ; preds = %90, %87
%94 = tail call i32 @oops(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %95
95: ; preds = %93, %90
%96 = load i8*, i8** %23
%97 = tail call i32 @free(i8* %96)
%98 = load i32, i32* @EXIT_SUCCESS
ret i32 %98
}