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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *xyz_conf_open(char *);
struct xyz_conf_t *xyz_conf_read(int /*<<< orphan*/ *);
struct xyz_conf_t *xyz_conf_load(char *file) {
  FILE *fp;
  if (file == NULL) {
    return NULL;
  }
  fp = xyz_conf_open(file);
  if (fp == NULL) {
    return NULL;
  }
  struct xyz_conf_t *tmp = xyz_conf_read(fp);
  fclose(fp);
  return tmp;
}


x86 assembly (clang, -O0):
<xyz_conf_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <xyz_conf_load+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1197 <xyz_conf_load+0x67>
mov    -0x10(%rbp),%rdi
call   1050 <xyz_conf_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <xyz_conf_load+0x49>
movq   $0x0,-0x8(%rbp)
jmp    1197 <xyz_conf_load+0x67>
mov    -0x18(%rbp),%rdi
call   1040 <xyz_conf_read@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xyz_conf_load>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     115e <xyz_conf_load+0x2e>
call   1050 <xyz_conf_open@plt>
test   %rax,%rax
je     115e <xyz_conf_load+0x2e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <xyz_conf_read@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    1160 <xyz_conf_load+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.xyz_conf_t = type { i32 }
define %struct.xyz_conf_t* @xyz_conf_load(i8* %0) {
%2 = alloca %struct.xyz_conf_t*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.xyz_conf_t*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store %struct.xyz_conf_t* null, %struct.xyz_conf_t** %2
br label %21
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32* @xyz_conf_open(i8* %10)
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
store %struct.xyz_conf_t* null, %struct.xyz_conf_t** %2
br label %21
15: ; preds = %9
%16 = load i32*, i32** %4
%17 = call %struct.xyz_conf_t* @xyz_conf_read(i32* %16)
store %struct.xyz_conf_t* %17, %struct.xyz_conf_t** %5
%18 = load i32*, i32** %4
%19 = call i32 @fclose(i32* %18)
%20 = load %struct.xyz_conf_t*, %struct.xyz_conf_t** %5
store %struct.xyz_conf_t* %20, %struct.xyz_conf_t** %2
br label %21
21: ; preds = %15, %14, %8
%22 = load %struct.xyz_conf_t*, %struct.xyz_conf_t** %2
ret %struct.xyz_conf_t* %22
}

LLVM IR (-O2):
%struct.xyz_conf_t = type { i32 }
define %struct.xyz_conf_t* @xyz_conf_load(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i32* @xyz_conf_open(i8* %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call %struct.xyz_conf_t* @xyz_conf_read(i32* %4)
%8 = tail call i32 @fclose(i32* %4)
br label %9
9: ; preds = %3, %1, %6
%10 = phi %struct.xyz_conf_t* [ %7, %6 ], [ null, %1 ], [ null, %3 ]
ret %struct.xyz_conf_t* %10
}