#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 */

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *findformat(char *type) {
  if (!strcmp(type, "char")) {
    return "hh";
  } else if (!strcmp(type, "short")) {
    return "h";
  } else if (!strcmp(type, "int")) {
    return "";
  } else if (!strcmp(type, "long long")) {
    return "ll";
  } else if (!strcmp(type, "long")) {
    return "l";
  } else {
    fprintf(stderr, "*** I don't understand type %s!\n", type);
    abort();
    return 0;
  }
}


x86 assembly (clang, -O0):
<findformat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1165 <findformat+0x35>
lea    0xea9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <findformat+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118e <findformat+0x5e>
lea    0xe81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <findformat+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <findformat+0x87>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <findformat+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e0 <findformat+0xb0>
lea    0xe45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <findformat+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1209 <findformat+0xd9>
lea    0xe1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <findformat+0xf9>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe02(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findformat>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1199 <findformat+0x69>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a2 <findformat+0x72>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ab <findformat+0x7b>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b4 <findformat+0x84>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11bd <findformat+0x8d>
lea    0xe86(%rip),%rax
pop    %rbx
ret
lea    0xe65(%rip),%rax
pop    %rbx
ret
lea    0xe5d(%rip),%rax
pop    %rbx
ret
lea    0xe8d(%rip),%rax
pop    %rbx
ret
lea    0xe61(%rip),%rax
pop    %rbx
ret
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"char\00"
@.str.1 = [3 x i8] c"hh\00"
@.str.2 = [6 x i8] c"short\00"
@.str.3 = [2 x i8] c"h\00"
@.str.4 = [4 x i8] c"int\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [10 x i8] c"long long\00"
@.str.7 = [3 x i8] c"ll\00"
@.str.8 = [5 x i8] c"long\00"
@.str.9 = [2 x i8] c"l\00"
@stderr = global i32 0
@.str.10 = [33 x i8] c"*** I don't understand type %s!\0A\00"
define i8* @findformat(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %33
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %33
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %33
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %33
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %33
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %3
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %30)
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %27, %22, %17, %12, %7
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@.str = [5 x i8] c"char\00"
@.str.1 = [3 x i8] c"hh\00"
@.str.2 = [6 x i8] c"short\00"
@.str.3 = [2 x i8] c"h\00"
@.str.4 = [4 x i8] c"int\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [10 x i8] c"long long\00"
@.str.7 = [3 x i8] c"ll\00"
@.str.8 = [5 x i8] c"long\00"
@.str.9 = [2 x i8] c"l\00"
@stderr = global i32 0
@.str.10 = [33 x i8] c"*** I don't understand type %s!\0A\00"
define i8* @findformat(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%19 = tail call i32 (...) @abort()
unreachable
20: ; preds = %13, %10, %7, %4, %1
%21 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %13 ]
ret i8* %21
}