#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*/ alternate_split(struct list *, struct list **,
                                   struct list **);
struct list *list_constructor_head(int);
int /*<<< orphan*/ list_print(struct list *);
int /*<<< orphan*/ printf(char *);
int main(int argc, const char *argv[]) {
  struct list *head1 = NULL;
  struct list *head2 = NULL;
  struct list *head3 = NULL;
  head1 = list_constructor_head(10);
  list_print(head1);
  alternate_split(head1, &head2, &head3);
  printf("Source:\n");
  list_print(head1);
  printf("Alt1:\n");
  list_print(head2);
  printf("Alt2:\n");
  list_print(head3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0xa,%edi
call   1040 <list_constructor_head@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <list_print@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <alternate_split@plt>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <list_print@plt>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <list_print@plt>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <list_print@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    $0xa,%edi
call   1040 <list_constructor_head@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <list_print@plt>
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1060 <alternate_split@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <list_print@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1050 <list_print@plt>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
call   1050 <list_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [9 x i8] c"Source:\0A\00"
@.str.1 = [7 x i8] c"Alt1:\0A\00"
@.str.2 = [7 x i8] c"Alt2:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.list*
%7 = alloca %struct.list*
%8 = alloca %struct.list*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.list* null, %struct.list** %6
store %struct.list* null, %struct.list** %7
store %struct.list* null, %struct.list** %8
%9 = call %struct.list* @list_constructor_head(i32 10)
store %struct.list* %9, %struct.list** %6
%10 = load %struct.list*, %struct.list** %6
%11 = call i32 @list_print(%struct.list* %10)
%12 = load %struct.list*, %struct.list** %6
%13 = call i32 @alternate_split(%struct.list* %12, %struct.list** %7, %struct.list** %8)
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%15 = load %struct.list*, %struct.list** %6
%16 = call i32 @list_print(%struct.list* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = load %struct.list*, %struct.list** %7
%19 = call i32 @list_print(%struct.list* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = load %struct.list*, %struct.list** %8
%22 = call i32 @list_print(%struct.list* %21)
ret i32 0
}

LLVM IR (-O2):
%struct.list = type { i32 }
@str = [8 x i8] c"Source:\00"
@str.3 = [6 x i8] c"Alt1:\00"
@str.4 = [6 x i8] c"Alt2:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.list*
%4 = alloca %struct.list*
%5 = bitcast %struct.list** %3 to i8*
store %struct.list* null, %struct.list** %3
%6 = bitcast %struct.list** %4 to i8*
store %struct.list* null, %struct.list** %4
%7 = tail call %struct.list* @list_constructor_head(i32 10)
%8 = tail call i32 @list_print(%struct.list* %7)
%9 = call i32 @alternate_split(%struct.list* %7, %struct.list** %3, %struct.list** %4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%11 = call i32 @list_print(%struct.list* %7)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0))
%13 = load %struct.list*, %struct.list** %3
%14 = call i32 @list_print(%struct.list* %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
%16 = load %struct.list*, %struct.list** %4
%17 = call i32 @list_print(%struct.list* %16)
ret i32 0
}