#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ writeTables(int /*<<< orphan*/ *);
int createTables(const char *filename) {
  FILE *file;
  if ((file = fopen(filename, "wb")) == NULL) {
    if ((file = fopen(filename, "wb")) == NULL) {
      perror(filename);
      return 1;
    }
  }
  writeTables(file);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<createTables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a2 <createTables+0x62>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    119d <createTables+0x5d>
mov    -0x10(%rbp),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bb <createTables+0x7b>
jmp    11a2 <createTables+0x62>
mov    -0x18(%rbp),%rdi
call   1060 <writeTables@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTables>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1172 <createTables+0x32>
lea    0xe9e(%rip),%rsi
mov    %r14,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118c <createTables+0x4c>
mov    %rbx,%rdi
call   1060 <writeTables@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
jmp    1184 <createTables+0x44>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
define i32 @createTables(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %16
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 @perror(i8* %13)
store i32 1, i32* %2
br label %21
15: ; preds = %8
br label %16
16: ; preds = %15, %1
%17 = load i32*, i32** %4
%18 = call i32 @writeTables(i32* %17)
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
store i32 0, i32* %2
br label %21
21: ; preds = %16, %12
%22 = load i32, i32* %2
ret i32 %22
}

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