#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_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ target_data_free(struct target_data *);
int /*<<< orphan*/ util_list_free(struct util_list *);
struct target_data *util_list_next(struct util_list *, struct target_data *);
int /*<<< orphan*/ util_list_remove(struct util_list *, struct target_data *);
struct target_data *util_list_start(struct util_list *);
void target_data_list_free(struct util_list *data) {
  struct target_data *td, *n;
  for (td = util_list_start(data), n = util_list_next(data, td); td != NULL;
       td = n, n = util_list_next(data, td)) {
    util_list_remove(data, td);
    target_data_free(td);
  }
  util_list_free(data);
}


x86 assembly (clang, -O0):
<target_data_list_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <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_data_list_free+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <util_list_remove@plt>
mov    -0x10(%rbp),%rdi
call   1050 <target_data_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_data_list_free+0x2a>
mov    -0x8(%rbp),%rdi
call   1070 <util_list_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<target_data_list_free>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <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_data_list_free+0x49>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <util_list_remove@plt>
mov    %rbx,%rdi
call   1050 <target_data_free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <util_list_next@plt>
mov    %r15,%rbx
test   %r15,%r15
jne    1170 <target_data_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_data = type { i32 }
define void @target_data_list_free(%struct.util_list* %0) {
%2 = alloca %struct.util_list*
%3 = alloca %struct.target_data*
%4 = alloca %struct.target_data*
store %struct.util_list* %0, %struct.util_list** %2
%5 = load %struct.util_list*, %struct.util_list** %2
%6 = call %struct.target_data* @util_list_start(%struct.util_list* %5)
store %struct.target_data* %6, %struct.target_data** %3
%7 = load %struct.util_list*, %struct.util_list** %2
%8 = load %struct.target_data*, %struct.target_data** %3
%9 = call %struct.target_data* @util_list_next(%struct.util_list* %7, %struct.target_data* %8)
store %struct.target_data* %9, %struct.target_data** %4
br label %10
10: ; preds = %19, %1
%11 = load %struct.target_data*, %struct.target_data** %3
%12 = icmp ne %struct.target_data* %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_data*, %struct.target_data** %3
%16 = call i32 @util_list_remove(%struct.util_list* %14, %struct.target_data* %15)
%17 = load %struct.target_data*, %struct.target_data** %3
%18 = call i32 @target_data_free(%struct.target_data* %17)
br label %19
19: ; preds = %13
%20 = load %struct.target_data*, %struct.target_data** %4
store %struct.target_data* %20, %struct.target_data** %3
%21 = load %struct.util_list*, %struct.util_list** %2
%22 = load %struct.target_data*, %struct.target_data** %3
%23 = call %struct.target_data* @util_list_next(%struct.util_list* %21, %struct.target_data* %22)
store %struct.target_data* %23, %struct.target_data** %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_data = type { i32 }
define void @target_data_list_free(%struct.util_list* %0) {
%2 = tail call %struct.target_data* @util_list_start(%struct.util_list* %0)
%3 = tail call %struct.target_data* @util_list_next(%struct.util_list* %0, %struct.target_data* %2)
%4 = icmp eq %struct.target_data* %2, null
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi %struct.target_data* [ %10, %5 ], [ %3, %1 ]
%7 = phi %struct.target_data* [ %6, %5 ], [ %2, %1 ]
%8 = tail call i32 @util_list_remove(%struct.util_list* %0, %struct.target_data* %7)
%9 = tail call i32 @target_data_free(%struct.target_data* %7)
%10 = tail call %struct.target_data* @util_list_next(%struct.util_list* %0, %struct.target_data* %6)
%11 = icmp eq %struct.target_data* %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
}