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

/* Variables and functions */
int /*<<< orphan*/ INIT_LIST_HEAD(struct list_head *);
int /*<<< orphan*/ __list_splice(struct list_head *, struct list_head *,
                                 struct list_head *);
int /*<<< orphan*/ list_empty(struct list_head *);
struct list_head *list_get_tail(struct list_head *);
void list_splice_tail_init(struct list_head *list, struct list_head *head) {
  struct list_head *tail = list_get_tail(head);
  if (!list_empty(list)) {
    __list_splice(list, tail, head);
    INIT_LIST_HEAD(list);
  }
}


x86 assembly (clang, -O0):
<list_splice_tail_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <list_get_tail@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <list_empty@plt>
cmp    $0x0,%eax
jne    1189 <list_splice_tail_init+0x49>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <__list_splice@plt>
mov    -0x8(%rbp),%rdi
call   1030 <INIT_LIST_HEAD@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_splice_tail_init>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <list_get_tail@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1060 <list_empty@plt>
test   %eax,%eax
je     1168 <list_splice_tail_init+0x28>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <__list_splice@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <INIT_LIST_HEAD@plt>

LLVM IR (-O0):
%struct.list_head = type { i32 }
define void @list_splice_tail_init(%struct.list_head* %0, %struct.list_head* %1) {
%3 = alloca %struct.list_head*
%4 = alloca %struct.list_head*
%5 = alloca %struct.list_head*
store %struct.list_head* %0, %struct.list_head** %3
store %struct.list_head* %1, %struct.list_head** %4
%6 = load %struct.list_head*, %struct.list_head** %4
%7 = call %struct.list_head* @list_get_tail(%struct.list_head* %6)
store %struct.list_head* %7, %struct.list_head** %5
%8 = load %struct.list_head*, %struct.list_head** %3
%9 = call i32 @list_empty(%struct.list_head* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %2
%12 = load %struct.list_head*, %struct.list_head** %3
%13 = load %struct.list_head*, %struct.list_head** %5
%14 = load %struct.list_head*, %struct.list_head** %4
%15 = call i32 @__list_splice(%struct.list_head* %12, %struct.list_head* %13, %struct.list_head* %14)
%16 = load %struct.list_head*, %struct.list_head** %3
%17 = call i32 @INIT_LIST_HEAD(%struct.list_head* %16)
br label %18
18: ; preds = %11, %2
ret void
}

LLVM IR (-O2):
%struct.list_head = type { i32 }
define void @list_splice_tail_init(%struct.list_head* %0, %struct.list_head* %1) {
%3 = tail call %struct.list_head* @list_get_tail(%struct.list_head* %1)
%4 = tail call i32 @list_empty(%struct.list_head* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @__list_splice(%struct.list_head* %0, %struct.list_head* %3, %struct.list_head* %1)
%8 = tail call i32 @INIT_LIST_HEAD(%struct.list_head* %0)
br label %9
9: ; preds = %6, %2
ret void
}