#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int find_matched(char *, char const **, int);
int /*<<< orphan*/ *fopen(char *, char *);
char *strstr(char *, char *);
int mime_lookup(char *entries_file, const char **types, int arr_len) {
  FILE *in;
  int found = 0;
  char buf[1024];
  char *pos = buf, *entry_line;
  if ((in = fopen(entries_file, "r")) != NULL) {
    while (fgets(pos, sizeof(buf), in)) {
      while (*pos == ' ' || *pos == '\f' || *pos == '\t' || *pos == '\v')
        pos++;
      if (*pos == '\r' || *pos == '\n')
        continue;
      if ((entry_line = strstr(pos, "MimeType=")) == pos) {
        found = find_matched(entry_line, types, arr_len);
        break;
      }
    }
    fclose(in);
  } else {
    ;
  }
  return found;
}


x86 assembly (clang, -O0):
<mime_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12d3 <mime_lookup+0x183>
jmp    119e <mime_lookup+0x4e>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12c5 <mime_lookup+0x175>
jmp    11c2 <mime_lookup+0x72>
mov    -0x438(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x441(%rbp)
je     1229 <mime_lookup+0xd9>
mov    -0x438(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xc,%ecx
mov    %al,-0x441(%rbp)
je     1229 <mime_lookup+0xd9>
mov    -0x438(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x441(%rbp)
je     1229 <mime_lookup+0xd9>
mov    -0x438(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xb,%eax
sete   %al
mov    %al,-0x441(%rbp)
mov    -0x441(%rbp),%al
test   $0x1,%al
jne    123c <mime_lookup+0xec>
jmp    1253 <mime_lookup+0x103>
mov    -0x438(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x438(%rbp)
jmp    11c2 <mime_lookup+0x72>
mov    -0x438(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     1279 <mime_lookup+0x129>
mov    -0x438(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    127e <mime_lookup+0x12e>
jmp    119e <mime_lookup+0x4e>
mov    -0x438(%rbp),%rdi
lea    0xd76(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x440(%rbp)
cmp    -0x438(%rbp),%rax
jne    12c0 <mime_lookup+0x170>
mov    -0x440(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <find_matched@plt>
mov    %eax,-0x24(%rbp)
jmp    12c5 <mime_lookup+0x175>
jmp    119e <mime_lookup+0x4e>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12d8 <mime_lookup+0x188>
jmp    12d8 <mime_lookup+0x188>
mov    -0x24(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mime_lookup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1215 <mime_lookup+0xc5>
mov    %rax,%rbx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     122e <mime_lookup+0xde>
mov    %r15,0x8(%rsp)
mov    %r14d,0x4(%rsp)
lea    0xe51(%rip),%r13
mov    $0x2400,%r14d
movabs $0x100001a00,%r15
jmp    11f9 <mime_lookup+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x9,%edx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <strncmp@plt>
test   %eax,%eax
je     121a <mime_lookup+0xca>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     122e <mime_lookup+0xde>
movzbl 0x0(%rbp),%eax
cmp    $0x20,%rax
ja     11d0 <mime_lookup+0x80>
bt     %rax,%r14
jb     11e4 <mime_lookup+0x94>
bt     %rax,%r15
jae    11d0 <mime_lookup+0x80>
add    $0x1,%rbp
jmp    11f9 <mime_lookup+0xa9>
xor    %r12d,%r12d
jmp    1236 <mime_lookup+0xe6>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
call   1030 <find_matched@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r12d,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"MimeType=\00"
define i32 @mime_lookup(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %8
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %12, i8** %10
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %73
16: ; preds = %3
br label %17
17: ; preds = %69, %58, %16
%18 = load i8*, i8** %10
%19 = load i32*, i32** %7
%20 = call i64 @fgets(i8* %18, i32 1024, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %70
22: ; preds = %17
br label %23
23: ; preds = %45, %22
%24 = load i8*, i8** %10
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %43, label %28
28: ; preds = %23
%29 = load i8*, i8** %10
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 12
br i1 %32, label %43, label %33
33: ; preds = %28
%34 = load i8*, i8** %10
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 9
br i1 %37, label %43, label %38
38: ; preds = %33
%39 = load i8*, i8** %10
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 11
br label %43
43: ; preds = %38, %33, %28, %23
%44 = phi i1 [ true, %33 ], [ true, %28 ], [ true, %23 ], [ %42, %38 ]
br i1 %44, label %45, label %48
45: ; preds = %43
%46 = load i8*, i8** %10
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %10
br label %23
48: ; preds = %43
%49 = load i8*, i8** %10
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 13
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = load i8*, i8** %10
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 10
br i1 %57, label %58, label %59
58: ; preds = %53, %48
br label %17
59: ; preds = %53
%60 = load i8*, i8** %10
%61 = call i8* @strstr(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %61, i8** %11
%62 = load i8*, i8** %10
%63 = icmp eq i8* %61, %62
br i1 %63, label %64, label %69
64: ; preds = %59
%65 = load i8*, i8** %11
%66 = load i8**, i8*** %5
%67 = load i32, i32* %6
%68 = call i32 @find_matched(i8* %65, i8** %66, i32 %67)
store i32 %68, i32* %8
br label %70
69: ; preds = %59
br label %17
70: ; preds = %64, %17
%71 = load i32*, i32** %7
%72 = call i32 @fclose(i32* %71)
br label %74
73: ; preds = %3
br label %74
74: ; preds = %73, %70
%75 = load i32, i32* %8
ret i32 %75
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"MimeType=\00"
define i32 @mime_lookup(i8* nocapture %0, i8** %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %28, label %8
8: ; preds = %3
%9 = call i64 @fgets(i8* %5, i32 1024, i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %8, %15
%12 = phi i8* [ %16, %15 ], [ %5, %8 ]
br label %13
13: ; preds = %11, %17
%14 = load i8, i8* %12
switch i8 %14, label %20 [
i8 32, label %15
i8 12, label %15
i8 9, label %15
i8 11, label %15
i8 13, label %17
i8 10, label %17
]
15: ; preds = %13, %13, %13, %13
%16 = getelementptr inbounds i8, i8* %12, i64 1
br label %11
17: ; preds = %13, %13, %20
%18 = call i64 @fgets(i8* %12, i32 1024, i32* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %13
20: ; preds = %13
%21 = call i32 @strncmp(i8* %12, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 9)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %20
%24 = call i32 @find_matched(i8* %12, i8** %1, i32 %2)
br label %25
25: ; preds = %17, %8, %23
%26 = phi i32 [ %24, %23 ], [ 0, %8 ], [ 0, %17 ]
%27 = call i32 @fclose(i32* %6)
br label %28
28: ; preds = %3, %25
%29 = phi i32 [ %26, %25 ], [ 0, %3 ]
ret i32 %29
}