#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_sections(int, int, struct list *);
int file_by_name_read_sections(const char *file_name, struct list *names) {
  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 < 1) {
    return 1;
  }
  rv = l_file_read_sections(fd, file_size, names);
  g_file_close(fd);
  return rv;
}


x86 assembly (clang, -O0):
<file_by_name_read_sections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <g_file_get_size@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    1172 <file_by_name_read_sections+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11b4 <file_by_name_read_sections+0x74>
mov    -0x10(%rbp),%rdi
call   1030 <g_file_open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    1194 <file_by_name_read_sections+0x54>
movl   $0x1,-0x4(%rbp)
jmp    11b4 <file_by_name_read_sections+0x74>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <l_file_read_sections@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <g_file_close@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_by_name_read_sections>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <g_file_get_size@plt>
test   %eax,%eax
jle    117c <file_by_name_read_sections+0x3c>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <g_file_open@plt>
test   %eax,%eax
jle    117c <file_by_name_read_sections+0x3c>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
mov    %r14,%rdx
call   1050 <l_file_read_sections@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <g_file_close@plt>
mov    %ebp,%eax
jmp    1181 <file_by_name_read_sections+0x41>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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