#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 list {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ g_file_close(int);
int g_file_get_size(char const *);
int g_file_open(char const *);
int l_file_read_section(int, int, char const *, struct list *, struct list *);
int file_by_name_read_section(const char *file_name, const char *section,
                              struct list *names, struct list *values) {
  int fd;
  int file_size;
  int rv;
  file_size = g_file_get_size(file_name);
  if (file_size < 1) {
    return 1;
  }
  fd = g_file_open(file_name);
  if (fd < 0) {
    return 1;
  }
  rv = l_file_read_section(fd, file_size, section, names, values);
  g_file_close(fd);
  return rv;
}


x86 assembly (clang, -O0):
<file_by_name_read_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <g_file_get_size@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x30(%rbp)
jge    117a <file_by_name_read_section+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <file_by_name_read_section+0x84>
mov    -0x10(%rbp),%rdi
call   1040 <g_file_open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    119c <file_by_name_read_section+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <file_by_name_read_section+0x84>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <l_file_read_section@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <g_file_close@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_by_name_read_section>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
call   1050 <g_file_get_size@plt>
test   %eax,%eax
jle    118c <file_by_name_read_section+0x4c>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <g_file_open@plt>
test   %eax,%eax
js     118c <file_by_name_read_section+0x4c>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <l_file_read_section@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <g_file_close@plt>
mov    %ebp,%eax
jmp    1191 <file_by_name_read_section+0x51>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.list = type { i32 }
define i32 @file_by_name_read_section(i8* %0, i8* %1, %struct.list* %2, %struct.list* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.list*
%9 = alloca %struct.list*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store %struct.list* %2, %struct.list** %8
store %struct.list* %3, %struct.list** %9
%13 = load i8*, i8** %6
%14 = call i32 @g_file_get_size(i8* %13)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 1, i32* %5
br label %34
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = call i32 @g_file_open(i8* %19)
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %5
br label %34
24: ; preds = %18
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = load i8*, i8** %7
%28 = load %struct.list*, %struct.list** %8
%29 = load %struct.list*, %struct.list** %9
%30 = call i32 @l_file_read_section(i32 %25, i32 %26, i8* %27, %struct.list* %28, %struct.list* %29)
store i32 %30, i32* %12
%31 = load i32, i32* %10
%32 = call i32 @g_file_close(i32 %31)
%33 = load i32, i32* %12
store i32 %33, i32* %5
br label %34
34: ; preds = %24, %23, %17
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
%struct.list = type { i32 }
define i32 @file_by_name_read_section(i8* %0, i8* %1, %struct.list* %2, %struct.list* %3) {
%5 = tail call i32 @g_file_get_size(i8* %0)
%6 = icmp slt i32 %5, 1
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32 @g_file_open(i8* %0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @l_file_read_section(i32 %8, i32 %5, i8* %1, %struct.list* %2, %struct.list* %3)
%12 = tail call i32 @g_file_close(i32 %8)
br label %13
13: ; preds = %7, %4, %10
%14 = phi i32 [ %11, %10 ], [ 1, %4 ], [ 1, %7 ]
ret i32 %14
}