#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
FILE *open_input(int argc, char **argv) {
  FILE *input;
  if (argc != 2) {
    fprintf(stdout, "input file missing.\n");
    fprintf(stdout,
            "usage: %s "
            "file_to_encrypt\n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  input = fopen(argv[1], "r");
  if (!input) {
    perror(NULL);
    fprintf(stdout,
            "usage: %s "
            "file_to_encrypt\n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  return input;
}


x86 assembly (clang, -O0):
<open_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     119c <open_input+0x5c>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f4 <open_input+0xb4>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_input>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1169 <open_input+0x29>
mov    0x8(%rbx),%rdi
lea    0xed9(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1186 <open_input+0x46>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e68(%rip),%r14
mov    (%r14),%edi
lea    0xe86(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
jmp    1196 <open_input+0x56>
xor    %edi,%edi
call   1050 <perror@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe75(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [21 x i8] c"input file missing.\0A\00"
@.str.1 = [27 x i8] c"usage: %s file_to_encrypt\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"r\00"
define i32* @open_input(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdout
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %22, i32** %5
%23 = load i32*, i32** %5
%24 = icmp ne i32* %23, null
br i1 %24, label %34, label %25
25: ; preds = %18
%26 = call i32 @perror(i32* null)
%27 = load i32, i32* @stdout
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %18
%35 = load i32*, i32** %5
ret i32* %35
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [21 x i8] c"input file missing.\0A\00"
@.str.1 = [27 x i8] c"usage: %s file_to_encrypt\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"r\00"
define noalias i32* @open_input(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
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.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = tail call i32 @perror(i32* null)
%19 = load i32, i32* @stdout
%20 = load i8*, i8** %1
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %12
ret i32* %15
}