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

/* Variables and functions */
int /*<<< orphan*/ change_arr(int *, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ print_arr(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_arr(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write_arr(int /*<<< orphan*/ *, int *, int);
int main(int argc, char **argv) {
  setbuf(stdout, NULL);
  int arr[20];
  int size;
  FILE *f1, *f2;
  if (argc != 3) {
    printf("Incorrect number of arguments\n");
    return -1;
  }
  f1 = fopen(argv[1], "r");
  f2 = fopen(argv[2], "w");
  if ((f1 == NULL) || (f2 == NULL)) {
    printf("Can't open files\n");
    return -3;
  }
  read_arr(f1, arr, &size);
  print_arr(arr, size);
  change_arr(arr, size);
  print_arr(arr, size);
  write_arr(f2, arr, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
cmpl   $0x3,-0x8(%rbp)
je     11bd <main+0x4d>
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1267 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     1203 <main+0x93>
cmpq   $0x0,-0x78(%rbp)
jne    121b <main+0xab>
lea    0xe19(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1267 <main+0xf7>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x64(%rbp),%rdx
call   1060 <read_arr@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1030 <print_arr@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1090 <change_arr@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1030 <print_arr@plt>
mov    -0x78(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
call   1070 <write_arr@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
cmp    $0x3,%ebp
jne    120e <main+0x9e>
mov    0x8(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
test   %r14,%r14
je     1221 <main+0xb1>
mov    %rax,%rbx
test   %rax,%rax
je     1221 <main+0xb1>
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <read_arr@plt>
mov    0xc(%rsp),%esi
mov    %rbp,%rdi
call   1040 <print_arr@plt>
mov    0xc(%rsp),%esi
mov    %rbp,%rdi
call   1090 <change_arr@plt>
mov    0xc(%rsp),%esi
mov    %rbp,%rdi
call   1040 <print_arr@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <write_arr@plt>
xor    %eax,%eax
jmp    1232 <main+0xc2>
lea    0xe00(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    1232 <main+0xc2>
lea    0xddc(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffd,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [31 x i8] c"Incorrect number of arguments\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [18 x i8] c"Can't open files\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i32]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @stdout
%11 = call i32 @setbuf(i32 %10, i32* null)
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %49
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %8
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %24, i32** %9
%25 = load i32*, i32** %8
%26 = icmp eq i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %16
%28 = load i32*, i32** %9
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %27, %16
%31 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 -3, i32* %3
br label %49
32: ; preds = %27
%33 = load i32*, i32** %8
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%35 = call i32 @read_arr(i32* %33, i32* %34, i32* %7)
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%37 = load i32, i32* %7
%38 = call i32 @print_arr(i32* %36, i32 %37)
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%40 = load i32, i32* %7
%41 = call i32 @change_arr(i32* %39, i32 %40)
%42 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call i32 @print_arr(i32* %42, i32 %43)
%45 = load i32*, i32** %9
%46 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%47 = load i32, i32* %7
%48 = call i32 @write_arr(i32* %45, i32* %46, i32 %47)
store i32 0, i32* %3
br label %49
49: ; preds = %32, %30, %14
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@str = [17 x i8] c"Can't open files\00"
@str.4 = [30 x i8] c"Incorrect number of arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = load i32, i32* @stdout
%6 = tail call i32 @setbuf(i32 %5, i32* null)
%7 = bitcast [20 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = icmp eq i32 %0, 3
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
br label %35
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %15, null
%20 = icmp eq i32* %18, null
%21 = or i1 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %35
24: ; preds = %12
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%26 = call i32 @read_arr(i32* %15, i32* %25, i32* %4)
%27 = load i32, i32* %4
%28 = call i32 @print_arr(i32* %25, i32 %27)
%29 = load i32, i32* %4
%30 = call i32 @change_arr(i32* %25, i32 %29)
%31 = load i32, i32* %4
%32 = call i32 @print_arr(i32* %25, i32 %31)
%33 = load i32, i32* %4
%34 = call i32 @write_arr(i32* %18, i32* %25, i32 %33)
br label %35
35: ; preds = %24, %22, %10
%36 = phi i32 [ -1, %10 ], [ -3, %22 ], [ 0, %24 ]
ret i32 %36
}