#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parseConfig(int /*<<< orphan*/ *);
int getConfig() {
  FILE *fp;
  static char *locations[] = {"/usr/local/etc/mail.conf", "/etc/mail.conf",
                              NULL};
  char **lp;
  for (lp = &locations[0]; *lp; lp++) {
    if ((fp = fopen(*lp, "r")) != NULL) {
      parseConfig(fp);
      (void)fclose(fp);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<getConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0x2f01(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a6 <getConfig+0x76>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xeba(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1190 <getConfig+0x60>
mov    -0x10(%rbp),%rdi
call   1050 <parseConfig@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ad <getConfig+0x7d>
jmp    1195 <getConfig+0x65>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1143 <getConfig+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getConfig>:
push   %rbx
lea    0xec8(%rip),%rdi
lea    0xeda(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1167 <getConfig+0x37>
lea    0xeb7(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     117e <getConfig+0x4e>
mov    %rbx,%rdi
call   1050 <parseConfig@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@getConfig.locations = internal global [3 x i8*] [i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str = [25 x i8] c"/usr/local/etc/mail.conf\00"
@.str.1 = [15 x i8] c"/etc/mail.conf\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @getConfig() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8**
store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @getConfig.locations, i64 0, i64 0), i8*** %3
br label %4
4: ; preds = %19, %0
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %11, i32** %2
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32*, i32** %2
%15 = call i32 @parseConfig(i32* %14)
%16 = load i32*, i32** %2
%17 = call i32 @fclose(i32* %16)
store i32 1, i32* %1
br label %23
18: ; preds = %8
br label %19
19: ; preds = %18
%20 = load i8**, i8*** %3
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %3
br label %4
22: ; preds = %4
store i32 0, i32* %1
br label %23
23: ; preds = %22, %13
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [25 x i8] c"/usr/local/etc/mail.conf\00"
@.str.1 = [15 x i8] c"/etc/mail.conf\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @getConfig() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3, %0
%7 = phi i32* [ %1, %0 ], [ %4, %3 ]
%8 = tail call i32 @parseConfig(i32* %7)
%9 = tail call i32 @fclose(i32* %7)
br label %10
10: ; preds = %3, %6
%11 = phi i32 [ 1, %6 ], [ 0, %3 ]
ret i32 %11
}