#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
struct xyz_conf_t *xyz_conf_append(struct xyz_conf_t *, char *, char *);
char *xyz_conf_parse(char *);
int xyz_conf_trim(char *);
struct xyz_conf_t *xyz_conf_read(FILE *fp) {
  char line[512];
  char *value;
  if (fp == NULL) {
    return NULL;
  }
  struct xyz_conf_t *conf = NULL;
  while (!feof(fp)) {
    bzero(line, sizeof(line));
    if (fgets(line, sizeof(line) - 1, fp) == NULL) {
      continue;
    }
    if (xyz_conf_trim(line) == -1) {
      continue;
    }
    value = xyz_conf_parse(line);
    if (value == NULL) {
      continue;
    }
    conf = xyz_conf_append(conf, line, value);
  }
  return conf;
}


x86 assembly (clang, -O0):
<xyz_conf_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1187 <xyz_conf_read+0x27>
movq   $0x0,-0x8(%rbp)
jmp    1256 <xyz_conf_read+0xf6>
movq   $0x0,-0x220(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b0 <xyz_conf_read+0x50>
jmp    124b <xyz_conf_read+0xeb>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
call   1070 <bzero@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11e5 <xyz_conf_read+0x85>
jmp    1192 <xyz_conf_read+0x32>
lea    -0x210(%rbp),%rdi
call   1080 <xyz_conf_trim@plt>
cmp    $0xffffffff,%eax
jne    11ff <xyz_conf_read+0x9f>
jmp    1192 <xyz_conf_read+0x32>
lea    -0x210(%rbp),%rdi
call   1030 <xyz_conf_parse@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    1225 <xyz_conf_read+0xc5>
jmp    1192 <xyz_conf_read+0x32>
mov    -0x220(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    -0x218(%rbp),%rdx
call   1040 <xyz_conf_append@plt>
mov    %rax,-0x220(%rbp)
jmp    1192 <xyz_conf_read+0x32>
mov    -0x220(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xyz_conf_read>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
test   %rdi,%rdi
je     11eb <xyz_conf_read+0x8b>
mov    %rdi,%rbx
call   1060 <feof@plt>
xor    %r14d,%r14d
test   %eax,%eax
jne    11ee <xyz_conf_read+0x8e>
mov    %rsp,%r15
jmp    119c <xyz_conf_read+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11ee <xyz_conf_read+0x8e>
mov    %r15,%rdi
mov    $0x200,%esi
call   1070 <bzero@plt>
mov    %r15,%rdi
mov    $0x1ff,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1190 <xyz_conf_read+0x30>
mov    %r15,%rdi
call   1080 <xyz_conf_trim@plt>
cmp    $0xffffffff,%eax
je     1190 <xyz_conf_read+0x30>
mov    %r15,%rdi
call   1030 <xyz_conf_parse@plt>
test   %rax,%rax
je     1190 <xyz_conf_read+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <xyz_conf_append@plt>
mov    %rax,%r14
jmp    1190 <xyz_conf_read+0x30>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.xyz_conf_t = type { i32 }
define %struct.xyz_conf_t* @xyz_conf_read(i32* %0) {
%2 = alloca %struct.xyz_conf_t*
%3 = alloca i32*
%4 = alloca [512 x i8]
%5 = alloca i8*
%6 = alloca %struct.xyz_conf_t*
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store %struct.xyz_conf_t* null, %struct.xyz_conf_t** %2
br label %42
10: ; preds = %1
store %struct.xyz_conf_t* null, %struct.xyz_conf_t** %6
br label %11
11: ; preds = %35, %34, %28, %23, %10
%12 = load i32*, i32** %3
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%18 = call i32 @bzero(i8* %17, i32 512)
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%20 = load i32*, i32** %3
%21 = call i32* @fgets(i8* %19, i32 511, i32* %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %16
br label %11
24: ; preds = %16
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%26 = call i32 @xyz_conf_trim(i8* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %29
28: ; preds = %24
br label %11
29: ; preds = %24
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%31 = call i8* @xyz_conf_parse(i8* %30)
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %29
br label %11
35: ; preds = %29
%36 = load %struct.xyz_conf_t*, %struct.xyz_conf_t** %6
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%38 = load i8*, i8** %5
%39 = call %struct.xyz_conf_t* @xyz_conf_append(%struct.xyz_conf_t* %36, i8* %37, i8* %38)
store %struct.xyz_conf_t* %39, %struct.xyz_conf_t** %6
br label %11
40: ; preds = %11
%41 = load %struct.xyz_conf_t*, %struct.xyz_conf_t** %6
store %struct.xyz_conf_t* %41, %struct.xyz_conf_t** %2
br label %42
42: ; preds = %40, %9
%43 = load %struct.xyz_conf_t*, %struct.xyz_conf_t** %2
ret %struct.xyz_conf_t* %43
}

LLVM IR (-O2):
%struct.xyz_conf_t = type { i32 }
define %struct.xyz_conf_t* @xyz_conf_read(i32* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32* %0, null
br i1 %4, label %27, label %5
5: ; preds = %1
%6 = call i32 @feof(i32* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %5, %23
%9 = phi %struct.xyz_conf_t* [ %24, %23 ], [ null, %5 ]
br label %10
10: ; preds = %8, %14
%11 = call i32 @bzero(i8* %3, i32 512)
%12 = call i32* @fgets(i8* %3, i32 511, i32* %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10, %17, %20
%15 = call i32 @feof(i32* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %10, label %27
17: ; preds = %10
%18 = call i32 @xyz_conf_trim(i8* %3)
%19 = icmp eq i32 %18, -1
br i1 %19, label %14, label %20
20: ; preds = %17
%21 = call i8* @xyz_conf_parse(i8* %3)
%22 = icmp eq i8* %21, null
br i1 %22, label %14, label %23
23: ; preds = %20
%24 = call %struct.xyz_conf_t* @xyz_conf_append(%struct.xyz_conf_t* %9, i8* %3, i8* %21)
%25 = call i32 @feof(i32* %0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %8, label %27
27: ; preds = %23, %14, %5, %1
%28 = phi %struct.xyz_conf_t* [ null, %1 ], [ null, %5 ], [ %9, %14 ], [ %24, %23 ]
ret %struct.xyz_conf_t* %28
}