#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_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ decode_file(int, int);
int open(char *, int, ...);
int main(int argc, char *argv[]) {
  int fdin, fdout;
  if (argc < 2)
    return 1;
  fdin = open(argv[1], O_RDONLY);
  fdout = open(argv[2], O_CREAT | O_WRONLY, 00664);
  decode_file(fdin, fdout);
  close(fdin);
  close(fdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    0x2e39(%rip),%rax
or     (%rax),%esi
mov    $0x1b4,%edx
mov    $0x0,%al
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <decode_file@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     1197 <main+0x67>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <open@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
mov    0x2e93(%rip),%rax
mov    0x2e5c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1b4,%edx
xor    %eax,%eax
call   1050 <open@plt>
mov    %eax,%ebx
mov    %r14d,%edi
mov    %eax,%esi
call   1030 <decode_file@plt>
mov    %r14d,%edi
call   1040 <close@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %31
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = call i32 (i8*, i32, ...) @open(i8* %14, i32 %15)
store i32 %16, i32* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = load i32, i32* @O_CREAT
%21 = load i32, i32* @O_WRONLY
%22 = or i32 %20, %21
%23 = call i32 (i8*, i32, ...) @open(i8* %19, i32 %22, i32 436)
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @decode_file(i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %7
%30 = call i32 @close(i32 %29)
store i32 0, i32* %3
br label %31
31: ; preds = %11, %10
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 (i8*, i32, ...) @open(i8* %6, i32 %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_CREAT
%12 = load i32, i32* @O_WRONLY
%13 = or i32 %12, %11
%14 = tail call i32 (i8*, i32, ...) @open(i8* %10, i32 %13, i32 436)
%15 = tail call i32 @decode_file(i32 %8, i32 %14)
%16 = tail call i32 @close(i32 %8)
%17 = tail call i32 @close(i32 %14)
br label %18
18: ; preds = %2, %4
%19 = phi i32 [ 0, %4 ], [ 1, %2 ]
ret i32 %19
}