#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 */
scalar_t__ startWith(char *, char *);
int dia2coap_cttType(char *cttType) {
  int type = 0;
  if (!cttType)
    return type;
  if (startWith(cttType, "text/plain"))
    type = 0;
  else if (startWith(cttType, "application/link-format"))
    type = 40;
  else if (startWith(cttType, "application/xml"))
    type = 41;
  else if (startWith(cttType, "application/octet-stream"))
    type = 42;
  else if (startWith(cttType, "application/rdf+xml"))
    type = 43;
  else if (startWith(cttType, "application/exi"))
    type = 47;
  else if (startWith(cttType, "application/json"))
    type = 50;
  return type;
}


x86 assembly (clang, -O0):
<dia2coap_cttType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1139 <dia2coap_cttType+0x29>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1262 <dia2coap_cttType+0x152>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     115f <dia2coap_cttType+0x4f>
movl   $0x0,-0x14(%rbp)
jmp    125c <dia2coap_cttType+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     1185 <dia2coap_cttType+0x75>
movl   $0x28,-0x14(%rbp)
jmp    1257 <dia2coap_cttType+0x147>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     11ab <dia2coap_cttType+0x9b>
movl   $0x29,-0x14(%rbp)
jmp    1252 <dia2coap_cttType+0x142>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     11d1 <dia2coap_cttType+0xc1>
movl   $0x2a,-0x14(%rbp)
jmp    124d <dia2coap_cttType+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     11f7 <dia2coap_cttType+0xe7>
movl   $0x2b,-0x14(%rbp)
jmp    1248 <dia2coap_cttType+0x138>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     121d <dia2coap_cttType+0x10d>
movl   $0x2f,-0x14(%rbp)
jmp    1243 <dia2coap_cttType+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <startWith@plt>
cmp    $0x0,%rax
je     123e <dia2coap_cttType+0x12e>
movl   $0x32,-0x14(%rbp)
jmp    1243 <dia2coap_cttType+0x133>
jmp    1248 <dia2coap_cttType+0x138>
jmp    124d <dia2coap_cttType+0x13d>
jmp    1252 <dia2coap_cttType+0x142>
jmp    1257 <dia2coap_cttType+0x147>
jmp    125c <dia2coap_cttType+0x14c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dia2coap_cttType>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     11d3 <dia2coap_cttType+0xc3>
mov    %rdi,%rbx
lea    0xed8(%rip),%rsi
call   1030 <startWith@plt>
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
mov    $0x28,%ebp
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
mov    $0x29,%ebp
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
mov    $0x2a,%ebp
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
mov    $0x2b,%ebp
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
mov    $0x2f,%ebp
test   %rax,%rax
jne    11d3 <dia2coap_cttType+0xc3>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <startWith@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    $0x32,%ebp
cmove  %ecx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [24 x i8] c"application/link-format\00"
@.str.2 = [16 x i8] c"application/xml\00"
@.str.3 = [25 x i8] c"application/octet-stream\00"
@.str.4 = [20 x i8] c"application/rdf+xml\00"
@.str.5 = [16 x i8] c"application/exi\00"
@.str.6 = [17 x i8] c"application/json\00"
define i32 @dia2coap_cttType(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = load i32, i32* %4
store i32 %8, i32* %2
br label %52
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @startWith(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 0, i32* %4
br label %50
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i64 @startWith(i8* %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 40, i32* %4
br label %49
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = call i64 @startWith(i8* %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 41, i32* %4
br label %48
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = call i64 @startWith(i8* %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 42, i32* %4
br label %47
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = call i64 @startWith(i8* %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 43, i32* %4
br label %46
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = call i64 @startWith(i8* %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 47, i32* %4
br label %45
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = call i64 @startWith(i8* %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 50, i32* %4
br label %44
44: ; preds = %43, %39
br label %45
45: ; preds = %44, %38
br label %46
46: ; preds = %45, %33
br label %47
47: ; preds = %46, %28
br label %48
48: ; preds = %47, %23
br label %49
49: ; preds = %48, %18
br label %50
50: ; preds = %49, %13
%51 = load i32, i32* %4
store i32 %51, i32* %2
br label %52
52: ; preds = %50, %7
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [24 x i8] c"application/link-format\00"
@.str.2 = [16 x i8] c"application/xml\00"
@.str.3 = [25 x i8] c"application/octet-stream\00"
@.str.4 = [20 x i8] c"application/rdf+xml\00"
@.str.5 = [16 x i8] c"application/exi\00"
@.str.6 = [17 x i8] c"application/json\00"
define i32 @dia2coap_cttType(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %25, label %3
3: ; preds = %1
%4 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %25
6: ; preds = %3
%7 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = tail call i64 @startWith(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 0, i32 50
br label %25
25: ; preds = %21, %3, %6, %9, %12, %15, %18, %1
%26 = phi i32 [ 0, %1 ], [ 0, %3 ], [ 40, %6 ], [ 41, %9 ], [ 42, %12 ], [ 43, %15 ], [ 47, %18 ], [ %24, %21 ]
ret i32 %26
}