#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*/ benchmark(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *get_output(int, char **);
char *read_optional_parameter(int, char **, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int command_benchmark(int argc, char *argv[]) {
  FILE *out = get_output(argc, argv);
  int i = 0;
  char *str_i = read_optional_parameter(argc, argv, "-b");
  if (str_i == NULL)
    str_i = read_optional_parameter(argc, argv, "--benchmark");
  if (str_i != NULL)
    sscanf(str_i, "%i", &i);
  benchmark(out, i);
  fclose(out);
  free(str_i);
  return 0;
}


x86 assembly (clang, -O0):
<command_benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <get_output@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdx
call   1080 <read_optional_parameter@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bf <command_benchmark+0x5f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4d(%rip),%rdx
call   1080 <read_optional_parameter@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11de <command_benchmark+0x7e>
mov    -0x28(%rbp),%rdi
lea    0xe3a(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <benchmark@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_benchmark>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
call   1070 <get_output@plt>
mov    %rax,%r14
movl   $0x0,0x4(%rsp)
lea    0xe7d(%rip),%rdx
mov    %ebp,%edi
mov    %r15,%rsi
call   1080 <read_optional_parameter@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ae <command_benchmark+0x4e>
lea    0xe67(%rip),%rdx
mov    %ebp,%edi
mov    %r15,%rsi
call   1080 <read_optional_parameter@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11eb <command_benchmark+0x8b>
lea    0xe5a(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1060 <benchmark@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %esi,%esi
xor    %ebx,%ebx
jmp    11c6 <command_benchmark+0x66>

LLVM IR (-O0):
@.str = [3 x i8] c"-b\00"
@.str.1 = [12 x i8] c"--benchmark\00"
@.str.2 = [3 x i8] c"%i\00"
define i32 @command_benchmark(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i32* @get_output(i32 %8, i8** %9)
store i32* %10, i32** %5
store i32 0, i32* %6
%11 = load i32, i32* %3
%12 = load i8**, i8*** %4
%13 = call i8* @read_optional_parameter(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* %3
%18 = load i8**, i8*** %4
%19 = call i8* @read_optional_parameter(i32 %17, i8** %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %7
br label %20
20: ; preds = %16, %2
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
br label %26
26: ; preds = %23, %20
%27 = load i32*, i32** %5
%28 = load i32, i32* %6
%29 = call i32 @benchmark(i32* %27, i32 %28)
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
%32 = load i8*, i8** %7
%33 = call i32 @free(i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-b\00"
@.str.1 = [12 x i8] c"--benchmark\00"
@.str.2 = [3 x i8] c"%i\00"
define i32 @command_benchmark(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32* @get_output(i32 %0, i8** %1)
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = tail call i8* @read_optional_parameter(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i8* @read_optional_parameter(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2, %8
%12 = phi i8* [ %9, %8 ], [ %6, %2 ]
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
br label %15
15: ; preds = %11, %8
%16 = phi i32 [ %14, %11 ], [ 0, %8 ]
%17 = phi i8* [ %12, %11 ], [ null, %8 ]
%18 = call i32 @benchmark(i32* %4, i32 %16)
%19 = call i32 @fclose(i32* %4)
%20 = call i32 @free(i8* %17)
ret i32 0
}