#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*/ gen_filter_tab(int /*<<< orphan*/ *);
int /*<<< orphan*/ gen_footers(int /*<<< orphan*/ *);
int /*<<< orphan*/ gen_headers(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  FILE *of;
  of = fopen("dsptables.h", "w");
  if (of == NULL) {
    perror("dsptables.h");
    return -1;
  }
  gen_headers(of);
  gen_filter_tab(of);
  gen_footers(of);
  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)
lea    0xe93(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <main+0x50>
lea    0xe71(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <main+0x72>
mov    -0x18(%rbp),%rdi
call   1040 <gen_headers@plt>
mov    -0x18(%rbp),%rdi
call   1030 <gen_filter_tab@plt>
mov    -0x18(%rbp),%rdi
call   1050 <gen_footers@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xead(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1188 <main+0x38>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <gen_headers@plt>
mov    %rbx,%rdi
call   1030 <gen_filter_tab@plt>
mov    %rbx,%rdi
call   1050 <gen_footers@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe71(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"dsptables.h\00"
@.str.1 = [2 x i8] c"w\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 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %19
12: ; preds = %2
%13 = load i32*, i32** %6
%14 = call i32 @gen_headers(i32* %13)
%15 = load i32*, i32** %6
%16 = call i32 @gen_filter_tab(i32* %15)
%17 = load i32*, i32** %6
%18 = call i32 @gen_footers(i32* %17)
store i32 0, i32* %3
br label %19
19: ; preds = %12, %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [12 x i8] c"dsptables.h\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %11
7: ; preds = %2
%8 = tail call i32 @gen_headers(i32* %3)
%9 = tail call i32 @gen_filter_tab(i32* %3)
%10 = tail call i32 @gen_footers(i32* %3)
br label %11
11: ; preds = %7, %5
%12 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %12
}