#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 strlen(char *);
char tolower(char);
int get_type(char *type, char *result) {
  char c1, c2;
  if (strlen(type) != 2)
    return 0;
  c1 = tolower(*type);
  c2 = tolower(type[1]);
  switch (c1) {
  case 'i':
    switch (c2) {
    case '1':
      *result = 'b';
      return 1;
    case '2':
      *result = 's';
      return 1;
    case '4':
      *result = 'i';
      return 1;
    }
    return 0;
  case 'r':
    switch (c2) {
    case '4':
      *result = 'f';
      return 1;
    case '8':
      *result = 'd';
      return 1;
    }
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
je     114e <get_type+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    126e <get_type+0x14e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <tolower@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x69,%eax
je     1193 <get_type+0x73>
jmp    1182 <get_type+0x62>
mov    -0x20(%rbp),%eax
sub    $0x72,%eax
je     120f <get_type+0xef>
jmp    1267 <get_type+0x147>
movsbl -0x1a(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x31,%eax
je     11ca <get_type+0xaa>
jmp    11a8 <get_type+0x88>
mov    -0x24(%rbp),%eax
sub    $0x32,%eax
je     11dd <get_type+0xbd>
jmp    11b9 <get_type+0x99>
mov    -0x24(%rbp),%eax
sub    $0x34,%eax
je     11f0 <get_type+0xd0>
jmp    1203 <get_type+0xe3>
mov    -0x18(%rbp),%rax
movb   $0x62,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    126e <get_type+0x14e>
mov    -0x18(%rbp),%rax
movb   $0x73,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    126e <get_type+0x14e>
mov    -0x18(%rbp),%rax
movb   $0x69,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    126e <get_type+0x14e>
movl   $0x0,-0x4(%rbp)
jmp    126e <get_type+0x14e>
movsbl -0x1a(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x34,%eax
je     1235 <get_type+0x115>
jmp    1224 <get_type+0x104>
mov    -0x28(%rbp),%eax
sub    $0x38,%eax
je     1248 <get_type+0x128>
jmp    125b <get_type+0x13b>
mov    -0x18(%rbp),%rax
movb   $0x66,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    126e <get_type+0x14e>
mov    -0x18(%rbp),%rax
movb   $0x64,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    126e <get_type+0x14e>
movl   $0x0,-0x4(%rbp)
jmp    126e <get_type+0x14e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
jne    1194 <get_type+0x74>
movsbl (%rbx),%edi
call   1040 <tolower@plt>
mov    %eax,%r15d
movsbl 0x1(%rbx),%edi
call   1040 <tolower@plt>
movsbl %r15b,%ecx
cmp    $0x72,%ecx
je     1171 <get_type+0x51>
cmp    $0x69,%ecx
jne    1194 <get_type+0x74>
movsbl %al,%eax
cmp    $0x31,%eax
je     1186 <get_type+0x66>
cmp    $0x34,%eax
je     118a <get_type+0x6a>
cmp    $0x32,%eax
jne    1194 <get_type+0x74>
mov    $0x73,%al
jmp    118c <get_type+0x6c>
movsbl %al,%eax
cmp    $0x34,%eax
je     1182 <get_type+0x62>
cmp    $0x38,%eax
jne    1194 <get_type+0x74>
mov    $0x64,%al
jmp    118c <get_type+0x6c>
mov    $0x66,%al
jmp    118c <get_type+0x6c>
mov    $0x62,%al
jmp    118c <get_type+0x6c>
mov    $0x69,%al
mov    %al,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_type(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %41
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = call signext i8 @tolower(i8 signext %14)
store i8 %15, i8* %6
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
store i8 %19, i8* %7
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
switch i32 %21, label %40 [
i32 105, label %22
i32 114, label %32
]
22: ; preds = %12
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
switch i32 %24, label %31 [
i32 49, label %25
i32 50, label %27
i32 52, label %29
]
25: ; preds = %22
%26 = load i8*, i8** %5
store i8 98, i8* %26
store i32 1, i32* %3
br label %41
27: ; preds = %22
%28 = load i8*, i8** %5
store i8 115, i8* %28
store i32 1, i32* %3
br label %41
29: ; preds = %22
%30 = load i8*, i8** %5
store i8 105, i8* %30
store i32 1, i32* %3
br label %41
31: ; preds = %22
store i32 0, i32* %3
br label %41
32: ; preds = %12
%33 = load i8, i8* %7
%34 = sext i8 %33 to i32
switch i32 %34, label %39 [
i32 52, label %35
i32 56, label %37
]
35: ; preds = %32
%36 = load i8*, i8** %5
store i8 102, i8* %36
store i32 1, i32* %3
br label %41
37: ; preds = %32
%38 = load i8*, i8** %5
store i8 100, i8* %38
store i32 1, i32* %3
br label %41
39: ; preds = %32
store i32 0, i32* %3
br label %41
40: ; preds = %12
store i32 0, i32* %3
br label %41
41: ; preds = %40, %39, %37, %35, %31, %29, %27, %25, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @get_type(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 2
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = load i8, i8* %0
%7 = tail call signext i8 @tolower(i8 signext %6)
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call signext i8 @tolower(i8 signext %9)
%11 = sext i8 %7 to i32
switch i32 %11, label %21 [
i32 105, label %12
i32 114, label %16
]
12: ; preds = %5
%13 = sext i8 %10 to i32
switch i32 %13, label %21 [
i32 49, label %19
i32 50, label %14
i32 52, label %15
]
14: ; preds = %12
br label %19
15: ; preds = %12
br label %19
16: ; preds = %5
%17 = sext i8 %10 to i32
switch i32 %17, label %21 [
i32 52, label %19
i32 56, label %18
]
18: ; preds = %16
br label %19
19: ; preds = %16, %12, %14, %15, %18
%20 = phi i8 [ 100, %18 ], [ 105, %15 ], [ 115, %14 ], [ 98, %12 ], [ 102, %16 ]
store i8 %20, i8* %1
br label %21
21: ; preds = %19, %5, %16, %12, %2
%22 = phi i32 [ 0, %2 ], [ 0, %12 ], [ 0, %16 ], [ 0, %5 ], [ 1, %19 ]
ret i32 %22
}