#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
char *strdup(char *);
int get_char_option(char *conf_path, char *name, char **val) {
  int fd;
  int cnt;
  char fname[512];
  char buf[256];
  char *endp;
  ;
  snprintf(fname, 512, "%s/%s", conf_path, name);
  if ((fd = open(fname, O_RDONLY)) < 0) {
    ;
    return -1;
  }
  cnt = read(fd, buf, 256);
  ;
  close(fd);
  if (cnt < 0) {
    return -1;
  }
  buf[cnt] = 0;
  *val = strdup(buf);
  return 0;
}


x86 assembly (clang, -O0):
<get_char_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x200,%esi
lea    0xe7e(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x230(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11b4 <get_char_option+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <get_char_option+0xc2>
mov    -0x24(%rbp),%edi
lea    -0x330(%rbp),%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x0,-0x28(%rbp)
jge    11e9 <get_char_option+0x99>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <get_char_option+0xc2>
movslq -0x28(%rbp),%rax
movb   $0x0,-0x330(%rbp,%rax,1)
lea    -0x330(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_char_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x308,%rsp
mov    %rdx,%r14
mov    %rsi,%r8
mov    %rdi,%rcx
lea    0xe93(%rip),%rdx
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1030 <snprintf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <open@plt>
mov    $0xffffffff,%r15d
test   %eax,%eax
js     11cf <get_char_option+0x7f>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <close@plt>
test   %ebp,%ebp
js     11cf <get_char_option+0x7f>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1070 <strdup@plt>
mov    %rax,(%r14)
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x308,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
define i32 @get_char_option(i8* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca [512 x i8]
%11 = alloca [256 x i8]
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = call i32 @snprintf(i8* %13, i32 512, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %8
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 -1, i32* %4
br label %38
22: ; preds = %3
%23 = load i32, i32* %8
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%25 = call i32 @read(i32 %23, i8* %24, i32 256)
store i32 %25, i32* %9
%26 = load i32, i32* %8
%27 = call i32 @close(i32 %26)
%28 = load i32, i32* %9
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 -1, i32* %4
br label %38
31: ; preds = %22
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %33
store i8 0, i8* %34
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%36 = call i8* @strdup(i8* %35)
%37 = load i8**, i8*** %7
store i8* %36, i8** %37
store i32 0, i32* %4
br label %38
38: ; preds = %31, %30, %21
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
define i32 @get_char_option(i8* %0, i8* %1, i8** nocapture writeonly %2) {
%4 = alloca [512 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i32 @snprintf(i8* %6, i32 512, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %6, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %3
%13 = call i32 @read(i32 %10, i8* %7, i32 256)
%14 = call i32 @close(i32 %10)
%15 = icmp slt i32 %13, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = zext i32 %13 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i8* @strdup(i8* %7)
store i8* %19, i8** %2
br label %20
20: ; preds = %12, %3, %16
%21 = phi i32 [ 0, %16 ], [ -1, %3 ], [ -1, %12 ]
ret i32 %21
}