#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 */

/* Variables and functions */
int /*<<< orphan*/ emit_code(int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ make_ff();
int /*<<< orphan*/ make_primes();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *opt = argc > 1 ? argv[1] : NULL;
  make_primes();
  make_ff();
  if (!opt)
    emit_code(stdout, 0);
  else if (!strcmp(opt, "h") || !strcmp(opt, ".h") || !strcmp(opt, "-h"))
    emit_code(stdout, 1);
  else if (!strcmp(opt, "c") || !strcmp(opt, ".c") || !strcmp(opt, "-c"))
    emit_code(stdout, 0);
  else {
    fprintf(stderr, "Usage: ffgen [-h|-c]\n");
    fprintf(stderr, "  -h for header file\n");
    fprintf(stderr, "  -c for C source file\n");
    return 1;
  }
  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)
cmpl   $0x1,-0x8(%rbp)
jle    1181 <main+0x31>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    118c <main+0x3c>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    118c <main+0x3c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <make_primes@plt>
mov    $0x0,%al
call   1060 <make_ff@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11c2 <main+0x72>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <emit_code@plt>
jmp    12da <main+0x18a>
mov    -0x18(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     120d <main+0xbd>
mov    -0x18(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     120d <main+0xbd>
mov    -0x18(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1225 <main+0xd5>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1030 <emit_code@plt>
jmp    12d5 <main+0x185>
mov    -0x18(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1270 <main+0x120>
mov    -0x18(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1270 <main+0x120>
mov    -0x18(%rbp),%rdi
lea    0xda7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <main+0x135>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <emit_code@plt>
jmp    12d0 <main+0x180>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xd78(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e1 <main+0x191>
jmp    12d5 <main+0x185>
jmp    12da <main+0x18a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     115e <main+0xe>
mov    0x8(%rsi),%rbx
jmp    1160 <main+0x10>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <make_primes@plt>
xor    %eax,%eax
call   1060 <make_ff@plt>
test   %rbx,%rbx
je     1246 <main+0xf6>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122f <main+0xdf>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122f <main+0xdf>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122f <main+0xdf>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1251 <main+0x101>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1251 <main+0x101>
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1251 <main+0x101>
mov    0x2de2(%rip),%rbx
mov    (%rbx),%edi
lea    0xe05(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe0d(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe15(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebp
jmp    1263 <main+0x113>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1030 <emit_code@plt>
xor    %ebp,%ebp
jmp    1263 <main+0x113>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
jmp    125c <main+0x10c>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
xor    %ebp,%ebp
xor    %esi,%esi
call   1030 <emit_code@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [2 x i8] c"h\00"
@.str.1 = [3 x i8] c".h\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [2 x i8] c"c\00"
@.str.4 = [3 x i8] c".c\00"
@.str.5 = [3 x i8] c"-c\00"
@stderr = global i32 0
@.str.6 = [22 x i8] c"Usage: ffgen [-h|-c]\0A\00"
@.str.7 = [22 x i8] c" -h for header file\0A\00"
@.str.8 = [24 x i8] c" -c for C source file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
br label %14
13: ; preds = %2
br label %14
14: ; preds = %13, %9
%15 = phi i8* [ %12, %9 ], [ null, %13 ]
store i8* %15, i8** %6
%16 = call i32 (...) @make_primes()
%17 = call i32 (...) @make_ff()
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = load i32, i32* @stdout
%22 = call i32 @emit_code(i32 %21, i32 0)
br label %62
23: ; preds = %14
%24 = load i8*, i8** %6
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i8*, i8** %6
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8*, i8** %6
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31, %27, %23
%36 = load i32, i32* @stdout
%37 = call i32 @emit_code(i32 %36, i32 1)
br label %61
38: ; preds = %31
%39 = load i8*, i8** %6
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i8*, i8** %6
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i8*, i8** %6
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %46, %42, %38
%51 = load i32, i32* @stdout
%52 = call i32 @emit_code(i32 %51, i32 0)
br label %60
53: ; preds = %46
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %63
60: ; preds = %50
br label %61
61: ; preds = %60, %35
br label %62
62: ; preds = %61, %20
store i32 0, i32* %3
br label %63
63: ; preds = %62, %53
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [2 x i8] c"h\00"
@.str.1 = [3 x i8] c".h\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [2 x i8] c"c\00"
@.str.4 = [3 x i8] c".c\00"
@.str.5 = [3 x i8] c"-c\00"
@stderr = global i32 0
@.str.6 = [22 x i8] c"Usage: ffgen [-h|-c]\0A\00"
@.str.7 = [22 x i8] c" -h for header file\0A\00"
@.str.8 = [24 x i8] c" -c for C source file\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ null, %2 ]
%9 = tail call i32 (...) @make_primes()
%10 = tail call i32 (...) @make_ff()
%11 = icmp eq i8* %8, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = tail call i32 @emit_code(i32 %13, i32 0)
br label %46
15: ; preds = %7
%16 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21, %18, %15
%25 = load i32, i32* @stdout
%26 = tail call i32 @emit_code(i32 %25, i32 1)
br label %46
27: ; preds = %21
%28 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33, %30, %27
%37 = load i32, i32* @stdout
%38 = tail call i32 @emit_code(i32 %37, i32 0)
br label %46
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%44 = load i32, i32* @stderr
%45 = tail call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %12, %36, %24, %39
%47 = phi i32 [ 1, %39 ], [ 0, %24 ], [ 0, %36 ], [ 0, %12 ]
ret i32 %47
}