#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(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *parameter_read(int, char **, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
FILE *parameter_set_input(int argc, char *argv[]) {
  FILE *return_value = stdin;
  char *input_str = parameter_read(argc, argv, "/i");
  if (input_str != NULL) {
    return_value = fopen(input_str, "rb");
    if (return_value == NULL) {
      fprintf(stderr, "%s: Cannot open input file %s\n", argv[0], input_str);
      exit(1);
    }
    free(input_str);
  }
  return (return_value);
}


x86 assembly (clang, -O0):
<parameter_set_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdx
call   1050 <parameter_read@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e1 <parameter_set_input+0x91>
mov    -0x20(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d8 <parameter_set_input+0x88>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe3d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parameter_set_input>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    0x2e89(%rip),%rax
mov    (%rax),%rbx
lea    0xe97(%rip),%rdx
call   1050 <parameter_read@plt>
test   %rax,%rax
je     1195 <parameter_set_input+0x45>
mov    %rax,%r15
lea    0xe86(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     119e <parameter_set_input+0x4e>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe55(%rip),%rsi
mov    %r15,%rcx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [3 x i8] c"/i\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"%s: Cannot open input file %s\0A\00"
define i32* @parameter_set_input(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32*, i32** @stdin
store i32* %7, i32** %5
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i8* @parameter_read(i32 %8, i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %29
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %5
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = load i8*, i8** %6
%24 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %13
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %26, %2
%30 = load i32*, i32** %5
ret i32* %30
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [3 x i8] c"/i\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"%s: Cannot open input file %s\0A\00"
define i32* @parameter_set_input(i32 %0, i8** %1) {
%3 = load i32*, i32** @stdin
%4 = tail call i8* @parameter_read(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %4)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %6
%15 = tail call i32 @free(i8* %4)
br label %16
16: ; preds = %14, %2
%17 = phi i32* [ %7, %14 ], [ %3, %2 ]
ret i32* %17
}