#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 */
char *stristr(char const *, char *);
scalar_t__ strstartwithignorecase(char *, char *);
int get_content_type(const char *header) {
  char *p;
  p = stristr(header, "content-type: ");
  if (!p)
    return 2;
  if (strstartwithignorecase("text/html", p + 14))
    return 0;
  else if (strstartwithignorecase("image", p + 14))
    return 1;
  else
    return 2;
}


x86 assembly (clang, -O0):
<get_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <stristr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1157 <get_content_type+0x37>
movl   $0x2,-0x4(%rbp)
jmp    11b2 <get_content_type+0x92>
mov    -0x18(%rbp),%rsi
add    $0xe,%rsi
lea    0xea9(%rip),%rdi
call   1040 <strstartwithignorecase@plt>
cmp    $0x0,%rax
je     1181 <get_content_type+0x61>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <get_content_type+0x92>
mov    -0x18(%rbp),%rsi
add    $0xe,%rsi
lea    0xe89(%rip),%rdi
call   1040 <strstartwithignorecase@plt>
cmp    $0x0,%rax
je     11ab <get_content_type+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <get_content_type+0x92>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_content_type>:
push   %rbx
lea    0xed8(%rip),%rsi
call   1030 <stristr@plt>
test   %rax,%rax
je     1154 <get_content_type+0x34>
mov    %rax,%rbx
add    $0xe,%rbx
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strstartwithignorecase@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     115b <get_content_type+0x3b>
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strstartwithignorecase@plt>
cmp    $0x1,%rax
mov    $0x1,%eax
adc    $0x0,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"content-type: \00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [6 x i8] c"image\00"
define i32 @get_content_type(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @stristr(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 2, i32* %2
br label %23
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 14
%13 = call i64 @strstartwithignorecase(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 0, i32* %2
br label %23
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 14
%19 = call i64 @strstartwithignorecase(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 1, i32* %2
br label %23
22: ; preds = %16
store i32 2, i32* %2
br label %23
23: ; preds = %22, %21, %15, %9
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [15 x i8] c"content-type: \00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [6 x i8] c"image\00"
define i32 @get_content_type(i8* %0) {
%2 = tail call i8* @stristr(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 14
%6 = tail call i64 @strstartwithignorecase(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = tail call i64 @strstartwithignorecase(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 2, i32 1
br label %12
12: ; preds = %8, %4, %1
%13 = phi i32 [ 2, %1 ], [ 0, %4 ], [ %11, %8 ]
ret i32 %13
}