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

/* Variables and functions */
int /*<<< orphan*/ list_append(struct list *, int /*<<< orphan*/);
int /*<<< orphan*/ list_get(struct list const *, unsigned int);
unsigned int list_size(struct list const *);
void list_append_list(struct list *l1, const struct list *l2) {
  for (unsigned int i = 1; i <= list_size(l2); ++i)
    list_append(l1, list_get(l2, i));
}


x86 assembly (clang, -O0):
<list_append_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <list_size@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
ja     1190 <list_append_list+0x60>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <list_get@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <list_append@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <list_append_list+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_append_list>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <list_size@plt>
test   %eax,%eax
je     1173 <list_append_list+0x43>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <list_get@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <list_append@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <list_size@plt>
cmp    %eax,%ebp
jbe    1150 <list_append_list+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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