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

/* Variables and functions */
int /*<<< orphan*/ udev_list_entry_delete(struct udev_list_entry *);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *);
struct udev_list_entry *udev_list_get_entry(struct udev_list_node *);
void udev_list_cleanup_entries(struct udev *udev, struct udev_list_node *list) {
  struct udev_list_entry *entry_loop;
  struct udev_list_entry *entry_tmp;
  for (entry_loop = udev_list_get_entry(list),
      entry_tmp = udev_list_entry_get_next(entry_loop);
       entry_loop != NULL;
       entry_loop = entry_tmp, entry_tmp = udev_list_entry_get_next(entry_tmp))
    udev_list_entry_delete(entry_loop);
}


x86 assembly (clang, -O0):
<udev_list_cleanup_entries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <udev_list_get_entry@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <udev_list_entry_get_next@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1188 <udev_list_cleanup_entries+0x58>
mov    -0x18(%rbp),%rdi
call   1030 <udev_list_entry_delete@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <udev_list_entry_get_next@plt>
mov    %rax,-0x20(%rbp)
jmp    115a <udev_list_cleanup_entries+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_list_cleanup_entries>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdi
call   1050 <udev_list_get_entry@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <udev_list_entry_get_next@plt>
test   %r14,%r14
je     116b <udev_list_cleanup_entries+0x3b>
nopl   0x0(%rax)
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <udev_list_entry_delete@plt>
mov    %rbx,%rdi
call   1040 <udev_list_entry_get_next@plt>
mov    %rbx,%r14
test   %rbx,%rbx
jne    1150 <udev_list_cleanup_entries+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.udev = type { i32 }
%struct.udev_list_node = type { i32 }
%struct.udev_list_entry = type { i32 }
define void @udev_list_cleanup_entries(%struct.udev* %0, %struct.udev_list_node* %1) {
%3 = alloca %struct.udev*
%4 = alloca %struct.udev_list_node*
%5 = alloca %struct.udev_list_entry*
%6 = alloca %struct.udev_list_entry*
store %struct.udev* %0, %struct.udev** %3
store %struct.udev_list_node* %1, %struct.udev_list_node** %4
%7 = load %struct.udev_list_node*, %struct.udev_list_node** %4
%8 = call %struct.udev_list_entry* @udev_list_get_entry(%struct.udev_list_node* %7)
store %struct.udev_list_entry* %8, %struct.udev_list_entry** %5
%9 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%10 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %9)
store %struct.udev_list_entry* %10, %struct.udev_list_entry** %6
br label %11
11: ; preds = %17, %2
%12 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%13 = icmp ne %struct.udev_list_entry* %12, null
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%16 = call i32 @udev_list_entry_delete(%struct.udev_list_entry* %15)
br label %17
17: ; preds = %14
%18 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
store %struct.udev_list_entry* %18, %struct.udev_list_entry** %5
%19 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%20 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %19)
store %struct.udev_list_entry* %20, %struct.udev_list_entry** %6
br label %11
21: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.udev = type { i32 }
%struct.udev_list_node = type { i32 }
%struct.udev_list_entry = type { i32 }
define void @udev_list_cleanup_entries(%struct.udev* nocapture readnone %0, %struct.udev_list_node* %1) {
%3 = tail call %struct.udev_list_entry* @udev_list_get_entry(%struct.udev_list_node* %1)
%4 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %3)
%5 = icmp eq %struct.udev_list_entry* %3, null
br i1 %5, label %12, label %6
6: ; preds = %2, %6
%7 = phi %struct.udev_list_entry* [ %10, %6 ], [ %4, %2 ]
%8 = phi %struct.udev_list_entry* [ %7, %6 ], [ %3, %2 ]
%9 = tail call i32 @udev_list_entry_delete(%struct.udev_list_entry* %8)
%10 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %7)
%11 = icmp eq %struct.udev_list_entry* %7, null
br i1 %11, label %12, label %6
12: ; preds = %6, %2
ret void
}