#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 EXIT_FAILURE;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ parse(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *is = fopen(argv[1], "r");
  if (argc < 2) {
    fprintf(stderr, "Usage: function_prototype_extractor "
                    "<input code file name> "
                    "<output file [default = function_prototypes.txt]>\n");
    return EXIT_FAILURE;
  }
  if (is == NULL) {
    fprintf(stderr, "Failed to open one or more files.\n");
    return EXIT_FAILURE;
  }
  parse(is);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118e <main+0x5e>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cf <main+0x9f>
cmpq   $0x0,-0x18(%rbp)
jne    11bf <main+0x8f>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xec7(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cf <main+0x9f>
mov    -0x18(%rbp),%rdi
call   1050 <parse@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
cmp    $0x1,%ebx
jg     115a <main+0x2a>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
jmp    117b <main+0x4b>
test   %rax,%rax
je     116b <main+0x3b>
mov    %rax,%rdi
call   1050 <parse@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xef5(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [110 x i8] c"Usage: function_prototype_extractor <input code file name> <output file [default = function_prototypes.txt]>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [35 x i8] c"Failed to open one or more files.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %27
17: ; preds = %2
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %27
24: ; preds = %17
%25 = load i32*, i32** %6
%26 = call i32 @parse(i32* %25)
store i32 0, i32* %3
br label %27
27: ; preds = %24, %20, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [110 x i8] c"Usage: function_prototype_extractor <input code file name> <output file [default = function_prototypes.txt]>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [35 x i8] c"Failed to open one or more files.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
br label %19
11: ; preds = %2
%12 = icmp eq i32* %5, null
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
br label %19
17: ; preds = %11
%18 = tail call i32 @parse(i32* %5)
br label %19
19: ; preds = %17, %13, %7
%20 = phi i32 [ %10, %7 ], [ %16, %13 ], [ 0, %17 ]
ret i32 %20
}