#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 *hybris_propcache_find(char const *);
scalar_t__ property_get_socket(char const *, char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int property_get(const char *key, char *value, const char *default_value) {
  char *ret = NULL;
  if ((key) && (strlen(key) >= 32 - 1))
    return -1;
  if (value == NULL)
    return -1;
  if (property_get_socket(key, value, default_value) == 0)
    return strlen(value);
  ret = hybris_propcache_find(key);
  if (ret) {
    strcpy(value, ret);
    return strlen(value);
  } else if (default_value != NULL) {
    strcpy(value, default_value);
    return strlen(value);
  } else {
    value = '\0';
  }
  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)
cmpq   $0x0,-0x10(%rbp)
je     1185 <property_get+0x45>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1f,%eax
jl     1185 <property_get+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <property_get+0xfb>
cmpq   $0x0,-0x18(%rbp)
jne    119c <property_get+0x5c>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <property_get+0xfb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <property_get_socket@plt>
cmp    $0x0,%rax
jne    11c8 <property_get+0x88>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    123b <property_get+0xfb>
mov    -0x10(%rbp),%rdi
call   1050 <hybris_propcache_find@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <property_get+0xbe>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    123b <property_get+0xfb>
cmpq   $0x0,-0x20(%rbp)
je     1227 <property_get+0xe7>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    123b <property_get+0xfb>
movq   $0x0,-0x18(%rbp)
jmp    1234 <property_get+0xf4>
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
mov    %rdi,%rbx
test   %rdi,%rdi
je     116e <property_get+0x2e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %r15,%r15
je     11bc <property_get+0x7c>
cmp    $0x1e,%ecx
jle    1173 <property_get+0x33>
jmp    11bc <property_get+0x7c>
test   %r15,%r15
je     11b3 <property_get+0x73>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <property_get_socket@plt>
test   %rax,%rax
je     11a6 <property_get+0x66>
mov    %rbx,%rdi
call   1050 <hybris_propcache_find@plt>
test   %rax,%rax
jne    119b <property_get+0x5b>
mov    %r14,%rax
test   %r14,%r14
je     11ba <property_get+0x7a>
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strlen@plt>
mov    $0xffffffff,%eax
jmp    11bc <property_get+0x7c>
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 = icmp ne i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = icmp sge i32 %13, 31
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 -1, i32* %4
br label %52
16: ; preds = %11, %3
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 -1, i32* %4
br label %52
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = call i64 @property_get_socket(i8* %21, i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i8*, i8** %6
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %4
br label %52
29: ; preds = %20
%30 = load i8*, i8** %5
%31 = call i8* @hybris_propcache_find(i8* %30)
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = load i8*, i8** %6
%36 = load i8*, i8** %8
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %6
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %4
br label %52
40: ; preds = %29
%41 = load i8*, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i8*, i8** %6
%45 = load i8*, i8** %7
%46 = call i32 @strcpy(i8* %44, i8* %45)
%47 = load i8*, i8** %6
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %4
br label %52
49: ; preds = %40
store i8* null, i8** %6
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
store i32 0, i32* %4
br label %52
52: ; preds = %51, %43, %34, %26, %19, %15
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
define i32 @property_get(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 30
%8 = icmp eq i8* %1, null
%9 = or i1 %8, %7
br i1 %9, label %25, label %12
10: ; preds = %3
%11 = icmp eq i8* %1, null
br i1 %11, label %25, label %12
12: ; preds = %5, %10
%13 = tail call i64 @property_get_socket(i8* %0, i8* %1, i8* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = tail call i8* @hybris_propcache_find(i8* %0)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = icmp eq i8* %2, null
br i1 %19, label %25, label %20
20: ; preds = %18, %15
%21 = phi i8* [ %16, %15 ], [ %2, %18 ]
%22 = tail call i32 @strcpy(i8* %1, i8* %21)
br label %23
23: ; preds = %20, %12
%24 = tail call i32 @strlen(i8* %1)
br label %25
25: ; preds = %23, %18, %10, %5
%26 = phi i32 [ -1, %5 ], [ -1, %10 ], [ 0, %18 ], [ %24, %23 ]
ret i32 %26
}