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

/* Variables and functions */
int /*<<< orphan*/ MoveNode(struct node **, struct node **);
int /*<<< orphan*/ print_linked_list(char *, struct node **);
void AlternatingSplit(struct node *source, struct node **aRef,
                      struct node **bRef) {
  while (source != NULL) {
    MoveNode(aRef, &source);
    if (source != NULL)
      MoveNode(bRef, &source);
  }
  print_linked_list("aRef", aRef);
  print_linked_list("bRef", bRef);
}


x86 assembly (clang, -O0):
<AlternatingSplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1169 <AlternatingSplit+0x49>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <MoveNode@plt>
cmpq   $0x0,-0x8(%rbp)
je     1164 <AlternatingSplit+0x44>
mov    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <MoveNode@plt>
jmp    1134 <AlternatingSplit+0x14>
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <print_linked_list@plt>
mov    -0x18(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1030 <print_linked_list@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AlternatingSplit>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,0x8(%rsp)
test   %rdi,%rdi
je     1166 <AlternatingSplit+0x46>
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <MoveNode@plt>
cmpq   $0x0,0x8(%rsp)
je     1166 <AlternatingSplit+0x46>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <MoveNode@plt>
cmpq   $0x0,0x8(%rsp)
jne    1140 <AlternatingSplit+0x20>
lea    0xe93(%rip),%rdi
mov    %r15,%rsi
call   1030 <print_linked_list@plt>
lea    0xe89(%rip),%rdi
mov    %r14,%rsi
call   1030 <print_linked_list@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [5 x i8] c"aRef\00"
@.str.1 = [5 x i8] c"bRef\00"
define void @AlternatingSplit(%struct.node* %0, %struct.node** %1, %struct.node** %2) {
%4 = alloca %struct.node*
%5 = alloca %struct.node**
%6 = alloca %struct.node**
store %struct.node* %0, %struct.node** %4
store %struct.node** %1, %struct.node*** %5
store %struct.node** %2, %struct.node*** %6
br label %7
7: ; preds = %18, %3
%8 = load %struct.node*, %struct.node** %4
%9 = icmp ne %struct.node* %8, null
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load %struct.node**, %struct.node*** %5
%12 = call i32 @MoveNode(%struct.node** %11, %struct.node** %4)
%13 = load %struct.node*, %struct.node** %4
%14 = icmp ne %struct.node* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load %struct.node**, %struct.node*** %6
%17 = call i32 @MoveNode(%struct.node** %16, %struct.node** %4)
br label %18
18: ; preds = %15, %10
br label %7
19: ; preds = %7
%20 = load %struct.node**, %struct.node*** %5
%21 = call i32 @print_linked_list(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.node** %20)
%22 = load %struct.node**, %struct.node*** %6
%23 = call i32 @print_linked_list(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.node** %22)
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [5 x i8] c"aRef\00"
@.str.1 = [5 x i8] c"bRef\00"
define void @AlternatingSplit(%struct.node* %0, %struct.node** %1, %struct.node** %2) {
%4 = alloca %struct.node*
store %struct.node* %0, %struct.node** %4
%5 = icmp eq %struct.node* %0, null
br i1 %5, label %14, label %6
6: ; preds = %3, %10
%7 = call i32 @MoveNode(%struct.node** %1, %struct.node** %4)
%8 = load %struct.node*, %struct.node** %4
%9 = icmp eq %struct.node* %8, null
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = call i32 @MoveNode(%struct.node** %2, %struct.node** %4)
%12 = load %struct.node*, %struct.node** %4
%13 = icmp eq %struct.node* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %10, %3
%15 = call i32 @print_linked_list(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.node** %1)
%16 = call i32 @print_linked_list(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.node** %2)
ret void
}