#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_decomposition(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
void output_decomposition_tables(const char *filename1, const char *filename2,
                                 const char *version) {
  const char *filenames[2];
  FILE *streams[2];
  size_t i;
  filenames[0] = filename1;
  filenames[1] = filename2;
  for (i = 0; i < 2; i++) {
    streams[i] = fopen(filenames[i], "w");
    if (streams[i] == NULL) {
      fprintf(stderr, "cannot open '%s' for writing\n", filenames[i]);
      exit(1);
    }
  }
  for (i = 0; i < 2; i++) {
    FILE *stream = streams[i];
    fprintf(stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
    fprintf(stream, "/* Decomposition of Unicode characters.  */\n");
    fprintf(
        stream,
        "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
        version);
    fprintf(stream, "\n");
  }
  output_decomposition(streams[0], streams[1]);
  for (i = 0; i < 2; i++) {
    if (ferror(streams[i]) || fclose(streams[i])) {
      fprintf(stderr, "error writing to '%s'\n", filenames[i]);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<output_decomposition_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x48(%rbp)
cmpq   $0x2,-0x48(%rbp)
jae    1209 <output_decomposition_tables+0xa9>
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
lea    0xe59(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x48(%rbp),%rax
cmpq   $0x0,-0x40(%rbp,%rax,8)
jne    11f3 <output_decomposition_tables+0x93>
mov    0x2e11(%rip),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11f8 <output_decomposition_tables+0x98>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    118c <output_decomposition_tables+0x2c>
movq   $0x0,-0x48(%rbp)
cmpq   $0x2,-0x48(%rbp)
jae    1286 <output_decomposition_tables+0x126>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1211 <output_decomposition_tables+0xb1>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <output_decomposition@plt>
movq   $0x0,-0x48(%rbp)
cmpq   $0x2,-0x48(%rbp)
jae    1317 <output_decomposition_tables+0x1b7>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    12d6 <output_decomposition_tables+0x176>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1301 <output_decomposition_tables+0x1a1>
mov    0x2d03(%rip),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1306 <output_decomposition_tables+0x1a6>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    129b <output_decomposition_tables+0x13b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_decomposition_tables>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rdi,(%rsp)
mov    %rsi,0x8(%rsp)
lea    0xe59(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12cc <output_decomposition_tables+0x14c>
mov    %rax,%r12
lea    0xe41(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
mov    %rbp,%rbx
test   %rax,%rax
je     12cc <output_decomposition_tables+0x14c>
mov    %rax,%r14
lea    0xe43(%rip),%rbx
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r12,%rcx
call   10a0 <fwrite@plt>
lea    0xe54(%rip),%r13
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r12,%rcx
call   10a0 <fwrite@plt>
lea    0xe65(%rip),%rbp
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <output_decomposition@plt>
mov    %r12,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    12e2 <output_decomposition_tables+0x162>
mov    %r12,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    12e2 <output_decomposition_tables+0x162>
mov    %r14,%rdi
call   1030 <ferror@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    12e4 <output_decomposition_tables+0x164>
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    12e4 <output_decomposition_tables+0x164>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d0d(%rip),%rax
mov    (%rax),%rdi
lea    0xd25(%rip),%rsi
mov    %rbx,%rdx
jmp    12f9 <output_decomposition_tables+0x179>
xor    %ebx,%ebx
mov    0x2cf5(%rip),%rax
mov    (%rax),%rdi
mov    (%rsp,%rbx,8),%rdx
lea    0xdc5(%rip),%rsi
xor    %eax,%eax
call   1060 <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 = [45 x i8] c"/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\0A\00"
@.str.3 = [45 x i8] c"/* Decomposition of Unicode characters. */\0A\00"
@.str.4 = [68 x i8] c"/* Generated automatically by gen-uni-tables.c for Unicode %s. */\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [23 x i8] c"error writing to '%s'\0A\00"
define void @output_decomposition_tables(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [2 x i8*]
%8 = alloca [2 x i32*]
%9 = alloca i64
%10 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%11 = load i8*, i8** %4
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* %11, i8** %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 1
store i8* %13, i8** %14
store i64 0, i64* %9
br label %15
15: ; preds = %37, %3
%16 = load i64, i64* %9
%17 = icmp ult i64 %16, 2
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = load i64, i64* %9
%20 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = load i64, i64* %9
%24 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %23
store i32* %22, i32** %24
%25 = load i64, i64* %9
%26 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %25
%27 = load i32*, i32** %26
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %36
29: ; preds = %18
%30 = load i32*, i32** @stderr
%31 = load i64, i64* %9
%32 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %18
br label %37
37: ; preds = %36
%38 = load i64, i64* %9
%39 = add i64 %38, 1
store i64 %39, i64* %9
br label %15
40: ; preds = %15
store i64 0, i64* %9
br label %41
41: ; preds = %57, %40
%42 = load i64, i64* %9
%43 = icmp ult i64 %42, 2
br i1 %43, label %44, label %60
44: ; preds = %41
%45 = load i64, i64* %9
%46 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %45
%47 = load i32*, i32** %46
store i32* %47, i32** %10
%48 = load i32*, i32** %10
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32*, i32** %10
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32*, i32** %10
%53 = load i8*, i8** %6
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = load i32*, i32** %10
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %44
%58 = load i64, i64* %9
%59 = add i64 %58, 1
store i64 %59, i64* %9
br label %41
60: ; preds = %41
%61 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 0
%62 = load i32*, i32** %61
%63 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 1
%64 = load i32*, i32** %63
%65 = call i32 @output_decomposition(i32* %62, i32* %64)
store i64 0, i64* %9
br label %66
66: ; preds = %89, %60
%67 = load i64, i64* %9
%68 = icmp ult i64 %67, 2
br i1 %68, label %69, label %92
69: ; preds = %66
%70 = load i64, i64* %9
%71 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %70
%72 = load i32*, i32** %71
%73 = call i64 @ferror(i32* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %81, label %75
75: ; preds = %69
%76 = load i64, i64* %9
%77 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %76
%78 = load i32*, i32** %77
%79 = call i64 @fclose(i32* %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %88
81: ; preds = %75, %69
%82 = load i32*, i32** @stderr
%83 = load i64, i64* %9
%84 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %85)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %75
br label %89
89: ; preds = %88
%90 = load i64, i64* %9
%91 = add i64 %90, 1
store i64 %91, i64* %9
br label %66
92: ; preds = %66
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 = [45 x i8] c"/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\0A\00"
@.str.3 = [45 x i8] c"/* Decomposition of Unicode characters. */\0A\00"
@.str.4 = [68 x i8] c"/* Generated automatically by gen-uni-tables.c for Unicode %s. */\0A\00"
@.str.6 = [23 x i8] c"error writing to '%s'\0A\00"
define void @output_decomposition_tables(i8* %0, i8* %1, i8* %2) {
%4 = alloca [2 x i8*]
%5 = bitcast [2 x i8*]* %4 to i8*
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* %0, i8** %6
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
store i8* %1, i8** %7
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %25, label %10
10: ; preds = %3
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i64 44, i64 1, i32* %8)
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i64 44, i64 1, i32* %8)
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%17 = tail call i32 @fputc(i32 10, i32* %8)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i64 44, i64 1, i32* %11)
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i64 44, i64 1, i32* %11)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%21 = tail call i32 @fputc(i32 10, i32* %11)
%22 = tail call i32 @output_decomposition(i32* %8, i32* %11)
%23 = tail call i64 @ferror(i32* %8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %33
25: ; preds = %10, %3
%26 = phi i8* [ %0, %3 ], [ %1, %10 ]
%27 = load i32*, i32** @stderr
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %13
%31 = tail call i64 @fclose(i32* %8)
%32 = icmp eq i64 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %43, %40, %30, %13
%34 = phi i64 [ 0, %30 ], [ 0, %13 ], [ 1, %40 ], [ 1, %43 ]
%35 = load i32*, i32** @stderr
%36 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 %34
%37 = load i8*, i8** %36
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %30
%41 = tail call i64 @ferror(i32* %11)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %33
43: ; preds = %40
%44 = tail call i64 @fclose(i32* %11)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %33
46: ; preds = %43
ret void
}