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


x86 assembly (clang, -O0):
<createTables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a7 <createTables+0x67>
lea    0xe90(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a2 <createTables+0x62>
lea    0xe6f(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <createTables+0x80>
jmp    11a7 <createTables+0x67>
mov    -0x10(%rbp),%rdi
call   1030 <writeJis@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTables>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1177 <createTables+0x37>
lea    0xe9d(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118b <createTables+0x4b>
mov    %rbx,%rdi
call   1030 <writeJis@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe6e(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
pop    %rbx
ret

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

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