#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 */

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fork();
long getBytes(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int, ...);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
void *read(int, char *, int);
int /*<<< orphan*/ write(int, char *, long);
int main(int argc, char **argv) {
  char *buffer;
  char *bufferout;
  char *path;
  char *outpath;
  long numbytes = 0, readpipe = 0;
  int descriptor, outcriptor, reader, pid;
  int fd[2];
  if (argc == 1) {
    printf("\n[*] Uso: ej2_so archivoacopiar nuevoarchivo\n\n");
    exit(-1);
  } else if (argc == 3) {
    path = argv[1];
    outpath = argv[2];
    pipe(fd);
    numbytes = getBytes(path);
    if (numbytes < 1) {
      printf("\nError al determinar el numero de bytes del archivo %s\n", path);
      exit(-1);
    }
    pid = fork();
    switch (pid) {
    case -1:
      printf("\nError al crear el proceso hijo\n");
      exit(-1);
      break;
    case 0:
      close(fd[0]);
      buffer = (char *)malloc(1024 / sizeof(char));
      descriptor = open(path, O_RDONLY);
      if (descriptor < 0) {
        printf("\nError al abrir el archivo %s\n", path);
        exit(-1);
      }
      printf("\nCopiando: [");
      while ((reader = read(descriptor, buffer, 1024)) != 0) {
        write(fd[1], buffer, reader);
        printf("-");
      }
      printf(">]\t (*)Archivo copiado con éxito!\n\n");
      close(descriptor);
      exit(0);
      break;
    default:
      close(fd[1]);
      bufferout = (char *)malloc(1024 / sizeof(char));
      while ((readpipe = read(fd[0], bufferout, 1024)) != 0) {
        outcriptor = open(outpath, O_WRONLY | O_CREAT | O_APPEND, 0666);
        if (outcriptor < 0) {
          printf("\nError al crear el archivo de destino %s\n", outpath);
          exit(-1);
        }
        write(outcriptor, bufferout, readpipe);
        memset(bufferout, 0, 1024);
      }
      close(outcriptor);
    }
  } else {
    printf("\nError con los argumentos\nUso: ej2_so archivoacopiar "
           "nuevoarchivo\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f8 <main+0x48>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1416 <main+0x266>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    -0x58(%rbp),%rdi
call   1070 <pipe@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <getBytes@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x1,-0x38(%rbp)
jge    1257 <main+0xa7>
mov    -0x28(%rbp),%rsi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x5c(%rbp)
sub    $0xffffffff,%eax
je     1285 <main+0xd5>
jmp    1275 <main+0xc5>
mov    -0x5c(%rbp),%eax
test   %eax,%eax
je     129d <main+0xed>
jmp    135b <main+0x1ab>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x58(%rbp),%edi
call   1060 <close@plt>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    12f0 <main+0x140>
mov    -0x28(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     133e <main+0x18e>
mov    -0x54(%rbp),%edi
mov    -0x18(%rbp),%rsi
movslq -0x4c(%rbp),%rdx
call   1030 <write@plt>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12fe <main+0x14e>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x54(%rbp),%edi
call   1060 <close@plt>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x58(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     1409 <main+0x259>
mov    -0x30(%rbp),%rdi
mov    0x2c2d(%rip),%rax
mov    (%rax),%esi
mov    0x2c54(%rip),%rax
or     (%rax),%esi
mov    0x2c13(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    13e4 <main+0x234>
mov    -0x30(%rbp),%rsi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x48(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1030 <write@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
jmp    1371 <main+0x1c1>
mov    -0x48(%rbp),%edi
call   1060 <close@plt>
jmp    1424 <main+0x274>
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1429 <main+0x279>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
je     11fa <main+0x2a>
cmp    $0x1,%edi
je     12fd <main+0x12d>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
jmp    12d1 <main+0x101>
mov    0x8(%rsi),%rbp
mov    0x10(%rsi),%r14
mov    %rsp,%rdi
call   1090 <pipe@plt>
mov    %rbp,%rdi
call   10d0 <getBytes@plt>
test   %rax,%rax
jle    1306 <main+0x136>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     130f <main+0x13f>
cmp    $0xffffffff,%eax
je     1347 <main+0x177>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
mov    $0x400,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
mov    (%rsp),%edi
mov    %rax,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %rax,%rbx
mov    0x2d95(%rip),%r13
mov    0x2d56(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%esi
mov    0x2d4d(%rip),%rax
or     (%rax),%esi
or     (%r12),%esi
mov    %r14,%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     12e2 <main+0x112>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <write@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    (%rsp),%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1270 <main+0xa0>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd7b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
lea    0xe10(%rip),%rdi
jmp    134e <main+0x17e>
lea    0xcf3(%rip),%rdi
jmp    1342 <main+0x172>
mov    (%rsp),%edi
call   1080 <close@plt>
mov    $0x400,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
jns    135d <main+0x18d>
lea    0xcf6(%rip),%rdi
mov    %rbp,%rsi
jmp    12ec <main+0x11c>
lea    0xda6(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    %eax,%r14d
lea    0xcf0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
test   %eax,%eax
je     139d <main+0x1cd>
mov    0x4(%rsp),%edi
movslq %eax,%rdx
mov    %rbx,%rsi
call   1050 <write@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
jmp    136e <main+0x19e>
lea    0xd2c(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"\0A[*] Uso: ej2_so archivoacopiar nuevoarchivo\0A\0A\00"
@.str.1 = [56 x i8] c"\0AError al determinar el numero de bytes del archivo %s\0A\00"
@.str.2 = [33 x i8] c"\0AError al crear el proceso hijo\0A\00"
@O_RDONLY = global i32 0
@.str.3 = [31 x i8] c"\0AError al abrir el archivo %s\0A\00"
@.str.4 = [13 x i8] c"\0ACopiando: [\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [37 x i8] c">]\09 (*)Archivo copiado con \C3\A9xito!\0A\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.7 = [42 x i8] c"\0AError al crear el archivo de destino %s\0A\00"
@.str.8 = [67 x i8] c"\0AError con los argumentos\0AUso: ej2_so archivoacopiar nuevoarchivo\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %10
store i64 0, i64* %11
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %122
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %8
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
store i8* %31, i8** %9
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%33 = call i32 @pipe(i32* %32)
%34 = load i8*, i8** %8
%35 = call i64 @getBytes(i8* %34)
store i64 %35, i64* %10
%36 = load i64, i64* %10
%37 = icmp slt i64 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %25
%39 = load i8*, i8** %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %25
%43 = call i32 (...) @fork()
store i32 %43, i32* %15
%44 = load i32, i32* %15
switch i32 %44, label %84 [
i32 -1, label %45
i32 0, label %48
]
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %42
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%50 = load i32, i32* %49
%51 = call i32 @close(i32 %50)
%52 = call i64 @malloc(i32 1024)
%53 = inttoptr i64 %52 to i8*
store i8* %53, i8** %6
%54 = load i8*, i8** %8
%55 = load i32, i32* @O_RDONLY
%56 = call i32 (i8*, i32, ...) @open(i8* %54, i32 %55)
store i32 %56, i32* %12
%57 = load i32, i32* %12
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %48
%60 = load i8*, i8** %8
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 -1)
unreachable
63: ; preds = %48
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %71, %63
%66 = load i32, i32* %12
%67 = load i8*, i8** %6
%68 = call i8* @read(i32 %66, i8* %67, i32 1024)
%69 = ptrtoint i8* %68 to i32
store i32 %69, i32* %14
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %79
71: ; preds = %65
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%73 = load i32, i32* %72
%74 = load i8*, i8** %6
%75 = load i32, i32* %14
%76 = sext i32 %75 to i64
%77 = call i32 @write(i32 %73, i8* %74, i64 %76)
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %65
79: ; preds = %65
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%81 = load i32, i32* %12
%82 = call i32 @close(i32 %81)
%83 = call i32 @exit(i32 0)
unreachable
84: ; preds = %42
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = call i64 @malloc(i32 1024)
%89 = inttoptr i64 %88 to i8*
store i8* %89, i8** %7
br label %90
90: ; preds = %111, %84
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%92 = load i32, i32* %91
%93 = load i8*, i8** %7
%94 = call i8* @read(i32 %92, i8* %93, i32 1024)
%95 = ptrtoint i8* %94 to i64
store i64 %95, i64* %11
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %118
97: ; preds = %90
%98 = load i8*, i8** %9
%99 = load i32, i32* @O_WRONLY
%100 = load i32, i32* @O_CREAT
%101 = or i32 %99, %100
%102 = load i32, i32* @O_APPEND
%103 = or i32 %101, %102
%104 = call i32 (i8*, i32, ...) @open(i8* %98, i32 %103, i32 438)
store i32 %104, i32* %13
%105 = load i32, i32* %13
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %111
107: ; preds = %97
%108 = load i8*, i8** %9
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %108)
%110 = call i32 @exit(i32 -1)
unreachable
111: ; preds = %97
%112 = load i32, i32* %13
%113 = load i8*, i8** %7
%114 = load i64, i64* %11
%115 = call i32 @write(i32 %112, i8* %113, i64 %114)
%116 = load i8*, i8** %7
%117 = call i32 @memset(i8* %116, i32 0, i32 1024)
br label %90
118: ; preds = %90
%119 = load i32, i32* %13
%120 = call i32 @close(i32 %119)
br label %121
121: ; preds = %118
br label %124
122: ; preds = %22
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
br label %124
124: ; preds = %122, %121
br label %125
125: ; preds = %124
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [56 x i8] c"\0AError al determinar el numero de bytes del archivo %s\0A\00"
@O_RDONLY = global i32 0
@.str.3 = [31 x i8] c"\0AError al abrir el archivo %s\0A\00"
@.str.4 = [13 x i8] c"\0ACopiando: [\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.7 = [42 x i8] c"\0AError al crear el archivo de destino %s\0A\00"
@str = [66 x i8] c"\0AError con los argumentos\0AUso: ej2_so archivoacopiar nuevoarchivo\00"
@str.9 = [36 x i8] c">]\09 (*)Archivo copiado con \C3\A9xito!\0A\00"
@str.10 = [32 x i8] c"\0AError al crear el proceso hijo\00"
@str.11 = [46 x i8] c"\0A[*] Uso: ej2_so archivoacopiar nuevoarchivo\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
switch i32 %0, label %89 [
i32 1, label %5
i32 3, label %8
]
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = call i32 @pipe(i32* %13)
%15 = call i64 @getBytes(i8* %10)
%16 = icmp slt i64 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %8
%21 = call i32 (...) @fork()
switch i32 %21, label %59 [
i32 -1, label %22
i32 0, label %25
]
22: ; preds = %20
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %20
%26 = load i32, i32* %13
%27 = call i32 @close(i32 %26)
%28 = call i64 @malloc(i32 1024)
%29 = inttoptr i64 %28 to i8*
%30 = load i32, i32* @O_RDONLY
%31 = call i32 (i8*, i32, ...) @open(i8* %10, i32 %30)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %25
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%38 = call i8* @read(i32 %31, i8* %29, i32 1024)
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %55, label %42
42: ; preds = %36
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %44
44: ; preds = %42, %44
%45 = phi i64 [ %39, %42 ], [ %52, %44 ]
%46 = load i32, i32* %43
%47 = shl i64 %45, 32
%48 = ashr exact i64 %47, 32
%49 = call i32 @write(i32 %46, i8* %29, i64 %48)
%50 = call i32 @putchar(i32 45)
%51 = call i8* @read(i32 %31, i8* %29, i32 1024)
%52 = ptrtoint i8* %51 to i64
%53 = trunc i64 %52 to i32
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %44
55: ; preds = %44, %36
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%57 = call i32 @close(i32 %31)
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %20
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%61 = load i32, i32* %60
%62 = call i32 @close(i32 %61)
%63 = call i64 @malloc(i32 1024)
%64 = inttoptr i64 %63 to i8*
%65 = load i32, i32* %13
%66 = call i8* @read(i32 %65, i8* %64, i32 1024)
%67 = icmp ne i8* %66, null
br label %68
68: ; preds = %59, %80
%69 = phi i8* [ %85, %80 ], [ %66, %59 ]
%70 = load i32, i32* @O_WRONLY
%71 = load i32, i32* @O_CREAT
%72 = or i32 %71, %70
%73 = load i32, i32* @O_APPEND
%74 = or i32 %72, %73
%75 = call i32 (i8*, i32, ...) @open(i8* %12, i32 %74, i32 438)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %68
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %12)
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %68
%81 = ptrtoint i8* %69 to i64
%82 = call i32 @write(i32 %75, i8* %64, i64 %81)
%83 = call i32 @memset(i8* %64, i32 0, i32 1024)
%84 = load i32, i32* %13
%85 = call i8* @read(i32 %84, i8* %64, i32 1024)
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %68
87: ; preds = %80
%88 = call i32 @close(i32 %75)
br label %91
89: ; preds = %2
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %91
91: ; preds = %87, %89
ret i32 0
}