#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*/ add_new_macro(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void load_config() {
  char buf[2000];
  FILE *config = fopen("/etc/iprdbg.conf", "r");
  if (!config)
    return;
  while (!feof(config)) {
    if (!fgets(buf, sizeof(buf), config))
      break;
    if (buf[0] == '#')
      continue;
    add_new_macro(buf);
  }
  fclose(config);
}


x86 assembly (clang, -O0):
<load_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
lea    0xe9e(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x7d8(%rbp)
cmpq   $0x0,-0x7d8(%rbp)
jne    1188 <load_config+0x38>
jmp    1206 <load_config+0xb6>
jmp    118d <load_config+0x3d>
mov    -0x7d8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ae <load_config+0x5e>
jmp    11fa <load_config+0xaa>
lea    -0x7d0(%rbp),%rdi
mov    -0x7d8(%rbp),%rdx
mov    $0x7d0,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    11d4 <load_config+0x84>
jmp    11fa <load_config+0xaa>
movsbl -0x7d0(%rbp),%eax
cmp    $0x23,%eax
jne    11e9 <load_config+0x99>
jmp    118d <load_config+0x3d>
lea    -0x7d0(%rbp),%rdi
call   1070 <add_new_macro@plt>
jmp    118d <load_config+0x3d>
mov    -0x7d8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_config>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
lea    0xe9f(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1189 <load_config+0x39>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     1194 <load_config+0x44>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsp,%r14
jmp    11ac <load_config+0x5c>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1181 <load_config+0x31>
mov    %r14,%rdi
mov    $0x7d0,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %eax,%eax
je     1181 <load_config+0x31>
cmpb   $0x23,(%rsp)
je     11a0 <load_config+0x50>
mov    %r14,%rdi
call   1070 <add_new_macro@plt>
jmp    11a0 <load_config+0x50>

LLVM IR (-O0):
@.str = [17 x i8] c"/etc/iprdbg.conf\00"
@.str.1 = [2 x i8] c"r\00"
define void @load_config() {
%1 = alloca [2000 x i8]
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
br label %31
7: ; preds = %0
br label %8
8: ; preds = %25, %24, %7
%9 = load i32*, i32** %2
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
%15 = load i32*, i32** %2
%16 = call i32 @fgets(i8* %14, i32 2000, i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %13
br label %28
19: ; preds = %13
%20 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 35
br i1 %23, label %24, label %25
24: ; preds = %19
br label %8
25: ; preds = %19
%26 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
%27 = call i32 @add_new_macro(i8* %26)
br label %8
28: ; preds = %18, %8
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %28, %6
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"/etc/iprdbg.conf\00"
@.str.1 = [2 x i8] c"r\00"
define void @load_config() {
%1 = alloca [2000 x i8]
%2 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %21, label %5
5: ; preds = %0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5, %16
%9 = call i32 @fgets(i8* %2, i32 2000, i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %8
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 35
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @add_new_macro(i8* %2)
br label %16
16: ; preds = %14, %11
%17 = call i32 @feof(i32* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %8, label %19
19: ; preds = %16, %8, %5
%20 = call i32 @fclose(i32* %3)
br label %21
21: ; preds = %0, %19
ret void
}