#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *get_output(int, char **);
int is_parameter_defined(int, char **, char *);
int /*<<< orphan*/ stderr;
int test_key_generation(int /*<<< orphan*/ *);
int command_test_generate(int argc, char *argv[]) {
  FILE *out;
  bool quite = is_parameter_defined(argc, argv, "--quite");
  if (!quite)
    quite = is_parameter_defined(argc, argv, "-q");
  if (quite) {
    out = fopen("/dev/null", "w");
    if (out == NULL) {
      fprintf(stderr, "%s: Can't open NULL_DEVICE, used in quite mode testing.",
              argv[0]);
      exit(2);
    }
  } else {
    out = get_output(argc, argv);
  }
  bool result = test_key_generation(out);
  fclose(out);
  if (result)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<command_test_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdx
call   1070 <is_parameter_defined@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11b5 <command_test_generate+0x45>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdx
call   1070 <is_parameter_defined@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     120c <command_test_generate+0x9c>
lea    0xe45(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1207 <command_test_generate+0x97>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
jmp    121c <command_test_generate+0xac>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <get_output@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <test_key_generation@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,-0x20(%rbp)
je     1247 <command_test_generate+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    124e <command_test_generate+0xde>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_test_generate>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe81(%rip),%rdx
call   1070 <is_parameter_defined@plt>
test   %eax,%eax
jne    119d <command_test_generate+0x2d>
lea    0xe79(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <is_parameter_defined@plt>
test   %eax,%eax
je     11d8 <command_test_generate+0x68>
lea    0xe67(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11e7 <command_test_generate+0x77>
mov    %rbp,%rdi
call   1080 <test_key_generation@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <get_output@plt>
mov    %rax,%rbp
jmp    11b8 <command_test_generate+0x48>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"--quite\00"
@.str.1 = [3 x i8] c"-q\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [56 x i8] c"%s: Can't open NULL_DEVICE, used in quite mode testing.\00"
define i32 @command_test_generate(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @is_parameter_defined(i32 %9, i8** %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @is_parameter_defined(i32 %15, i8** %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %17, i32* %7
br label %18
18: ; preds = %14, %2
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %21
br label %37
33: ; preds = %18
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32* @get_output(i32 %34, i8** %35)
store i32* %36, i32** %6
br label %37
37: ; preds = %33, %32
%38 = load i32*, i32** %6
%39 = call i32 @test_key_generation(i32* %38)
store i32 %39, i32* %8
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
%42 = load i32, i32* %8
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %37
store i32 0, i32* %3
br label %46
45: ; preds = %37
store i32 1, i32* %3
br label %46
46: ; preds = %45, %44
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [8 x i8] c"--quite\00"
@.str.1 = [3 x i8] c"-q\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [56 x i8] c"%s: Can't open NULL_DEVICE, used in quite mode testing.\00"
define i32 @command_test_generate(i32 %0, i8** %1) {
%3 = tail call i32 @is_parameter_defined(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @is_parameter_defined(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2, %5
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 2)
unreachable
16: ; preds = %5
%17 = tail call i32* @get_output(i32 %0, i8** %1)
br label %18
18: ; preds = %8, %16
%19 = phi i32* [ %9, %8 ], [ %17, %16 ]
%20 = tail call i32 @test_key_generation(i32* %19)
%21 = tail call i32 @fclose(i32* %19)
%22 = icmp eq i32 %20, 0
%23 = zext i1 %22 to i32
ret i32 %23
}