#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*/ _defaults_rc_goto_eol(int /*<<< orphan*/ *);
scalar_t__ _defaults_rc_read_line(int /*<<< orphan*/ *, char **, char **, int *,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ defaults_add(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int defaults_read(char *filename) {
  FILE *f;
  int type;
  char *key;
  char *val;
  if (!filename) {
    return 1;
  }
  if ((f = fopen(filename, "r")) == NULL) {
    fprintf(stderr, "Could not read rc file \"%s\": ", filename);
    perror("");
    return 1;
  }
  while (!feof(f)) {
    if (_defaults_rc_read_line(f, &key, &val, &type, NULL, NULL) != 0) {
      fprintf(stderr, "Error parsing rc file.\n");
      fclose(f);
      return 1;
    } else {
      if (type == 1) {
        if (key && val) {
          defaults_add(key, val);
        }
        if (key) {
          free(key);
          key = NULL;
        }
        if (val) {
          free(val);
          val = NULL;
        }
      }
      _defaults_rc_goto_eol(f);
    }
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<defaults_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b3 <defaults_read+0x23>
movl   $0x1,-0x4(%rbp)
jmp    1302 <defaults_read+0x172>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1204 <defaults_read+0x74>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    0xe44(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1302 <defaults_read+0x172>
jmp    1209 <defaults_read+0x79>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1227 <defaults_read+0x97>
jmp    12f2 <defaults_read+0x162>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10a0 <_defaults_rc_read_line@plt>
cmp    $0x0,%rax
je     127a <defaults_read+0xea>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1302 <defaults_read+0x172>
cmpl   $0x1,-0x1c(%rbp)
jne    12e4 <defaults_read+0x154>
cmpq   $0x0,-0x28(%rbp)
je     12a7 <defaults_read+0x117>
cmpq   $0x0,-0x30(%rbp)
je     12a7 <defaults_read+0x117>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10b0 <defaults_add@plt>
cmpq   $0x0,-0x28(%rbp)
je     12c3 <defaults_read+0x133>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12df <defaults_read+0x14f>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    12e4 <defaults_read+0x154>
mov    -0x18(%rbp),%rdi
call   1050 <_defaults_rc_goto_eol@plt>
jmp    1209 <defaults_read+0x79>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<defaults_read>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    $0x1,%r14d
test   %rdi,%rdi
je     11d9 <defaults_read+0x49>
mov    %rdi,%rbp
lea    0xe4f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12a9 <defaults_read+0x119>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e9 <defaults_read+0x59>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x1c(%rsp),%rbp
jmp    1214 <defaults_read+0x84>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <_defaults_rc_goto_eol@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11ce <defaults_read+0x3e>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10a0 <_defaults_rc_read_line@plt>
test   %rax,%rax
jne    1285 <defaults_read+0xf5>
cmpl   $0x1,0x1c(%rsp)
jne    1200 <defaults_read+0x70>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1255 <defaults_read+0xc5>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1255 <defaults_read+0xc5>
call   10b0 <defaults_add@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1268 <defaults_read+0xd8>
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1200 <defaults_read+0x70>
call   1030 <free@plt>
movq   $0x0,0x8(%rsp)
jmp    1200 <defaults_read+0x70>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd8b(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11d9 <defaults_read+0x49>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xd6d(%rip),%rdi
call   1090 <perror@plt>
jmp    11d9 <defaults_read+0x49>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Could not read rc file \22%s\22: \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [24 x i8] c"Error parsing rc file.\0A\00"
define i32 @defaults_read(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 1, i32* %2
br label %68
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %3
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %68
20: ; preds = %11
br label %21
21: ; preds = %64, %20
%22 = load i32*, i32** %4
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %65
26: ; preds = %21
%27 = load i32*, i32** %4
%28 = call i64 @_defaults_rc_read_line(i32* %27, i8** %6, i8** %7, i32* %5, i32* null, i32* null)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32*, i32** %4
%34 = call i32 @fclose(i32* %33)
store i32 1, i32* %2
br label %68
35: ; preds = %26
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %61
38: ; preds = %35
%39 = load i8*, i8** %6
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i8*, i8** %7
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i8*, i8** %6
%46 = load i8*, i8** %7
%47 = call i32 @defaults_add(i8* %45, i8* %46)
br label %48
48: ; preds = %44, %41, %38
%49 = load i8*, i8** %6
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i8*, i8** %6
%53 = call i32 @free(i8* %52)
store i8* null, i8** %6
br label %54
54: ; preds = %51, %48
%55 = load i8*, i8** %7
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i8*, i8** %7
%59 = call i32 @free(i8* %58)
store i8* null, i8** %7
br label %60
60: ; preds = %57, %54
br label %61
61: ; preds = %60, %35
%62 = load i32*, i32** %4
%63 = call i32 @_defaults_rc_goto_eol(i32* %62)
br label %64
64: ; preds = %61
br label %21
65: ; preds = %21
%66 = load i32*, i32** %4
%67 = call i32 @fclose(i32* %66)
store i32 0, i32* %2
br label %68
68: ; preds = %65, %30, %15, %10
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Could not read rc file \22%s\22: \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [24 x i8] c"Error parsing rc file.\0A\00"
define i32 @defaults_read(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = icmp eq i8* %0, null
br i1 %8, label %54, label %9
9: ; preds = %1
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i32 @feof(i32* %10)
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %52
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%18 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %54
19: ; preds = %12, %48
%20 = call i64 @_defaults_rc_read_line(i32* %10, i8** %3, i8** %4, i32* %2, i32* null, i32* null)
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @fclose(i32* %10)
br label %54
26: ; preds = %19
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = icmp ne i8* %30, null
%32 = load i8*, i8** %4
%33 = icmp ne i8* %32, null
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 @defaults_add(i8* %30, i8* %32)
%37 = load i8*, i8** %3
br label %38
38: ; preds = %35, %29
%39 = phi i8* [ %37, %35 ], [ %30, %29 ]
%40 = icmp eq i8* %39, null
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = call i32 @free(i8* %39)
store i8* null, i8** %3
br label %43
43: ; preds = %41, %38
%44 = load i8*, i8** %4
%45 = icmp eq i8* %44, null
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @free(i8* %44)
store i8* null, i8** %4
br label %48
48: ; preds = %43, %46, %26
%49 = call i32 @_defaults_rc_goto_eol(i32* %10)
%50 = call i32 @feof(i32* %10)
%51 = icmp eq i32 %50, 0
br i1 %51, label %19, label %52
52: ; preds = %48, %12
%53 = call i32 @fclose(i32* %10)
br label %54
54: ; preds = %1, %52, %22, %15
%55 = phi i32 [ 1, %15 ], [ 1, %22 ], [ 0, %52 ], [ 1, %1 ]
ret i32 %55
}