#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*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ output_lbp(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
void output_tables(const char *filename, const char *version) {
  FILE *stream;
  stream = fopen(filename, "w");
  if (stream == NULL) {
    fprintf(stderr, "cannot open '%s' for writing\n", filename);
    exit(1);
  }
  fprintf(stream, "/* Line breaking properties of Unicode characters.  */\n");
  fprintf(stream,
          "/* Generated automatically by gen-lbrkprop for Unicode %s.  */\n",
          version);
  fprintf(stream, "\n");
  output_lbp(stream);
  if (ferror(stream) || fclose(stream)) {
    fprintf(stderr, "error writing to '%s'\n", filename);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<output_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <output_tables+0x55>
mov    0x2e4a(%rip),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <output_lbp@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    121e <output_tables+0xbe>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1244 <output_tables+0xe4>
mov    0x2dbb(%rip),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_tables>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1214 <output_tables+0x94>
mov    %rax,%rbx
lea    0xe7a(%rip),%rdi
mov    $0x37,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1050 <output_lbp@plt>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1201 <output_tables+0x81>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    1201 <output_tables+0x81>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dd8(%rip),%rax
mov    (%rax),%rdi
lea    0xe86(%rip),%rsi
jmp    1225 <output_tables+0xa5>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdi
lea    0xddd(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [56 x i8] c"/* Line breaking properties of Unicode characters. */\0A\00"
@.str.3 = [64 x i8] c"/* Generated automatically by gen-lbrkprop for Unicode %s. */\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [23 x i8] c"error writing to '%s'\0A\00"
define void @output_tables(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32*, i32** @stderr
%12 = load i8*, i8** %3
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32*, i32** %5
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32*, i32** %5
%19 = load i8*, i8** %4
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i32*, i32** %5
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32*, i32** %5
%24 = call i32 @output_lbp(i32* %23)
%25 = load i32*, i32** %5
%26 = call i64 @ferror(i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %15
%29 = load i32*, i32** %5
%30 = call i64 @fclose(i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28, %15
%33 = load i32*, i32** @stderr
%34 = load i8*, i8** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %28
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [56 x i8] c"/* Line breaking properties of Unicode characters. */\0A\00"
@.str.3 = [64 x i8] c"/* Generated automatically by gen-lbrkprop for Unicode %s. */\0A\00"
@.str.5 = [23 x i8] c"error writing to '%s'\0A\00"
define void @output_tables(i8* %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32*, i32** @stderr
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 55, i64 1, i32* %3)
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%12 = tail call i32 @fputc(i32 10, i32* %3)
%13 = tail call i32 @output_lbp(i32* %3)
%14 = tail call i64 @ferror(i32* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = tail call i64 @fclose(i32* %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16, %9
%20 = load i32*, i32** @stderr
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %16
ret void
}