#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*/ UErrorCode;
typedef int UChar32;

/* Variables and functions */
int /*<<< orphan*/ U_IS_UNICODE_CHAR(int);
int /*<<< orphan*/ U_ZERO_ERROR;
scalar_t__ normalize(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ ucs2utf(int, unsigned char *);
int /*<<< orphan*/ unorm2_getNFCInstance(int /*<<< orphan*/ *);
int /*<<< orphan*/ unorm2_getNFDInstance(int /*<<< orphan*/ *);
void ccdump(void) {
  UChar32 ch;
  char str[7], nfd[0x100], nfc[0x100];
  for (ch = 1; ch < 0x110000; ch++) {
    UErrorCode error_code = U_ZERO_ERROR;
    if (!U_IS_UNICODE_CHAR(ch)) {
      continue;
    }
    ucs2utf(ch, (unsigned char *)str);
    if (normalize(str, nfd, unorm2_getNFDInstance(&error_code))) {
      printf("ch=%04x error occure\n", ch);
      continue;
    }
    if (normalize(str, nfc, unorm2_getNFCInstance(&error_code))) {
      printf("ch=%04x error occure\n", ch);
      continue;
    }
    if (strcmp(nfd, nfc)) {
      printf("%04x\t%s\t%s\n", ch, nfd, nfc);
    }
  }
}


x86 assembly (clang, -O0):
<ccdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x110000,-0x4(%rbp)
jge    12c3 <ccdump+0x153>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x214(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <U_IS_UNICODE_CHAR@plt>
cmp    $0x0,%eax
jne    11b4 <ccdump+0x44>
jmp    12b5 <ccdump+0x145>
mov    -0x4(%rbp),%edi
lea    -0xb(%rbp),%rsi
call   1030 <ucs2utf@plt>
lea    -0xb(%rbp),%rax
mov    %rax,-0x228(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x220(%rbp)
lea    -0x214(%rbp),%rdi
call   1090 <unorm2_getNFDInstance@plt>
mov    -0x228(%rbp),%rdi
mov    -0x220(%rbp),%rsi
mov    %eax,%edx
call   1050 <normalize@plt>
cmp    $0x0,%rax
je     121a <ccdump+0xaa>
mov    -0x4(%rbp),%esi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b5 <ccdump+0x145>
lea    -0xb(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x230(%rbp)
lea    -0x214(%rbp),%rdi
call   1070 <unorm2_getNFCInstance@plt>
mov    -0x238(%rbp),%rdi
mov    -0x230(%rbp),%rsi
mov    %eax,%edx
call   1050 <normalize@plt>
cmp    $0x0,%rax
je     1274 <ccdump+0x104>
mov    -0x4(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b5 <ccdump+0x145>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12b0 <ccdump+0x140>
mov    -0x4(%rbp),%esi
lea    -0x110(%rbp),%rdx
lea    -0x210(%rbp),%rcx
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b5 <ccdump+0x145>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1182 <ccdump+0x12>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    $0x1,%ebx
mov    0x2e5b(%rip),%r14
lea    0x9(%rsp),%rbp
lea    0x4(%rsp),%r15
lea    0x110(%rsp),%r13
lea    0xe5a(%rip),%r12
jmp    11cb <ccdump+0x5b>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x110000,%ebx
je     1272 <ccdump+0x102>
mov    (%r14),%eax
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
call   1080 <U_IS_UNICODE_CHAR@plt>
test   %eax,%eax
je     11bc <ccdump+0x4c>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1030 <ucs2utf@plt>
mov    %r15,%rdi
call   1090 <unorm2_getNFDInstance@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <normalize@plt>
test   %rax,%rax
jne    11b0 <ccdump+0x40>
mov    %r15,%rdi
call   1070 <unorm2_getNFCInstance@plt>
mov    %rbp,%r15
mov    %rbp,%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <normalize@plt>
test   %rax,%rax
je     1239 <ccdump+0xc9>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rbp
lea    0x4(%rsp),%r15
jmp    11bc <ccdump+0x4c>
mov    %rbp,%rsi
mov    %r13,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    %r15,%rbp
lea    0x4(%rsp),%r15
je     11bc <ccdump+0x4c>
lea    0xdba(%rip),%rdi
mov    %ebx,%esi
mov    %r13,%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bc <ccdump+0x4c>
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@U_ZERO_ERROR = global i32 0
@.str = [22 x i8] c"ch=%04x error occure\0A\00"
@.str.1 = [12 x i8] c"%04x\09%s\09%s\0A\00"
define void @ccdump() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i32
store i32 1, i32* %1
br label %6
6: ; preds = %47, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1114112
br i1 %8, label %9, label %50
9: ; preds = %6
%10 = load i32, i32* @U_ZERO_ERROR
store i32 %10, i32* %5
%11 = load i32, i32* %1
%12 = call i32 @U_IS_UNICODE_CHAR(i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
br label %47
15: ; preds = %9
%16 = load i32, i32* %1
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%18 = call i32 @ucs2utf(i32 %16, i8* %17)
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = call i32 @unorm2_getNFDInstance(i32* %5)
%22 = call i64 @normalize(i8* %19, i8* %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = load i32, i32* %1
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %47
27: ; preds = %15
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%30 = call i32 @unorm2_getNFCInstance(i32* %5)
%31 = call i64 @normalize(i8* %28, i8* %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %1
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %47
36: ; preds = %27
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* %1
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %42, i8* %43, i8* %44)
br label %46
46: ; preds = %41, %36
br label %47
47: ; preds = %46, %33, %24, %14
%48 = load i32, i32* %1
%49 = add nsw i32 %48, 1
store i32 %49, i32* %1
br label %6
50: ; preds = %6
ret void
}

LLVM IR (-O2):
@U_ZERO_ERROR = global i32 0
@.str = [22 x i8] c"ch=%04x error occure\0A\00"
@.str.1 = [12 x i8] c"%04x\09%s\09%s\0A\00"
define void @ccdump() {
%1 = alloca [7 x i8]
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %0, %32
%10 = phi i32 [ 1, %0 ], [ %33, %32 ]
%11 = load i32, i32* @U_ZERO_ERROR
store i32 %11, i32* %4
%12 = call i32 @U_IS_UNICODE_CHAR(i32 %10)
%13 = icmp eq i32 %12, 0
br i1 %13, label %32, label %14
14: ; preds = %9
%15 = call i32 @ucs2utf(i32 %10, i8* %5)
%16 = call i32 @unorm2_getNFDInstance(i32* %4)
%17 = call i64 @normalize(i8* %5, i8* %6, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %32
21: ; preds = %14
%22 = call i32 @unorm2_getNFCInstance(i32* %4)
%23 = call i64 @normalize(i8* %5, i8* %7, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %32
27: ; preds = %21
%28 = call i64 @strcmp(i8* %6, i8* %7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %6, i8* %7)
br label %32
32: ; preds = %27, %30, %9, %25, %19
%33 = add nuw nsw i32 %10, 1
%34 = icmp eq i32 %33, 1114112
br i1 %34, label %35, label %9
35: ; preds = %32
ret void
}