#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
FILE *args_output_file(int argc, char **argv) {
  char *cfile = "success.chr";
  if (argc >= 3)
    cfile = argv[2];
  FILE *cfd = fopen(cfile, "w");
  if (cfd == NULL) {
    fprintf(stderr, "Invalid file to save best chromosomes: '%s'\n", cfile);
    return NULL;
  } else {
    fprintf(stderr, "Saving chromosome to file: '%s'\n", cfile);
  }
  return cfd;
}


x86 assembly (clang, -O0):
<args_output_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0xc(%rbp)
jl     1150 <args_output_file+0x30>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1195 <args_output_file+0x75>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe8b(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <args_output_file+0x96>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe92(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<args_output_file>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     112f <args_output_file+0xf>
mov    0x10(%rsi),%r14
jmp    1136 <args_output_file+0x16>
lea    0xeca(%rip),%r14
lea    0xecf(%rip),%rsi
mov    %r14,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rax
lea    0xed9(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"success.chr\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [45 x i8] c"Invalid file to save best chromosomes: '%s'\0A\00"
@.str.3 = [33 x i8] c"Saving chromosome to file: '%s'\0A\00"
define i32* @args_output_file(i32 %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
store i8* %13, i8** %6
br label %14
14: ; preds = %10, %2
%15 = load i8*, i8** %6
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %6
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %21)
store i32* null, i32** %3
br label %29
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %6
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %23
%28 = load i32*, i32** %7
store i32* %28, i32** %3
br label %29
29: ; preds = %27, %19
%30 = load i32*, i32** %3
ret i32* %30
}

LLVM IR (-O2):
@.str = [12 x i8] c"success.chr\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [45 x i8] c"Invalid file to save best chromosomes: '%s'\0A\00"
@.str.3 = [33 x i8] c"Saving chromosome to file: '%s'\0A\00"
define noalias i32* @args_output_file(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
br label %7
7: ; preds = %4, %2
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
%11 = load i32, i32* @stderr
%12 = select i1 %10, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0)
%13 = tail call i32 @fprintf(i32 %11, i8* %12, i8* %8)
ret i32* %9
}