#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 /*<<< orphan*/ close(int);
int /*<<< orphan*/ encodefd(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc <= 1) {
    encodefd(0, 1);
  } else {
    for (int i = 1; i < argc; i++) {
      int fd;
      if ((fd = open(argv[i], 0)) < 0)
        fprintf(stdout, "base64: cannot open %s\n", argv[i]);
      encodefd(fd, 1);
      close(fd);
    }
  }
  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   $0x1,-0x8(%rbp)
jg     1171 <main+0x31>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <encodefd@plt>
jmp    11ec <main+0xac>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e7 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    11c4 <main+0x84>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe41(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1050 <encodefd@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x38>
jmp    11ec <main+0xac>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    116d <main+0x2d>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <encodefd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r12
mov    %edi,%r15d
mov    $0x1,%ebx
mov    0x2e61(%rip),%r13
lea    0xe7a(%rip),%r14
jmp    11ac <main+0x6c>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <encodefd@plt>
mov    %ebp,%edi
call   1030 <close@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     115c <main+0x1c>
mov    (%r12,%rbx,8),%rdi
xor    %esi,%esi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1190 <main+0x50>
mov    0x0(%r13),%edi
mov    (%r12,%rbx,8),%rdx
mov    %r14,%rsi
call   1040 <fprintf@plt>
jmp    1190 <main+0x50>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [24 x i8] c"base64: cannot open %s\0A\00"
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 sle i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @encodefd(i32 0, i32 1)
br label %42
12: ; preds = %2
store i32 1, i32* %6
br label %13
13: ; preds = %38, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %41
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @open(i8* %22, i32 0)
store i32 %23, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %17
%26 = load i32, i32* @stdout
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %25, %17
%34 = load i32, i32* %7
%35 = call i32 @encodefd(i32 %34, i32 1)
%36 = load i32, i32* %7
%37 = call i32 @close(i32 %36)
br label %38
38: ; preds = %33
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %13
41: ; preds = %13
br label %42
42: ; preds = %41, %10
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [24 x i8] c"base64: cannot open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %2
%7 = tail call i32 @encodefd(i32 0, i32 1)
br label %23
8: ; preds = %4, %18
%9 = phi i64 [ 1, %4 ], [ %21, %18 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @open(i8* %11, i32 0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i32, i32* @stdout
%16 = load i8*, i8** %10
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %8
%19 = tail call i32 @encodefd(i32 %12, i32 1)
%20 = tail call i32 @close(i32 %12)
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %5
br i1 %22, label %23, label %8
23: ; preds = %18, %6
ret i32 0
}