#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 *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *getContentType(char *extension) {
  char *content = malloc(30);
  if (strcmp(extension, "html") == 0 || strcmp(extension, "css") == 0) {
    strcat(content, "text/");
    strcat(content, extension);
  } else if (strcmp(extension, "jpg") == 0 || strcmp(extension, "jpeg") == 0 ||
             strcmp(extension, "png") == 0 || strcmp(extension, "gif") == 0) {
    strcat(content, "image/");
    strcat(content, extension);
  } else {
    content = "text/plain";
  }
  return content;
}


x86 assembly (clang, -O0):
<getContentType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     117e <getContentType+0x4e>
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <getContentType+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
jmp    123a <getContentType+0x10a>
mov    -0x8(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1208 <getContentType+0xd8>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1208 <getContentType+0xd8>
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1208 <getContentType+0xd8>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <getContentType+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
jmp    1235 <getContentType+0x105>
lea    0xdf6(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    123a <getContentType+0x10a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getContentType>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
lea    0xeae(%rip),%r15
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
lea    0xe96(%rip),%r15
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <getContentType+0xa4>
lea    0xe55(%rip),%r14
jmp    11ea <getContentType+0xba>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"html\00"
@.str.1 = [4 x i8] c"css\00"
@.str.2 = [6 x i8] c"text/\00"
@.str.3 = [4 x i8] c"jpg\00"
@.str.4 = [5 x i8] c"jpeg\00"
@.str.5 = [4 x i8] c"png\00"
@.str.6 = [4 x i8] c"gif\00"
@.str.7 = [7 x i8] c"image/\00"
@.str.8 = [11 x i8] c"text/plain\00"
define i8* @getContentType(i8* %0) {
%2 = tail call dereferenceable_or_null(30) i8* @malloc(i32 30)
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %8, %11, %14, %17, %1, %5
%21 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %17 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %8 ]
%22 = tail call i32 @strcat(i8* %2, i8* %21)
%23 = tail call i32 @strcat(i8* %2, i8* %0)
br label %24
24: ; preds = %20, %17
%25 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), %17 ], [ %2, %20 ]
ret i8* %25
}