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

/* Variables and functions */
int /*<<< orphan*/ target_status_free(struct target_status *);
int /*<<< orphan*/ util_list_free(struct util_list *);
struct target_status *util_list_next(struct util_list *,
                                     struct target_status *);
int /*<<< orphan*/ util_list_remove(struct util_list *, struct target_status *);
struct target_status *util_list_start(struct util_list *);
void status_list_free(struct util_list *status) {
  struct target_status *ts, *n;
  for (ts = util_list_start(status), n = util_list_next(status, ts); ts != NULL;
       ts = n, n = util_list_next(status, ts)) {
    util_list_remove(status, ts);
    target_status_free(ts);
  }
  util_list_free(status);
}


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

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