#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__ mg_globmatch(char *, int, char const *, int);
scalar_t__ strlen(char const *);
const char *guess_content_type(const char *filename) {
  int n = (int)strlen(filename);
  if (mg_globmatch("#.html", 6, filename, n))
    return "text/html";
  if (mg_globmatch("#.css", 5, filename, n))
    return "text/css";
  if (mg_globmatch("#.js", 4, filename, n))
    return "text/javascript";
  return "text/plain";
}


x86 assembly (clang, -O0):
<guess_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xeba(%rip),%rdi
mov    $0x6,%esi
call   1040 <mg_globmatch@plt>
cmp    $0x0,%rax
je     116a <guess_content_type+0x4a>
lea    0xea6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <guess_content_type+0xb9>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe99(%rip),%rdi
mov    $0x5,%esi
call   1040 <mg_globmatch@plt>
cmp    $0x0,%rax
je     119c <guess_content_type+0x7c>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <guess_content_type+0xb9>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe76(%rip),%rdi
mov    $0x4,%esi
call   1040 <mg_globmatch@plt>
cmp    $0x0,%rax
je     11ce <guess_content_type+0xae>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <guess_content_type+0xb9>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_content_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r14
lea    0xeca(%rip),%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <mg_globmatch@plt>
test   %rax,%rax
je     1154 <guess_content_type+0x34>
lea    0xeb5(%rip),%rax
jmp    11a5 <guess_content_type+0x85>
lea    0xeb6(%rip),%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <mg_globmatch@plt>
test   %rax,%rax
je     1179 <guess_content_type+0x59>
lea    0xea0(%rip),%rax
jmp    11a5 <guess_content_type+0x85>
lea    0xea0(%rip),%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <mg_globmatch@plt>
test   %rax,%rax
lea    0xe9b(%rip),%rcx
lea    0xe84(%rip),%rax
cmove  %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"#.html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [6 x i8] c"#.css\00"
@.str.3 = [9 x i8] c"text/css\00"
@.str.4 = [5 x i8] c"#.js\00"
@.str.5 = [16 x i8] c"text/javascript\00"
@.str.6 = [11 x i8] c"text/plain\00"
define i8* @guess_content_type(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i64 @mg_globmatch(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6, i8* %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %26
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i64 @mg_globmatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5, i8* %14, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %26
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = call i64 @mg_globmatch(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4, i8* %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %26
25: ; preds = %19
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %26
26: ; preds = %25, %24, %18, %12
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@.str = [7 x i8] c"#.html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [6 x i8] c"#.css\00"
@.str.3 = [9 x i8] c"text/css\00"
@.str.4 = [5 x i8] c"#.js\00"
@.str.5 = [16 x i8] c"text/javascript\00"
@.str.6 = [11 x i8] c"text/plain\00"
define i8* @guess_content_type(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = tail call i64 @mg_globmatch(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6, i8* %0, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = tail call i64 @mg_globmatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5, i8* %0, i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i64 @mg_globmatch(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4, i8* %0, i32 %3)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0)
br label %13
13: ; preds = %9, %6, %1
%14 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %6 ], [ %12, %9 ]
ret i8* %14
}