#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 config {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ config_parse(struct config *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int config_load(struct config *config, const char *config_path) {
  FILE *fp;
  fp = fopen(config_path, "r");
  if (fp == NULL) {
    return 1;
  }
  if (config_parse(config, fp)) {
    fclose(fp);
    return 1;
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<config_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116b <config_load+0x3b>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <config_load+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <config_parse@plt>
cmp    $0x0,%rax
je     1197 <config_load+0x67>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <config_load+0x77>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_load>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%rbp
lea    0xec0(%rip),%rsi
mov    %rax,%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     116e <config_load+0x3e>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <config_parse@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1173 <config_load+0x43>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.config = type { i32 }
@.str = [2 x i8] c"r\00"
define i32 @config_load(%struct.config* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.config*
%5 = alloca i8*
%6 = alloca i32*
store %struct.config* %0, %struct.config** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %23
12: ; preds = %2
%13 = load %struct.config*, %struct.config** %4
%14 = load i32*, i32** %6
%15 = call i64 @config_parse(%struct.config* %13, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32*, i32** %6
%19 = call i32 @fclose(i32* %18)
store i32 1, i32* %3
br label %23
20: ; preds = %12
%21 = load i32*, i32** %6
%22 = call i32 @fclose(i32* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %20, %17, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.config = type { i32 }
@.str = [2 x i8] c"r\00"
define i32 @config_load(%struct.config* %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i64 @config_parse(%struct.config* %0, i32* %3)
%7 = icmp ne i64 %6, 0
%8 = tail call i32 @fclose(i32* %3)
%9 = zext i1 %7 to i32
br label %10
10: ; preds = %5, %2
%11 = phi i32 [ 1, %2 ], [ %9, %5 ]
ret i32 %11
}