#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 const *);
int get_type(const char *type) {
  if (type == NULL)
    return -1;
  int len = strlen(type);
  if (len == 0)
    return -1;
  switch (type[0]) {
  case 'I':
    return 1;
  case 'A':
    return 2;
  case 'L':
    if (len < 3)
      return -1;
    if (type[2] == '7')
      return 3;
    if (type[2] == '8')
      return 4;
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <get_type+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1155 <get_type+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x41,%eax
je     119b <get_type+0x8b>
jmp    116d <get_type+0x5d>
mov    -0x18(%rbp),%eax
sub    $0x49,%eax
je     118f <get_type+0x7f>
jmp    117e <get_type+0x6e>
mov    -0x18(%rbp),%eax
sub    $0x4c,%eax
je     11a7 <get_type+0x97>
jmp    11fc <get_type+0xec>
movl   $0x1,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
movl   $0x2,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
cmpl   $0x3,-0x14(%rbp)
jge    11bd <get_type+0xad>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x37,%eax
jne    11da <get_type+0xca>
movl   $0x3,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x38,%eax
jne    11f7 <get_type+0xe7>
movl   $0x4,-0x4(%rbp)
jmp    1203 <get_type+0xf3>
jmp    11fc <get_type+0xec>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1168 <get_type+0x58>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     1168 <get_type+0x58>
movsbl (%rbx),%ecx
cmp    $0x4c,%ecx
je     1149 <get_type+0x39>
cmp    $0x49,%ecx
je     1142 <get_type+0x32>
cmp    $0x41,%ecx
jne    1168 <get_type+0x58>
mov    $0x2,%ebp
jmp    1168 <get_type+0x58>
mov    $0x1,%ebp
jmp    1168 <get_type+0x58>
cmp    $0x3,%eax
jl     1168 <get_type+0x58>
mov    0x2(%rbx),%al
xor    %ecx,%ecx
cmp    $0x38,%al
sete   %cl
lea    (%rcx,%rcx,4),%ecx
add    $0xffffffff,%ecx
cmp    $0x37,%al
mov    $0x3,%ebp
cmovne %ecx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @get_type(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %3
%7 = load i8, i8* %0
%8 = sext i8 %7 to i32
switch i32 %8, label %19 [
i32 73, label %20
i32 65, label %9
i32 76, label %10
]
9: ; preds = %6
br label %20
10: ; preds = %6
%11 = icmp slt i32 %4, 3
br i1 %11, label %20, label %12
12: ; preds = %10
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 56
%16 = select i1 %15, i32 4, i32 -1
%17 = icmp eq i8 %14, 55
%18 = select i1 %17, i32 3, i32 %16
br label %20
19: ; preds = %6
br label %20
20: ; preds = %12, %9, %19, %3, %6, %10, %1
%21 = phi i32 [ -1, %1 ], [ -1, %19 ], [ 2, %9 ], [ -1, %3 ], [ 1, %6 ], [ -1, %10 ], [ %18, %12 ]
ret i32 %21
}