#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *ucs_symbol(unsigned int);
void output_charmap(FILE *stream, const char *mapname,
                    unsigned int (*func)(unsigned int)) {
  char table[0x110000];
  unsigned int i;
  bool need_semicolon;
  const int max_column = 75;
  int column;
  for (i = 0; i < 0x110000; i++)
    table[i] = (func(i) != i);
  fprintf(stream, "%s ", mapname);
  need_semicolon = false;
  column = 1000;
  for (i = 0; i < 0x110000; i++)
    if (table[i]) {
      char buf[25 + 1];
      strcpy(buf, "(");
      strcat(buf, ucs_symbol(i));
      strcat(buf, ",");
      strcat(buf, ucs_symbol(func(i)));
      strcat(buf, ")");
      if (need_semicolon) {
        fprintf(stream, ";");
        column++;
      }
      if (column + strlen(buf) > max_column) {
        fprintf(stream, "/\n   ");
        column = 3;
      }
      fprintf(stream, "%s", buf);
      column += strlen(buf);
      need_semicolon = true;
    }
  fprintf(stream, "\n");
}


x86 assembly (clang, -O0):
<output_charmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110070,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x4b,-0x11002c(%rbp)
movl   $0x0,-0x110024(%rbp)
cmpl   $0x110000,-0x110024(%rbp)
jae    11c8 <output_charmap+0x78>
mov    -0x18(%rbp),%rax
mov    -0x110024(%rbp),%edi
call   *%rax
cmp    -0x110024(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,%cl
mov    -0x110024(%rbp),%eax
mov    %cl,-0x110020(%rbp,%rax,1)
mov    -0x110024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110024(%rbp)
jmp    117b <output_charmap+0x2b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x110028(%rbp)
movl   $0x3e8,-0x110030(%rbp)
movl   $0x0,-0x110024(%rbp)
cmpl   $0x110000,-0x110024(%rbp)
jae    137a <output_charmap+0x22a>
mov    -0x110024(%rbp),%eax
cmpb   $0x0,-0x110020(%rbp,%rax,1)
je     1361 <output_charmap+0x211>
lea    -0x110050(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110050(%rbp),%rax
mov    %rax,-0x110060(%rbp)
mov    -0x110024(%rbp),%edi
call   1040 <ucs_symbol@plt>
mov    -0x110060(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
lea    -0x110050(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x110050(%rbp),%rax
mov    %rax,-0x110058(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x110024(%rbp),%edi
call   *%rax
mov    %eax,%edi
call   1040 <ucs_symbol@plt>
mov    -0x110058(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
lea    -0x110050(%rbp),%rdi
lea    0xd5c(%rip),%rsi
call   1070 <strcat@plt>
cmpl   $0x0,-0x110028(%rbp)
je     12df <output_charmap+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x110030(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110030(%rbp)
mov    -0x110030(%rbp),%eax
mov    %eax,-0x110064(%rbp)
lea    -0x110050(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x110064(%rbp),%eax
add    %ecx,%eax
cmp    $0x4b,%eax
jle    1326 <output_charmap+0x1d6>
mov    -0x8(%rbp),%rdi
lea    0xcf7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x3,-0x110030(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x110050(%rbp),%rdx
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x110050(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x110030(%rbp),%eax
mov    %eax,-0x110030(%rbp)
movl   $0x1,-0x110028(%rbp)
jmp    1366 <output_charmap+0x216>
mov    -0x110024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110024(%rbp)
jmp    11fc <output_charmap+0xac>
mov    -0x8(%rbp),%rdi
lea    0xc90(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0x110070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_charmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x110028,%rsp
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   *%r15
mov    %eax,%eax
cmp    %rax,%rbx
setne  0x20(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x110000,%rbx
jne    11a0 <output_charmap+0x20>
lea    0xe3d(%rip),%rsi
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x3e8,%ebp
mov    %rsp,%r13
xor    %r12d,%r12d
jmp    120c <output_charmap+0x8c>
nop
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <fputs@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
add    %eax,%ebp
mov    $0x1,%r12d
add    $0x1,%rbx
cmp    $0x110000,%rbx
je     12b4 <output_charmap+0x134>
cmpb   $0x0,0x20(%rsp,%rbx,1)
je     11fb <output_charmap+0x7b>
mov    %r13,%rdi
lea    0xde7(%rip),%rsi
call   1030 <strcpy@plt>
mov    %ebx,%edi
call   1040 <ucs_symbol@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
mov    %r13,%rdi
lea    0xdc8(%rip),%rsi
call   1090 <strcat@plt>
mov    %ebx,%edi
call   *%r15
mov    %eax,%edi
call   1040 <ucs_symbol@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
mov    %r13,%rdi
lea    0xda4(%rip),%rsi
call   1090 <strcat@plt>
test   %r12d,%r12d
je     127e <output_charmap+0xfe>
mov    $0x3b,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
add    $0x1,%ebp
mov    %r13,%rdi
call   1050 <strlen@plt>
add    %ebp,%eax
cmp    $0x4c,%eax
jl     11e0 <output_charmap+0x60>
mov    $0x5,%esi
mov    $0x1,%edx
lea    0xd68(%rip),%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    $0x3,%ebp
jmp    11e0 <output_charmap+0x60>
mov    $0xa,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
add    $0x110028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c")\00"
@.str.4 = [2 x i8] c";\00"
@.str.5 = [6 x i8] c"/\0A \00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @output_charmap(i32* %0, i8* %1, i32 (i32)* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32 (i32)*
%7 = alloca [1114112 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [26 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 (i32)* %2, i32 (i32)** %6
store i32 75, i32* %10
store i32 0, i32* %8
br label %13
13: ; preds = %27, %3
%14 = load i32, i32* %8
%15 = icmp ult i32 %14, 1114112
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i32 (i32)*, i32 (i32)** %6
%18 = load i32, i32* %8
%19 = call i32 %17(i32 %18)
%20 = load i32, i32* %8
%21 = icmp ne i32 %19, %20
%22 = zext i1 %21 to i32
%23 = trunc i32 %22 to i8
%24 = load i32, i32* %8
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [1114112 x i8], [1114112 x i8]* %7, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %16
%28 = load i32, i32* %8
%29 = add i32 %28, 1
store i32 %29, i32* %8
br label %13
30: ; preds = %13
%31 = load i32*, i32** %4
%32 = load i8*, i8** %5
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
store i32 0, i32* %9
store i32 1000, i32* %11
store i32 0, i32* %8
br label %34
34: ; preds = %85, %30
%35 = load i32, i32* %8
%36 = icmp ult i32 %35, 1114112
br i1 %36, label %37, label %88
37: ; preds = %34
%38 = load i32, i32* %8
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [1114112 x i8], [1114112 x i8]* %7, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %84
43: ; preds = %37
%44 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%47 = load i32, i32* %8
%48 = call i8* @ucs_symbol(i32 %47)
%49 = call i32 @strcat(i8* %46, i8* %48)
%50 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%53 = load i32 (i32)*, i32 (i32)** %6
%54 = load i32, i32* %8
%55 = call i32 %53(i32 %54)
%56 = call i8* @ucs_symbol(i32 %55)
%57 = call i32 @strcat(i8* %52, i8* %56)
%58 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%59 = call i32 @strcat(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32, i32* %9
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %43
%63 = load i32*, i32** %4
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
br label %67
67: ; preds = %62, %43
%68 = load i32, i32* %11
%69 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%70 = call i32 @strlen(i8* %69)
%71 = add nsw i32 %68, %70
%72 = icmp sgt i32 %71, 75
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = load i32*, i32** %4
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %11
br label %76
76: ; preds = %73, %67
%77 = load i32*, i32** %4
%78 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %78)
%80 = getelementptr inbounds [26 x i8], [26 x i8]* %12, i64 0, i64 0
%81 = call i32 @strlen(i8* %80)
%82 = load i32, i32* %11
%83 = add nsw i32 %82, %81
store i32 %83, i32* %11
store i32 1, i32* %9
br label %84
84: ; preds = %76, %37
br label %85
85: ; preds = %84
%86 = load i32, i32* %8
%87 = add i32 %86, 1
store i32 %87, i32* %8
br label %34
88: ; preds = %34
%89 = load i32*, i32** %4
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c")\00"
@.str.5 = [6 x i8] c"/\0A \00"
define void @output_charmap(i32* nocapture %0, i8* %1, i32 (i32)* nocapture %2) {
%4 = alloca [1114112 x i8]
%5 = alloca [26 x i8]
%6 = getelementptr inbounds [1114112 x i8], [1114112 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %3, %7
%8 = phi i64 [ 0, %3 ], [ %15, %7 ]
%9 = trunc i64 %8 to i32
%10 = tail call i32 %2(i32 %9)
%11 = zext i32 %10 to i64
%12 = icmp ne i64 %8, %11
%13 = zext i1 %12 to i8
%14 = getelementptr inbounds [1114112 x i8], [1114112 x i8]* %4, i64 0, i64 %8
store i8 %13, i8* %14
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, 1114112
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%19 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
br label %20
20: ; preds = %17, %53
%21 = phi i64 [ 0, %17 ], [ %56, %53 ]
%22 = phi i32 [ 1000, %17 ], [ %55, %53 ]
%23 = phi i32 [ 0, %17 ], [ %54, %53 ]
%24 = getelementptr inbounds [1114112 x i8], [1114112 x i8]* %4, i64 0, i64 %21
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %53, label %27
27: ; preds = %20
%28 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = trunc i64 %21 to i32
%30 = call i8* @ucs_symbol(i32 %29)
%31 = call i32 @strcat(i8* %19, i8* %30)
%32 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 %2(i32 %29)
%34 = call i8* @ucs_symbol(i32 %33)
%35 = call i32 @strcat(i8* %19, i8* %34)
%36 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i32 %23, 0
br i1 %37, label %41, label %38
38: ; preds = %27
%39 = call i32 @fputc(i32 59, i32* %0)
%40 = add nsw i32 %22, 1
br label %41
41: ; preds = %38, %27
%42 = phi i32 [ %40, %38 ], [ %22, %27 ]
%43 = call i32 @strlen(i8* %19)
%44 = add nsw i32 %43, %42
%45 = icmp sgt i32 %44, 75
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %48
48: ; preds = %46, %41
%49 = phi i32 [ 3, %46 ], [ %42, %41 ]
%50 = call i32 @fputs(i8* %19, i32* %0)
%51 = call i32 @strlen(i8* %19)
%52 = add nsw i32 %51, %49
br label %53
53: ; preds = %20, %48
%54 = phi i32 [ 1, %48 ], [ %23, %20 ]
%55 = phi i32 [ %52, %48 ], [ %22, %20 ]
%56 = add nuw nsw i64 %21, 1
%57 = icmp eq i64 %56, 1114112
br i1 %57, label %58, label %20
58: ; preds = %53
%59 = call i32 @fputc(i32 10, i32* %0)
ret void
}