#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
char *content_type(char *file) {
  char extension[1024];
  char file_name[1024];
  strcpy(file_name, file);
  strtok(file_name, ".");
  strcpy(extension, strtok(NULL, "."));
  if (!strcmp(extension, "html") || !strcmp(extension, "htm"))
    return "text/html";
  else
    return "text/plain";
}


x86 assembly (clang, -O0):
<content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x810(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1050 <strtok@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x818(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe85(%rip),%rsi
call   1050 <strtok@plt>
mov    -0x818(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11c7 <content_type+0x97>
lea    -0x410(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <content_type+0xa7>
lea    0xe38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e2 <content_type+0xb2>
lea    0xe32(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<content_type>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%rsi
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xebc(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    (%rsp),%eax
mov    %eax,%ecx
xor    $0x6c6d7468,%ecx
cmp    $0x6d7468,%eax
lea    0xe87(%rip),%rdx
lea    0xe8a(%rip),%rax
cmove  %rdx,%rax
movzbl 0x4(%rsp),%esi
or     %ecx,%esi
cmove  %rdx,%rax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c"html\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [11 x i8] c"text/plain\00"
define i8* @content_type(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcpy(i8* %4, i8* %8)
%10 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%11 = icmp eq i32 %10, 0
%12 = bitcast [1024 x i8]* %2 to i32*
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 7173224
%15 = select i1 %11, i1 true, i1 %14
%16 = select i1 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0)
ret i8* %16
}