#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 */
char *find_key(char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
int property_get(const char *key, char *value, const char *default_value) {
  char *ret = NULL;
  ret = find_key(key);
  if (ret == NULL) {
    if (default_value != NULL) {
      strcpy(value, default_value);
      return strlen(value);
    } else
      return 0;
  }
  if (ret) {
    strcpy(value, ret);
    free(ret);
    return strlen(value);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<property_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <find_key@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a9 <property_get+0x69>
cmpq   $0x0,-0x20(%rbp)
je     119d <property_get+0x5d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    11e2 <property_get+0xa2>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <property_get+0xa2>
cmpq   $0x0,-0x28(%rbp)
je     11db <property_get+0x9b>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    11e2 <property_get+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<property_get>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1060 <find_key@plt>
test   %rax,%rax
je     116d <property_get+0x2d>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    117d <property_get+0x3d>
test   %r14,%r14
je     118a <property_get+0x4a>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <strlen@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @property_get(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %8
%9 = load i8*, i8** %5
%10 = call i8* @find_key(i8* %9)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %4
br label %35
22: ; preds = %13
store i32 0, i32* %4
br label %35
23: ; preds = %3
%24 = load i8*, i8** %8
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i8*, i8** %6
%28 = load i8*, i8** %8
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %8
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %6
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %4
br label %35
34: ; preds = %23
store i32 0, i32* %4
br label %35
35: ; preds = %34, %26, %22, %16
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @property_get(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @find_key(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = icmp eq i8* %2, null
br i1 %7, label %15, label %8
8: ; preds = %6
%9 = tail call i32 @strcpy(i8* %1, i8* %2)
br label %13
10: ; preds = %3
%11 = tail call i32 @strcpy(i8* %1, i8* %4)
%12 = tail call i32 @free(i8* %4)
br label %13
13: ; preds = %8, %10
%14 = tail call i32 @strlen(i8* %1)
br label %15
15: ; preds = %13, %6
%16 = phi i32 [ 0, %6 ], [ %14, %13 ]
ret i32 %16
}