#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int mime_lookup(char *, char const **, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void test_options_file() {
  printf("Testing configurations file\n");
  char entries_file[] = "desktop_entry.sample";
  const char *keys[5] = {"text/html", "application/json+xml",
                         "application/xhtml", "x-scheme-handler/http",
                         "text/javascript"};
  FILE *fp;
  if (!(fp = fopen(entries_file, "w"))) {
    perror("test_desktop_entries_file");
    exit(1);
  }
  fprintf(fp, "[Title, or section label?]\n");
  fprintf(fp, "something=in_their_language\n");
  fprintf(fp, "settings[attr]=value or something\n");
  fprintf(fp,
          "MimeType=text/html;application/xhtml+xml;x-scheme-handler/"
          "http;x-scheme-handler/https;x-scheme-handler/geo;image/svg+xml;");
  fprintf(fp, "settings[attr]=value or something\n");
  fclose(fp);
  assert(mime_lookup(entries_file, keys, 5) == 4);
  printf("ALL TESTS PASSED!\n");
}


x86 assembly (clang, -O0):
<test_options_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    0xfd5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xfd2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xfd0(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xfcb(%rip),%al
mov    %al,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe3a(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe39(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe4a(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe55(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1247 <test_options_file+0xb7>
lea    0xe3e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x58(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x5,%edx
call   1060 <mime_lookup@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_options_file>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xfd0(%rip),%rdi
call   1030 <puts@plt>
movaps 0xe66(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x656c706d61732e,%rax
mov    %rax,0xd(%rsp)
lea    0xe61(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe5f(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe68(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xe6e(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe78(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xe7c(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     12bc <test_options_file+0x13c>
mov    %rax,%rbx
lea    0xe7d(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe80(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe84(%rip),%r14
mov    $0x22,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe8b(%rip),%rdi
mov    $0x79,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    $0x22,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    $0x5,%edx
call   1050 <mime_lookup@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdab(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Testing configurations file\0A\00"
@__const.test_options_file.entries_file = [21 x i8] c"desktop_entry.sample\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [21 x i8] c"application/json+xml\00"
@.str.3 = [18 x i8] c"application/xhtml\00"
@.str.4 = [22 x i8] c"x-scheme-handler/http\00"
@.str.5 = [16 x i8] c"text/javascript\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [26 x i8] c"test_desktop_entries_file\00"
@.str.8 = [28 x i8] c"[Title, or section label?]\0A\00"
@.str.9 = [29 x i8] c"something=in_their_language\0A\00"
@.str.10 = [35 x i8] c"settings[attr]=value or something\0A\00"
@.str.11 = [122 x i8] c"MimeType=text/html;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/geo;image/svg+xml;\00"
@.str.12 = [19 x i8] c"ALL TESTS PASSED!\0A\00"
define void @test_options_file() {
%1 = alloca [21 x i8]
%2 = alloca [5 x i8*]
%3 = alloca i32*
%4 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [21 x i8]* %1 to i8*
%6 = bitcast [5 x i8*]* %2 to i8*
%7 = bitcast i8* %6 to [5 x i8*]*
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %14, i32** %3
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = load i32*, i32** %3
%21 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%22 = load i32*, i32** %3
%23 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%24 = load i32*, i32** %3
%25 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%26 = load i32*, i32** %3
%27 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str.11, i64 0, i64 0))
%28 = load i32*, i32** %3
%29 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%30 = load i32*, i32** %3
%31 = call i32 @fclose(i32* %30)
%32 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%33 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%34 = call i32 @mime_lookup(i8* %32, i8** %33, i32 5)
%35 = icmp eq i32 %34, 4
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_options_file.entries_file = [21 x i8] c"desktop_entry.sample\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [21 x i8] c"application/json+xml\00"
@.str.3 = [18 x i8] c"application/xhtml\00"
@.str.4 = [22 x i8] c"x-scheme-handler/http\00"
@.str.5 = [16 x i8] c"text/javascript\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [26 x i8] c"test_desktop_entries_file\00"
@.str.8 = [28 x i8] c"[Title, or section label?]\0A\00"
@.str.9 = [29 x i8] c"something=in_their_language\0A\00"
@.str.10 = [35 x i8] c"settings[attr]=value or something\0A\00"
@.str.11 = [122 x i8] c"MimeType=text/html;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/geo;image/svg+xml;\00"
@str = [28 x i8] c"Testing configurations file\00"
@str.13 = [18 x i8] c"ALL TESTS PASSED!\00"
define void @test_options_file() {
%1 = alloca [21 x i8]
%2 = alloca [5 x i8*]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%5 = bitcast [5 x i8*]* %2 to i8*
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8** %10
%11 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i64 27, i64 1, i32* %11)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i64 28, i64 1, i32* %11)
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i64 34, i64 1, i32* %11)
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str.11, i64 0, i64 0), i64 121, i64 1, i32* %11)
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i64 34, i64 1, i32* %11)
%22 = tail call i32 @fclose(i32* %11)
%23 = call i32 @mime_lookup(i8* %4, i8** %6, i32 5)
%24 = icmp eq i32 %23, 4
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
ret void
}