#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 */
int /*<<< orphan*/ udev_device_add_property(struct udev_device *, char const *,
                                            char const *);
struct udev_list_entry *
udev_device_get_properties_list_entry(struct udev_device *);
char *udev_list_entry_get_name(struct udev_list_entry *);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *);
char *udev_list_entry_get_value(struct udev_list_entry *);
int udev_device_copy_properties(struct udev_device *dst,
                                struct udev_device *src) {
  struct udev_list_entry *entry;
  for ((entry = udev_device_get_properties_list_entry(src)); entry;
       entry = udev_list_entry_get_next(entry)) {
    const char *key, *value;
    key = udev_list_entry_get_name(entry);
    value = udev_list_entry_get_value(entry);
    udev_device_add_property(dst, key, value);
  }
  return 0;
}


x86 assembly (clang, -O0):
<udev_device_copy_properties>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <udev_device_get_properties_list_entry@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b5 <udev_device_copy_properties+0x65>
mov    -0x18(%rbp),%rdi
call   1060 <udev_list_entry_get_name@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <udev_list_entry_get_value@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <udev_device_add_property@plt>
mov    -0x18(%rbp),%rdi
call   1040 <udev_list_entry_get_next@plt>
mov    %rax,-0x18(%rbp)
jmp    116d <udev_device_copy_properties+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_copy_properties>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <udev_device_get_properties_list_entry@plt>
test   %rax,%rax
je     11a1 <udev_device_copy_properties+0x51>
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <udev_list_entry_get_name@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <udev_list_entry_get_value@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1070 <udev_device_add_property@plt>
mov    %rbx,%rdi
call   1040 <udev_list_entry_get_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <udev_device_copy_properties+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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