#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*/ close(int);
int open_prop_file(char const *, char const *, int *);
int read_entire_file(int, char **, size_t *);
int get_property(const char *prop_path, const char *prop_name, char **prop_val,
                 size_t *prop_len) {
  int rc, fd;
  rc = open_prop_file(prop_path, prop_name, &fd);
  if (rc)
    return rc;
  rc = read_entire_file(fd, prop_val, prop_len);
  close(fd);
  return rc;
}


x86 assembly (clang, -O0):
<get_property>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <open_prop_file@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1171 <get_property+0x41>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <get_property+0x62>
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <read_entire_file@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
call   1030 <close@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_property>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
lea    0xc(%rsp),%rdx
call   1050 <open_prop_file@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1168 <get_property+0x38>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <read_entire_file@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   1030 <close@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_property(i8* %0, i8* %1, i8** %2, i64* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8** %2, i8*** %8
store i64* %3, i64** %9
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = call i32 @open_prop_file(i8* %12, i8* %13, i32* %11)
store i32 %14, i32* %10
%15 = load i32, i32* %10
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load i32, i32* %10
store i32 %18, i32* %5
br label %27
19: ; preds = %4
%20 = load i32, i32* %11
%21 = load i8**, i8*** %8
%22 = load i64*, i64** %9
%23 = call i32 @read_entire_file(i32 %20, i8** %21, i64* %22)
store i32 %23, i32* %10
%24 = load i32, i32* %11
%25 = call i32 @close(i32 %24)
%26 = load i32, i32* %10
store i32 %26, i32* %5
br label %27
27: ; preds = %19, %17
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @get_property(i8* %0, i8* %1, i8** %2, i64* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i32 @open_prop_file(i8* %0, i8* %1, i32* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load i32, i32* %5
%11 = call i32 @read_entire_file(i32 %10, i8** %2, i64* %3)
%12 = load i32, i32* %5
%13 = call i32 @close(i32 %12)
br label %14
14: ; preds = %4, %9
%15 = phi i32 [ %11, %9 ], [ %7, %4 ]
ret i32 %15
}