#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 */
struct fte_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bfile(char *);
int /*<<< orphan*/ errx(int, char *, int, char *);
int /*<<< orphan*/ fte_getdescription(struct fte_data *, char *, char *,
                                      char **, char **, char **, char **);
struct fte_data *fte_init(int /*<<< orphan*/);
int /*<<< orphan*/ warnx(char *, char *);
char *get_filetype_icon(char *ext) {
  static struct fte_data *fdata = NULL;
  if (fdata == NULL)
    fdata = fte_init(bfile("config/file_extensions.conf"));
  static char *icon, *version;
  char *group, *descr;
  if (fdata == NULL) {
    errx(1, "No fte_data %d %s", 19,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/bowlofstew/enterprise-search/refs/heads/"
         "master/src/dispatcher_all/out_common.c");
    return NULL;
  }
  if (!fte_getdescription(fdata, "eng", ext, &group, &descr, &icon, &version)) {
    warnx("no icon for ext %s\n", ext);
    icon[0] = '\0';
    return icon;
  }
  return icon;
}


x86 assembly (clang, -O0):
<get_filetype_icon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,0x2eec(%rip)
jne    1184 <get_filetype_icon+0x34>
lea    0xe8f(%rip),%rdi
call   1070 <bfile@plt>
mov    %eax,%edi
call   1060 <fte_init@plt>
mov    %rax,0x2ecc(%rip)
cmpq   $0x0,0x2ec4(%rip)
jne    11bc <get_filetype_icon+0x6c>
mov    $0x1,%edi
lea    0xe7e(%rip),%rsi
mov    $0x13,%edx
lea    0xe84(%rip),%rcx
call   1030 <errx@plt>
movq   $0x0,-0x8(%rbp)
jmp    122b <get_filetype_icon+0xdb>
mov    0x2e8d(%rip),%rdi
mov    -0x10(%rbp),%rdx
lea    0xf09(%rip),%rsi
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    0x2e7b(%rip),%r9
lea    0x2e7c(%rip),%rax
mov    %rax,(%rsp)
call   1050 <fte_getdescription@plt>
cmp    $0x0,%eax
jne    1220 <get_filetype_icon+0xd0>
mov    -0x10(%rbp),%rsi
lea    0xeda(%rip),%rdi
call   1040 <warnx@plt>
mov    0x2e4b(%rip),%rax
movb   $0x0,(%rax)
mov    0x2e41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <get_filetype_icon+0xdb>
mov    0x2e31(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filetype_icon>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    0x2ef1(%rip),%rdi
test   %rdi,%rdi
jne    1186 <get_filetype_icon+0x36>
lea    0xe95(%rip),%rdi
call   1070 <bfile@plt>
mov    %eax,%edi
call   1060 <fte_init@plt>
mov    %rax,%rdi
mov    %rax,0x2ecf(%rip)
test   %rax,%rax
je     11db <get_filetype_icon+0x8b>
lea    0x2ed3(%rip),%rax
mov    %rax,(%rsp)
lea    0xf3f(%rip),%rsi
lea    0x2eb9(%rip),%r9
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbx,%rdx
call   1050 <fte_getdescription@plt>
test   %eax,%eax
jne    11ce <get_filetype_icon+0x7e>
lea    0xf1f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <warnx@plt>
mov    0x2e8d(%rip),%rax
movb   $0x0,(%rax)
mov    0x2e83(%rip),%rax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe3a(%rip),%rsi
lea    0xe45(%rip),%rcx
mov    $0x1,%edi
mov    $0x13,%edx
call   1030 <errx@plt>
xor    %eax,%eax
jmp    11d5 <get_filetype_icon+0x85>

LLVM IR (-O0):
%struct.fte_data = type { i32 }
@get_filetype_icon.fdata = internal global %struct.fte_data* null
@.str = [28 x i8] c"config/file_extensions.conf\00"
@get_filetype_icon.icon = internal global i8* null
@get_filetype_icon.version = internal global i8* null
@.str.1 = [18 x i8] c"No fte_data %d %s\00"
@.str.2 = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bowlofstew/enterprise-search/refs/heads/master/src/dispatcher_all/out_common.c\00"
@.str.3 = [4 x i8] c"eng\00"
@.str.4 = [20 x i8] c"no icon for ext %s\0A\00"
define i8* @get_filetype_icon(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load %struct.fte_data*, %struct.fte_data** @get_filetype_icon.fdata
%7 = icmp eq %struct.fte_data* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @bfile(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = call %struct.fte_data* @fte_init(i32 %9)
store %struct.fte_data* %10, %struct.fte_data** @get_filetype_icon.fdata
br label %11
11: ; preds = %8, %1
%12 = load %struct.fte_data*, %struct.fte_data** @get_filetype_icon.fdata
%13 = icmp eq %struct.fte_data* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 19, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %29
16: ; preds = %11
%17 = load %struct.fte_data*, %struct.fte_data** @get_filetype_icon.fdata
%18 = load i8*, i8** %3
%19 = call i32 @fte_getdescription(%struct.fte_data* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %18, i8** %4, i8** %5, i8** @get_filetype_icon.icon, i8** @get_filetype_icon.version)
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i32 @warnx(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** @get_filetype_icon.icon
%25 = getelementptr inbounds i8, i8* %24, i64 0
store i8 0, i8* %25
%26 = load i8*, i8** @get_filetype_icon.icon
store i8* %26, i8** %2
br label %29
27: ; preds = %16
%28 = load i8*, i8** @get_filetype_icon.icon
store i8* %28, i8** %2
br label %29
29: ; preds = %27, %21, %14
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
%struct.fte_data = type { i32 }
@get_filetype_icon.fdata = internal unnamed_addr global %struct.fte_data* null
@.str = [28 x i8] c"config/file_extensions.conf\00"
@get_filetype_icon.icon = internal global i8* null
@get_filetype_icon.version = internal global i8* null
@.str.1 = [18 x i8] c"No fte_data %d %s\00"
@.str.2 = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bowlofstew/enterprise-search/refs/heads/master/src/dispatcher_all/out_common.c\00"
@.str.3 = [4 x i8] c"eng\00"
@.str.4 = [20 x i8] c"no icon for ext %s\0A\00"
define i8* @get_filetype_icon(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = load %struct.fte_data*, %struct.fte_data** @get_filetype_icon.fdata
%5 = icmp eq %struct.fte_data* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = bitcast i8** %2 to i8*
%8 = bitcast i8** %3 to i8*
br label %17
9: ; preds = %1
%10 = tail call i32 @bfile(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%11 = tail call %struct.fte_data* @fte_init(i32 %10)
store %struct.fte_data* %11, %struct.fte_data** @get_filetype_icon.fdata
%12 = bitcast i8** %2 to i8*
%13 = bitcast i8** %3 to i8*
%14 = icmp eq %struct.fte_data* %11, null
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 19, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.2, i64 0, i64 0))
br label %27
17: ; preds = %6, %9
%18 = phi %struct.fte_data* [ %4, %6 ], [ %11, %9 ]
%19 = call i32 @fte_getdescription(%struct.fte_data* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8** %2, i8** %3, i8** @get_filetype_icon.icon, i8** @get_filetype_icon.version)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i32 @warnx(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%23 = load i8*, i8** @get_filetype_icon.icon
store i8 0, i8* %23
%24 = load i8*, i8** @get_filetype_icon.icon
br label %27
25: ; preds = %17
%26 = load i8*, i8** @get_filetype_icon.icon
br label %27
27: ; preds = %25, %21, %15
%28 = phi i8* [ null, %15 ], [ %26, %25 ], [ %24, %21 ]
%29 = bitcast i8** %2 to i8*
%30 = bitcast i8** %3 to i8*
ret i8* %28
}