#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*/ *stdout;
FILE *parameter_set_output(int argc, char *argv[]) {
  FILE *return_value = stdout;
  char *output_str = parameter_read(argc, argv, "/o");
  if (output_str != NULL) {
    return_value = fopen(output_str, "w");
    if (return_value == NULL) {
      fprintf(stderr, "%s: Cannot open output file %s\n", argv[0], output_str);
      exit(1);
    }
    free(output_str);
  }
  return (return_value);
}


x86 assembly (clang, -O0):
<parameter_set_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e72(%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_output+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_output+0x88>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe3c(%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_output>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    0x2e79(%rip),%rax
mov    (%rax),%rbx
lea    0xe97(%rip),%rdx
call   1050 <parameter_read@plt>
test   %rax,%rax
je     1195 <parameter_set_output+0x45>
mov    %rax,%r15
lea    0xe86(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     119e <parameter_set_output+0x4e>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe54(%rip),%rsi
mov    %r15,%rcx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [3 x i8] c"/o\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"%s: Cannot open output file %s\0A\00"
define i32* @parameter_set_output(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** @stdout
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 ([2 x i8], [2 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 ([32 x i8], [32 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):
@stdout = global i32* null
@.str = [3 x i8] c"/o\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"%s: Cannot open output file %s\0A\00"
define i32* @parameter_set_output(i32 %0, i8** %1) {
%3 = load i32*, i32** @stdout
%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 ([2 x i8], [2 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 ([32 x i8], [32 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
}