#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 util_list {
  int dummy;
};
struct target_entry {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ target_entry_free(struct target_entry *);
int /*<<< orphan*/ util_list_free(struct util_list *);
struct target_entry *util_list_next(struct util_list *, struct target_entry *);
int /*<<< orphan*/ util_list_remove(struct util_list *, struct target_entry *);
struct target_entry *util_list_start(struct util_list *);
void target_list_free(struct util_list *target_list) {
  struct target_entry *te, *n;
  for (te = util_list_start(target_list), n = util_list_next(target_list, te);
       te != NULL; te = n, n = util_list_next(target_list, te)) {
    util_list_remove(target_list, te);
    target_entry_free(te);
  }
  util_list_free(target_list);
}


x86 assembly (clang, -O0):
<target_list_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <util_list_start@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <util_list_next@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b9 <target_list_free+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <util_list_remove@plt>
mov    -0x10(%rbp),%rdi
call   1060 <target_entry_free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <util_list_next@plt>
mov    %rax,-0x18(%rbp)
jmp    117a <target_list_free+0x2a>
mov    -0x8(%rbp),%rdi
call   1070 <util_list_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<target_list_free>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <util_list_start@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <util_list_next@plt>
test   %rbx,%rbx
je     1199 <target_list_free+0x49>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <util_list_remove@plt>
mov    %rbx,%rdi
call   1060 <target_entry_free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <util_list_next@plt>
mov    %r15,%rbx
test   %r15,%r15
jne    1170 <target_list_free+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <util_list_free@plt>

LLVM IR (-O0):
%struct.util_list = type { i32 }
%struct.target_entry = type { i32 }
define void @target_list_free(%struct.util_list* %0) {
%2 = alloca %struct.util_list*
%3 = alloca %struct.target_entry*
%4 = alloca %struct.target_entry*
store %struct.util_list* %0, %struct.util_list** %2
%5 = load %struct.util_list*, %struct.util_list** %2
%6 = call %struct.target_entry* @util_list_start(%struct.util_list* %5)
store %struct.target_entry* %6, %struct.target_entry** %3
%7 = load %struct.util_list*, %struct.util_list** %2
%8 = load %struct.target_entry*, %struct.target_entry** %3
%9 = call %struct.target_entry* @util_list_next(%struct.util_list* %7, %struct.target_entry* %8)
store %struct.target_entry* %9, %struct.target_entry** %4
br label %10
10: ; preds = %19, %1
%11 = load %struct.target_entry*, %struct.target_entry** %3
%12 = icmp ne %struct.target_entry* %11, null
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load %struct.util_list*, %struct.util_list** %2
%15 = load %struct.target_entry*, %struct.target_entry** %3
%16 = call i32 @util_list_remove(%struct.util_list* %14, %struct.target_entry* %15)
%17 = load %struct.target_entry*, %struct.target_entry** %3
%18 = call i32 @target_entry_free(%struct.target_entry* %17)
br label %19
19: ; preds = %13
%20 = load %struct.target_entry*, %struct.target_entry** %4
store %struct.target_entry* %20, %struct.target_entry** %3
%21 = load %struct.util_list*, %struct.util_list** %2
%22 = load %struct.target_entry*, %struct.target_entry** %3
%23 = call %struct.target_entry* @util_list_next(%struct.util_list* %21, %struct.target_entry* %22)
store %struct.target_entry* %23, %struct.target_entry** %4
br label %10
24: ; preds = %10
%25 = load %struct.util_list*, %struct.util_list** %2
%26 = call i32 @util_list_free(%struct.util_list* %25)
ret void
}

LLVM IR (-O2):
%struct.util_list = type { i32 }
%struct.target_entry = type { i32 }
define void @target_list_free(%struct.util_list* %0) {
%2 = tail call %struct.target_entry* @util_list_start(%struct.util_list* %0)
%3 = tail call %struct.target_entry* @util_list_next(%struct.util_list* %0, %struct.target_entry* %2)
%4 = icmp eq %struct.target_entry* %2, null
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi %struct.target_entry* [ %10, %5 ], [ %3, %1 ]
%7 = phi %struct.target_entry* [ %6, %5 ], [ %2, %1 ]
%8 = tail call i32 @util_list_remove(%struct.util_list* %0, %struct.target_entry* %7)
%9 = tail call i32 @target_entry_free(%struct.target_entry* %7)
%10 = tail call %struct.target_entry* @util_list_next(%struct.util_list* %0, %struct.target_entry* %6)
%11 = icmp eq %struct.target_entry* %6, null
br i1 %11, label %12, label %5
12: ; preds = %5, %1
%13 = tail call i32 @util_list_free(%struct.util_list* %0)
ret void
}