#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 *, ...);
void type_name(FILE *output, int signed_p, int size) {
  if (signed_p) {
    switch (size) {
    case 1:
      fprintf(output, ":int8");
      break;
    case 2:
      fprintf(output, ":int16");
      break;
    case 4:
      fprintf(output, ":int32");
      break;
    case 8:
      fprintf(output, ":int64");
      break;
    default:
      goto error;
    }
  } else {
    switch (size) {
    case 1:
      fprintf(output, ":uint8");
      break;
    case 2:
      fprintf(output, ":uint16");
      break;
    case 4:
      fprintf(output, ":uint32");
      break;
    case 8:
      fprintf(output, ":uint64");
      break;
    default:
      goto error;
    }
  }
  return;
error:
  fprintf(output, "(cl:error \"No type of size ~D.\" %i)\n", size);
}


x86 assembly (clang, -O0):
<type_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11bb <type_name+0xab>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     11b1 <type_name+0xa1>
mov    -0x18(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xee0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b6 <type_name+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b6 <type_name+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b6 <type_name+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b6 <type_name+0xa6>
jmp    124f <type_name+0x13f>
jmp    124a <type_name+0x13a>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x7,%eax
ja     1240 <type_name+0x130>
mov    -0x20(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1245 <type_name+0x135>
mov    -0x8(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1245 <type_name+0x135>
mov    -0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1245 <type_name+0x135>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1245 <type_name+0x135>
jmp    124f <type_name+0x13f>
jmp    124a <type_name+0x13a>
jmp    1264 <type_name+0x154>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type_name>:
mov    %rdi,%rcx
lea    -0x1(%rdx),%eax
test   %esi,%esi
je     1155 <type_name+0x35>
cmp    $0x7,%eax
ja     1173 <type_name+0x53>
lea    0xeca(%rip),%rsi
movslq (%rsi,%rax,4),%rax
add    %rsi,%rax
jmp    *%rax
lea    0xefa(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
cmp    $0x7,%eax
ja     1173 <type_name+0x53>
lea    0xebf(%rip),%rsi
movslq (%rsi,%rax,4),%rax
add    %rsi,%rax
jmp    *%rax
lea    0xeea(%rip),%rdi
jmp    119d <type_name+0x7d>
lea    0xf00(%rip),%rsi
mov    %rcx,%rdi
xor    %eax,%eax
jmp    1030 <fprintf@plt>
lea    0xebb(%rip),%rdi
jmp    119d <type_name+0x7d>
lea    0xeb9(%rip),%rdi
jmp    119d <type_name+0x7d>
lea    0xeb7(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xeaf(%rip),%rdi
jmp    11c5 <type_name+0xa5>
lea    0xeae(%rip),%rdi
jmp    11c5 <type_name+0xa5>
lea    0xead(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
@.str = [6 x i8] c":int8\00"
@.str.1 = [7 x i8] c":int16\00"
@.str.2 = [7 x i8] c":int32\00"
@.str.3 = [7 x i8] c":int64\00"
@.str.4 = [7 x i8] c":uint8\00"
@.str.5 = [8 x i8] c":uint16\00"
@.str.6 = [8 x i8] c":uint32\00"
@.str.7 = [8 x i8] c":uint64\00"
@.str.8 = [37 x i8] c"(cl:error \22No type of size ~D.\22 %i)\0A\00"
define void @type_name(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %3
%10 = load i32, i32* %6
switch i32 %10, label %23 [
i32 1, label %11
i32 2, label %14
i32 4, label %17
i32 8, label %20
]
11: ; preds = %9
%12 = load i32*, i32** %4
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %24
14: ; preds = %9
%15 = load i32*, i32** %4
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %24
17: ; preds = %9
%18 = load i32*, i32** %4
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %24
20: ; preds = %9
%21 = load i32*, i32** %4
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %24
23: ; preds = %9
br label %42
24: ; preds = %20, %17, %14, %11
br label %41
25: ; preds = %3
%26 = load i32, i32* %6
switch i32 %26, label %39 [
i32 1, label %27
i32 2, label %30
i32 4, label %33
i32 8, label %36
]
27: ; preds = %25
%28 = load i32*, i32** %4
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %40
30: ; preds = %25
%31 = load i32*, i32** %4
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %40
33: ; preds = %25
%34 = load i32*, i32** %4
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %40
36: ; preds = %25
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %40
39: ; preds = %25
br label %42
40: ; preds = %36, %33, %30, %27
br label %41
41: ; preds = %40, %24
br label %46
42: ; preds = %39, %23
%43 = load i32*, i32** %4
%44 = load i32, i32* %6
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %42, %41
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c":int8\00"
@.str.1 = [7 x i8] c":int16\00"
@.str.2 = [7 x i8] c":int32\00"
@.str.3 = [7 x i8] c":int64\00"
@.str.4 = [7 x i8] c":uint8\00"
@.str.5 = [8 x i8] c":uint16\00"
@.str.6 = [8 x i8] c":uint32\00"
@.str.7 = [8 x i8] c":uint64\00"
@.str.8 = [37 x i8] c"(cl:error \22No type of size ~D.\22 %i)\0A\00"
define void @type_name(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %14, label %5
5: ; preds = %3
switch i32 %2, label %23 [
i32 1, label %6
i32 2, label %8
i32 4, label %10
i32 8, label %12
]
6: ; preds = %5
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %25
8: ; preds = %5
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %25
10: ; preds = %5
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %25
12: ; preds = %5
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %25
14: ; preds = %3
switch i32 %2, label %23 [
i32 1, label %15
i32 2, label %17
i32 4, label %19
i32 8, label %21
]
15: ; preds = %14
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %25
17: ; preds = %14
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i64 7, i64 1, i32* %0)
br label %25
19: ; preds = %14
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %0)
br label %25
21: ; preds = %14
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 7, i64 1, i32* %0)
br label %25
23: ; preds = %14, %5
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %2)
br label %25
25: ; preds = %12, %10, %8, %6, %21, %19, %17, %15, %23
ret void
}