#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 */
typedef int /*<<< orphan*/ size;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ in_size;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fork();
int open(char *, int, ...);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *);
scalar_t__ read(int, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int write(int, ...);
int main() {
  int fd[2];
  char data[1000];
  if (pipe(fd) < 0) {
    printf("Can\'t create pipe\n");
    exit(-1);
  }
  char pathname_from[1000];
  char pathname_to[1000];
  printf("gimme source\n");
  fgets(pathname_from, 1000, stdin);
  printf("gimme dest\n");
  fgets(pathname_to, 1000, stdin);
  pathname_from[strlen(pathname_from) - 1] = 0;
  pathname_to[strlen(pathname_to) - 1] = 0;
  pid_t result = fork();
  if (result > 0) {
    close(fd[0]);
    int fd_in = open(pathname_from, O_RDONLY);
    if (fd_in == -1) {
      printf("Can\'t open source\n");
      exit(-1);
    }
    int size = read(fd_in, &data, 1000);
    if (size < 0) {
      printf("Can\'t read\n");
      exit(-1);
    }
    if (write(fd[1], &size, sizeof(size)) < 0) {
      printf("Can\'t write size\n");
      exit(-1);
    }
    if (write(fd[1], data, size) < 0) {
      printf("Can\'t write data\n");
      exit(-1);
    }
    close(fd[1]);
    close(fd_in);
  } else {
    close(fd[1]);
    int in_size;
    if (read(fd[0], &in_size, sizeof(in_size)) < 0) {
      printf("Can\'t read size\n");
      exit(-1);
    }
    if (read(fd[0], data, in_size) < 0) {
      printf("Er with reading\n");
      exit(-1);
    }
    int fd_out = open(pathname_to, O_WRONLY | O_CREAT, 0644);
    if (write(fd_out, data, in_size) != in_size) {
      printf("Er with writing\n");
      exit(-1);
    }
    printf("we did it\n");
    close(fd[0]);
    close(fd_out);
  }
  waitpid(result, NULL, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc00,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    11eb <main+0x3b>
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
lea    -0x7f0(%rbp),%rdi
mov    0x2dd3(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1090 <fgets@plt>
lea    0xe09(%rip),%rdi
call   1050 <printf@plt>
lea    -0xbe0(%rbp),%rdi
mov    0x2dad(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1090 <fgets@plt>
lea    -0x7f0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x7f0(%rbp,%rax,1)
lea    -0xbe0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xbe0(%rbp,%rax,1)
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0xbe8(%rbp)
cmpq   $0x0,-0xbe8(%rbp)
jle    1392 <main+0x1e2>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
lea    -0x7f0(%rbp),%rdi
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0xbec(%rbp)
cmpl   $0xffffffff,-0xbec(%rbp)
jne    12cd <main+0x11d>
lea    0xd6f(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0xbec(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    $0x3e8,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0xbf0(%rbp)
cmpl   $0x0,-0xbf0(%rbp)
jge    130f <main+0x15f>
lea    0xd40(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0xbf0(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%eax
jge    1344 <main+0x194>
lea    0xd17(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    -0xbf0(%rbp),%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%eax
jge    137a <main+0x1ca>
lea    0xcf3(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    -0xbec(%rbp),%edi
call   1060 <close@plt>
jmp    148d <main+0x2dd>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    -0xc(%rbp),%edi
lea    -0xbf4(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
cmp    $0x0,%rax
jge    13d0 <main+0x220>
lea    0xcaf(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    -0xbf4(%rbp),%edx
mov    $0x0,%al
call   1080 <read@plt>
cmp    $0x0,%rax
jge    1407 <main+0x257>
lea    0xc89(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    -0xbe0(%rbp),%rdi
mov    0x2bab(%rip),%rax
mov    (%rax),%esi
mov    0x2bda(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0xbf8(%rbp)
mov    -0xbf8(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    -0xbf4(%rbp),%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    -0xbf4(%rbp),%eax
je     146e <main+0x2be>
lea    0xc33(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xc2e(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0xbf8(%rbp),%edi
call   1060 <close@plt>
mov    -0xbe8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
xor    %eax,%eax
add    $0xc00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xbd8,%rsp
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     1391 <main+0x1e1>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df9(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x7f0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1090 <fgets@plt>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edx
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x3e8,%esi
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
jle    12d9 <main+0x129>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
lea    0x7f0(%rsp),%rdi
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     139a <main+0x1ea>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x3e8,%edx
xor    %eax,%eax
call   1080 <read@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     13a3 <main+0x1f3>
mov    0xc(%rsp),%edi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <write@plt>
test   %eax,%eax
js     13ac <main+0x1fc>
mov    0xc(%rsp),%edi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <write@plt>
test   %eax,%eax
js     13b5 <main+0x205>
mov    0xc(%rsp),%edi
jmp    136d <main+0x1bd>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1080 <read@plt>
test   %rax,%rax
js     13be <main+0x20e>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <read@plt>
test   %rax,%rax
js     13c7 <main+0x217>
mov    0x2c9c(%rip),%rax
mov    0x2ccd(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0x400(%rsp),%rdi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10b0 <open@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
xor    %eax,%eax
call   1040 <write@plt>
cmp    0x4(%rsp),%eax
jne    13d0 <main+0x220>
lea    0xcb4(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
xor    %eax,%eax
add    $0xbd8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xcf9(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xcde(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xcca(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xcb0(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xc96(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xc7d(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xc64(%rip),%rdi
jmp    13d7 <main+0x227>
lea    0xc4b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Can't create pipe\0A\00"
@.str.1 = [14 x i8] c"gimme source\0A\00"
@stdin = global i32 0
@.str.2 = [12 x i8] c"gimme dest\0A\00"
@O_RDONLY = global i32 0
@.str.3 = [19 x i8] c"Can't open source\0A\00"
@.str.4 = [12 x i8] c"Can't read\0A\00"
@.str.5 = [18 x i8] c"Can't write size\0A\00"
@.str.6 = [18 x i8] c"Can't write data\0A\00"
@.str.7 = [17 x i8] c"Can't read size\0A\00"
@.str.8 = [17 x i8] c"Er with reading\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.9 = [17 x i8] c"Er with writing\0A\00"
@.str.10 = [11 x i8] c"we did it\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = call i64 @pipe(i32* %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 1000, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i32 @fgets(i8* %23, i32 1000, i32 %24)
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %34
store i8 0, i8* %35
%36 = call i64 (...) @fork()
store i64 %36, i64* %6
%37 = load i64, i64* %6
%38 = icmp sgt i64 %37, 0
br i1 %38, label %39, label %84
39: ; preds = %17
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%44 = load i32, i32* @O_RDONLY
%45 = call i32 (i8*, i32, ...) @open(i8* %43, i32 %44)
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %39
%49 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %39
%52 = load i32, i32* %7
%53 = call i64 (i32, ...) @read(i32 %52, [1000 x i8]* %3, i32 1000)
%54 = trunc i64 %53 to i32
store i32 %54, i32* %8
%55 = load i32, i32* %8
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32 @exit(i32 -1)
unreachable
60: ; preds = %51
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%62 = load i32, i32* %61
%63 = call i32 (i32, ...) @write(i32 %62, i32* %8, i64 4)
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%67 = call i32 @exit(i32 -1)
unreachable
68: ; preds = %60
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%70 = load i32, i32* %69
%71 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%72 = load i32, i32* %8
%73 = call i32 (i32, ...) @write(i32 %70, i8* %71, i32 %72)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %68
%76 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%77 = call i32 @exit(i32 -1)
unreachable
78: ; preds = %68
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %7
%83 = call i32 @close(i32 %82)
br label %127
84: ; preds = %17
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%89 = load i32, i32* %88
%90 = call i64 (i32, ...) @read(i32 %89, i32* %9, i64 4)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %84
%93 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%94 = call i32 @exit(i32 -1)
unreachable
95: ; preds = %84
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%97 = load i32, i32* %96
%98 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%99 = load i32, i32* %9
%100 = call i64 (i32, ...) @read(i32 %97, i8* %98, i32 %99)
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %95
%103 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%104 = call i32 @exit(i32 -1)
unreachable
105: ; preds = %95
%106 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%107 = load i32, i32* @O_WRONLY
%108 = load i32, i32* @O_CREAT
%109 = or i32 %107, %108
%110 = call i32 (i8*, i32, ...) @open(i8* %106, i32 %109, i32 420)
store i32 %110, i32* %10
%111 = load i32, i32* %10
%112 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%113 = load i32, i32* %9
%114 = call i32 (i32, ...) @write(i32 %111, i8* %112, i32 %113)
%115 = load i32, i32* %9
%116 = icmp ne i32 %114, %115
br i1 %116, label %117, label %120
117: ; preds = %105
%118 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%119 = call i32 @exit(i32 -1)
unreachable
120: ; preds = %105
%121 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%122 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%123 = load i32, i32* %122
%124 = call i32 @close(i32 %123)
%125 = load i32, i32* %10
%126 = call i32 @close(i32 %125)
br label %127
127: ; preds = %120, %78
%128 = load i64, i64* %6
%129 = call i32 @waitpid(i64 %128, i32* null, i32 0)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@str = [13 x i8] c"gimme source\00"
@str.11 = [11 x i8] c"gimme dest\00"
@str.12 = [10 x i8] c"we did it\00"
@str.13 = [16 x i8] c"Er with writing\00"
@str.14 = [16 x i8] c"Er with reading\00"
@str.15 = [16 x i8] c"Can't read size\00"
@str.16 = [17 x i8] c"Can't write data\00"
@str.17 = [17 x i8] c"Can't write size\00"
@str.18 = [11 x i8] c"Can't read\00"
@str.19 = [18 x i8] c"Can't open source\00"
@str.20 = [18 x i8] c"Can't create pipe\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [2 x i32]* %1 to i8*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%10 = call i64 @pipe(i32* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.20, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %0
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %16, i32 1000, i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.11, i64 0, i64 0))
%22 = load i32, i32* @stdin
%23 = call i32 @fgets(i8* %17, i32 1000, i32 %22)
%24 = call i32 @strlen(i8* %16)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i32 @strlen(i8* %17)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %30
store i8 0, i8* %31
%32 = call i64 (...) @fork()
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %71
34: ; preds = %15
%35 = load i32, i32* %9
%36 = call i32 @close(i32 %35)
%37 = load i32, i32* @O_RDONLY
%38 = call i32 (i8*, i32, ...) @open(i8* %16, i32 %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.19, i64 0, i64 0))
%42 = call i32 @exit(i32 -1)
unreachable
43: ; preds = %34
%44 = bitcast i32* %5 to i8*
%45 = call i64 (i32, ...) @read(i32 %38, [1000 x i8]* %2, i32 1000)
%46 = trunc i64 %45 to i32
store i32 %46, i32* %5
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %43
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%53 = load i32, i32* %52
%54 = call i32 (i32, ...) @write(i32 %53, i32* %5, i64 4)
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %51
%60 = load i32, i32* %52
%61 = load i32, i32* %5
%62 = call i32 (i32, ...) @write(i32 %60, i8* %8, i32 %61)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %59
%68 = load i32, i32* %52
%69 = call i32 @close(i32 %68)
%70 = call i32 @close(i32 %38)
br label %107
71: ; preds = %15
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%73 = load i32, i32* %72
%74 = call i32 @close(i32 %73)
%75 = bitcast i32* %6 to i8*
%76 = load i32, i32* %9
%77 = call i64 (i32, ...) @read(i32 %76, i32* %6, i64 4)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %71
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.15, i64 0, i64 0))
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %71
%83 = load i32, i32* %9
%84 = load i32, i32* %6
%85 = call i64 (i32, ...) @read(i32 %83, i8* %8, i32 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %82
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
%89 = call i32 @exit(i32 -1)
unreachable
90: ; preds = %82
%91 = load i32, i32* @O_WRONLY
%92 = load i32, i32* @O_CREAT
%93 = or i32 %92, %91
%94 = call i32 (i8*, i32, ...) @open(i8* %17, i32 %93, i32 420)
%95 = load i32, i32* %6
%96 = call i32 (i32, ...) @write(i32 %94, i8* %8, i32 %95)
%97 = load i32, i32* %6
%98 = icmp eq i32 %96, %97
br i1 %98, label %102, label %99
99: ; preds = %90
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0))
%101 = call i32 @exit(i32 -1)
unreachable
102: ; preds = %90
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
%104 = load i32, i32* %9
%105 = call i32 @close(i32 %104)
%106 = call i32 @close(i32 %94)
br label %107
107: ; preds = %102, %67
%108 = call i32 @waitpid(i64 %32, i32* null, i32 0)
ret i32 0
}