#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 **);
void alteratingSplit(struct node *source, struct node **aRef,
                     struct node **bRef) {
  int i = 0;
  while (source != NULL) {
    if (i % 2 == 0) {
      moveNode(aRef, &source);
    } else {
      moveNode(bRef, &source);
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<alteratingSplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1177 <alteratingSplit+0x67>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115c <alteratingSplit+0x4c>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <moveNode@plt>
jmp    1169 <alteratingSplit+0x59>
mov    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <moveNode@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <alteratingSplit+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alteratingSplit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %rdi,%rdi
je     114d <alteratingSplit+0x3d>
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %ebp,%ebp
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
test   $0x1,%bpl
mov    %r14,%rdi
cmove  %rbx,%rdi
mov    %r15,%rsi
call   1030 <moveNode@plt>
add    $0x1,%ebp
cmpq   $0x0,(%rsp)
jne    1130 <alteratingSplit+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define void @alteratingSplit(%struct.node* %0, %struct.node** %1, %struct.node** %2) {
%4 = alloca %struct.node*
%5 = alloca %struct.node**
%6 = alloca %struct.node**
%7 = alloca i32
store %struct.node* %0, %struct.node** %4
store %struct.node** %1, %struct.node*** %5
store %struct.node** %2, %struct.node*** %6
store i32 0, i32* %7
br label %8
8: ; preds = %21, %3
%9 = load %struct.node*, %struct.node** %4
%10 = icmp ne %struct.node* %9, null
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i32, i32* %7
%13 = srem i32 %12, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load %struct.node**, %struct.node*** %5
%17 = call i32 @moveNode(%struct.node** %16, %struct.node** %4)
br label %21
18: ; preds = %11
%19 = load %struct.node**, %struct.node*** %6
%20 = call i32 @moveNode(%struct.node** %19, %struct.node** %4)
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
define void @alteratingSplit(%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 %15, label %6
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ 0, %3 ]
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, %struct.node** %1, %struct.node** %2
%11 = call i32 @moveNode(%struct.node** %10, %struct.node** %4)
%12 = add nuw nsw i32 %7, 1
%13 = load %struct.node*, %struct.node** %4
%14 = icmp eq %struct.node* %13, null
br i1 %14, label %15, label %6
15: ; preds = %6, %3
ret void
}