#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 udev_list_entry {
  int dummy;
};
struct udev_device {
  int dummy;
};

/* Variables and functions */
struct udev_list_entry *
udev_device_get_properties_list_entry(struct udev_device *);
struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *,
                                                    char const *);
char const *udev_list_entry_get_value(struct udev_list_entry *);
__attribute__((visibility("default"))) const char *
udev_device_get_property_value(struct udev_device *udev_device,
                               const char *key) {
  struct udev_list_entry *list_entry;
  if (udev_device == NULL)
    return NULL;
  if (key == NULL)
    return NULL;
  list_entry = udev_device_get_properties_list_entry(udev_device);
  list_entry = udev_list_entry_get_by_name(list_entry, key);
  return udev_list_entry_get_value(list_entry);
}


x86 assembly (clang, -O0):
<udev_device_get_property_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <udev_device_get_property_value+0x28>
movq   $0x0,-0x8(%rbp)
jmp    119b <udev_device_get_property_value+0x6b>
cmpq   $0x0,-0x18(%rbp)
jne    1170 <udev_device_get_property_value+0x40>
movq   $0x0,-0x8(%rbp)
jmp    119b <udev_device_get_property_value+0x6b>
mov    -0x10(%rbp),%rdi
call   1040 <udev_device_get_properties_list_entry@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <udev_list_entry_get_by_name@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <udev_list_entry_get_value@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_get_property_value>:
push   %rbx
test   %rdi,%rdi
je     1157 <udev_device_get_property_value+0x27>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1157 <udev_device_get_property_value+0x27>
call   1040 <udev_device_get_properties_list_entry@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <udev_list_entry_get_by_name@plt>
mov    %rax,%rdi
pop    %rbx
jmp    1030 <udev_list_entry_get_value@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.udev_list_entry = type { i32 }
define i8* @udev_device_get_property_value(%struct.udev_device* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.udev_device*
%5 = alloca i8*
%6 = alloca %struct.udev_list_entry*
store %struct.udev_device* %0, %struct.udev_device** %4
store i8* %1, i8** %5
%7 = load %struct.udev_device*, %struct.udev_device** %4
%8 = icmp eq %struct.udev_device* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* null, i8** %3
br label %22
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %10
store i8* null, i8** %3
br label %22
14: ; preds = %10
%15 = load %struct.udev_device*, %struct.udev_device** %4
%16 = call %struct.udev_list_entry* @udev_device_get_properties_list_entry(%struct.udev_device* %15)
store %struct.udev_list_entry* %16, %struct.udev_list_entry** %6
%17 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%18 = load i8*, i8** %5
%19 = call %struct.udev_list_entry* @udev_list_entry_get_by_name(%struct.udev_list_entry* %17, i8* %18)
store %struct.udev_list_entry* %19, %struct.udev_list_entry** %6
%20 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%21 = call i8* @udev_list_entry_get_value(%struct.udev_list_entry* %20)
store i8* %21, i8** %3
br label %22
22: ; preds = %14, %13, %9
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev_list_entry = type { i32 }
define i8* @udev_device_get_property_value(%struct.udev_device* %0, i8* %1) {
%3 = icmp eq %struct.udev_device* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call %struct.udev_list_entry* @udev_device_get_properties_list_entry(%struct.udev_device* %0)
%8 = tail call %struct.udev_list_entry* @udev_list_entry_get_by_name(%struct.udev_list_entry* %7, i8* %1)
%9 = tail call i8* @udev_list_entry_get_value(%struct.udev_list_entry* %8)
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ null, %2 ]
ret i8* %11
}