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

/* Variables and functions */
int /*<<< orphan*/ list_append(struct list *, int /*<<< orphan*/);
struct list_it *list_it(struct list *);
int /*<<< orphan*/ list_it_data(struct list_it *);
struct list_it *list_it_next(struct list_it *);
void list_append_list(struct list *dst, const struct list *src) {
  struct list *s = (struct list *)src;
  struct list_it *it;
  for (it = list_it(s); it != NULL; it = list_it_next(it)) {
    list_append(dst, list_it_data(it));
  }
}


x86 assembly (clang, -O0):
<list_append_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <list_it@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119e <list_append_list+0x5e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <list_it_data@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1060 <list_append@plt>
mov    -0x20(%rbp),%rdi
call   1040 <list_it_next@plt>
mov    %rax,-0x20(%rbp)
jmp    1165 <list_append_list+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_append_list>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <list_it@plt>
test   %rax,%rax
je     1182 <list_append_list+0x42>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <list_it_data@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <list_append@plt>
mov    %rbx,%rdi
call   1040 <list_it_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1160 <list_append_list+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.list_it = type { i32 }
define void @list_append_list(%struct.list* %0, %struct.list* %1) {
%3 = tail call %struct.list_it* @list_it(%struct.list* %1)
%4 = icmp eq %struct.list_it* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2, %5
%6 = phi %struct.list_it* [ %9, %5 ], [ %3, %2 ]
%7 = tail call i32 @list_it_data(%struct.list_it* %6)
%8 = tail call i32 @list_append(%struct.list* %0, i32 %7)
%9 = tail call %struct.list_it* @list_it_next(%struct.list_it* %6)
%10 = icmp eq %struct.list_it* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %2
ret void
}