#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*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
int get_filetype(char *filename, char *filetype) {
  if (strstr(filename, ".html"))
    strcpy(filetype, "text/html\r\n");
  else if (strstr(filename, ".gif"))
    strcpy(filetype, "image/gif");
  else if (strstr(filename, ".jpg")) {
    strcpy(filetype, "image/jpeg\r\n");
    return 1;
  } else if (strstr(filename, ".png")) {
    strcpy(filetype, "image/png\r\n");
    return 1;
  } else
    strcpy(filetype, "");
  return 0;
}


x86 assembly (clang, -O0):
<get_filetype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     115f <get_filetype+0x3f>
mov    -0x18(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1219 <get_filetype+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     118e <get_filetype+0x6e>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1214 <get_filetype+0xf4>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11c4 <get_filetype+0xa4>
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1220 <get_filetype+0x100>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11fa <get_filetype+0xda>
mov    -0x18(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1220 <get_filetype+0x100>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1030 <strcpy@plt>
jmp    120f <get_filetype+0xef>
jmp    1214 <get_filetype+0xf4>
jmp    1219 <get_filetype+0xf9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filetype>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1040 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1146 <get_filetype+0x26>
lea    0xec2(%rip),%rsi
jmp    11af <get_filetype+0x8f>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1163 <get_filetype+0x43>
lea    0xeb6(%rip),%rsi
jmp    11af <get_filetype+0x8f>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1185 <get_filetype+0x65>
mov    $0x1,%ebp
lea    0xea3(%rip),%rsi
jmp    11af <get_filetype+0x8f>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
lea    0xe8e(%rip),%rax
lea    0xe8d(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c".html\00"
@.str.1 = [12 x i8] c"text/html\0D\0A\00"
@.str.2 = [5 x i8] c".gif\00"
@.str.3 = [10 x i8] c"image/gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [13 x i8] c"image/jpeg\0D\0A\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [12 x i8] c"image/png\0D\0A\00"
@.str.8 = [1 x i8] zeroinitializer
define i32 @get_filetype(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %39
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %38
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i64 @strstr(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %40
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = call i64 @strstr(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %40
33: ; preds = %26
%34 = load i8*, i8** %5
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0))
br label %36
36: ; preds = %33
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %16
br label %39
39: ; preds = %38, %9
store i32 0, i32* %3
br label %40
40: ; preds = %39, %30, %23
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [6 x i8] c".html\00"
@.str.1 = [12 x i8] c"text/html\0D\0A\00"
@.str.2 = [5 x i8] c".gif\00"
@.str.3 = [10 x i8] c"image/gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [13 x i8] c"image/jpeg\0D\0A\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [12 x i8] c"image/png\0D\0A\00"
@.str.8 = [1 x i8] zeroinitializer
define i32 @get_filetype(i8* %0, i8* %1) {
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0)
%15 = xor i1 %13, true
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %11, %8, %5, %2
%18 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), %8 ], [ %14, %11 ]
%19 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 1, %8 ], [ %16, %11 ]
%20 = tail call i32 @strcpy(i8* %1, i8* %18)
ret i32 %19
}