#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 string {
  int dummy;
};
struct list_item {
  int dummy;
};
struct list {
  int dummy;
};

/* Variables and functions */
struct string *list_get_data(struct list_item *);
struct list_item *list_head(struct list *);
struct list_item *list_next(struct list_item *);
int /*<<< orphan*/ string_destroy(struct string *);
void destroy_strings_in_list(struct list *list) {
  struct list_item *item = list_head(list);
  while (item != NULL) {
    struct string *string = list_get_data(item);
    string_destroy(string);
    item = list_next(item);
  }
}


x86 assembly (clang, -O0):
<destroy_strings_in_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <list_head@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118c <destroy_strings_in_list+0x4c>
mov    -0x10(%rbp),%rdi
call   1040 <list_get_data@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <string_destroy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <list_next@plt>
mov    %rax,-0x10(%rbp)
jmp    1159 <destroy_strings_in_list+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destroy_strings_in_list>:
push   %rbx
call   1060 <list_head@plt>
test   %rax,%rax
je     1170 <destroy_strings_in_list+0x30>
mov    %rax,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <list_get_data@plt>
mov    %rax,%rdi
call   1030 <string_destroy@plt>
mov    %rbx,%rdi
call   1050 <list_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1150 <destroy_strings_in_list+0x10>
pop    %rbx
ret

LLVM IR (-O0):
%struct.list = type { i32 }
%struct.list_item = type { i32 }
%struct.string = type { i32 }
define void @destroy_strings_in_list(%struct.list* %0) {
%2 = alloca %struct.list*
%3 = alloca %struct.list_item*
%4 = alloca %struct.string*
store %struct.list* %0, %struct.list** %2
%5 = load %struct.list*, %struct.list** %2
%6 = call %struct.list_item* @list_head(%struct.list* %5)
store %struct.list_item* %6, %struct.list_item** %3
br label %7
7: ; preds = %10, %1
%8 = load %struct.list_item*, %struct.list_item** %3
%9 = icmp ne %struct.list_item* %8, null
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load %struct.list_item*, %struct.list_item** %3
%12 = call %struct.string* @list_get_data(%struct.list_item* %11)
store %struct.string* %12, %struct.string** %4
%13 = load %struct.string*, %struct.string** %4
%14 = call i32 @string_destroy(%struct.string* %13)
%15 = load %struct.list_item*, %struct.list_item** %3
%16 = call %struct.list_item* @list_next(%struct.list_item* %15)
store %struct.list_item* %16, %struct.list_item** %3
br label %7
17: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.list_item = type { i32 }
%struct.string = type { i32 }
define void @destroy_strings_in_list(%struct.list* %0) {
%2 = tail call %struct.list_item* @list_head(%struct.list* %0)
%3 = icmp eq %struct.list_item* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1, %4
%5 = phi %struct.list_item* [ %8, %4 ], [ %2, %1 ]
%6 = tail call %struct.string* @list_get_data(%struct.list_item* %5)
%7 = tail call i32 @string_destroy(%struct.string* %6)
%8 = tail call %struct.list_item* @list_next(%struct.list_item* %5)
%9 = icmp eq %struct.list_item* %8, null
br i1 %9, label %10, label %4
10: ; preds = %4, %1
ret void
}