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

/* Variables and functions */
struct l_node *insert_node(struct l_node *, int);
int /*<<< orphan*/ print_list(struct l_node *);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ split_list(struct l_node *, struct l_node **,
                              struct l_node **);
int main(int argc, char *argv[]) {
  struct l_node *head = NULL;
  struct l_node *first = NULL;
  struct l_node *second = NULL;
  int i;
  for (i = 0; i < 13; i++)
    head = insert_node(head, rand() % 1234);
  printf("State of the list is as below -\n\n");
  print_list(head);
  printf("\n\n");
  split_list(head, &first, &second);
  printf("First half of the list -\t");
  print_list(first);
  printf("\n\n");
  printf("Second half of the list -\t");
  print_list(second);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xd,-0x2c(%rbp)
jge    11c3 <main+0x73>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x38(%rbp),%rdi
mov    $0x4d2,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1060 <insert_node@plt>
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1185 <main+0x35>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <print_list@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <split_list@plt>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <print_list@plt>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <print_list@plt>
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
xor    %edi,%edi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0xffffffffd46f3235,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xa,%eax
add    %ecx,%eax
imul   $0x4d2,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1070 <insert_node@plt>
mov    %rax,%rbx
lea    0xc12(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <print_list@plt>
lea    0xc1d(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <split_list@plt>
lea    0xba8(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rsp),%rdi
call   1040 <print_list@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xba4(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <print_list@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.l_node = type { i32 }
@.str = [34 x i8] c"State of the list is as below -\0A\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [26 x i8] c"First half of the list -\09\00"
@.str.3 = [27 x i8] c"Second half of the list -\09\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.l_node*
%7 = alloca %struct.l_node*
%8 = alloca %struct.l_node*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.l_node* null, %struct.l_node** %6
store %struct.l_node* null, %struct.l_node** %7
store %struct.l_node* null, %struct.l_node** %8
store i32 0, i32* %9
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 13
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load %struct.l_node*, %struct.l_node** %6
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 1234
%17 = call %struct.l_node* @insert_node(%struct.l_node* %14, i32 %16)
store %struct.l_node* %17, %struct.l_node** %6
br label %18
18: ; preds = %13
%19 = load i32, i32* %9
%20 = add nsw i32 %19, 1
store i32 %20, i32* %9
br label %10
21: ; preds = %10
%22 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%23 = load %struct.l_node*, %struct.l_node** %6
%24 = call i32 @print_list(%struct.l_node* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = load %struct.l_node*, %struct.l_node** %6
%27 = call i32 @split_list(%struct.l_node* %26, %struct.l_node** %7, %struct.l_node** %8)
%28 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%29 = load %struct.l_node*, %struct.l_node** %7
%30 = call i32 @print_list(%struct.l_node* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%33 = load %struct.l_node*, %struct.l_node** %8
%34 = call i32 @print_list(%struct.l_node* %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.l_node = type { i32 }
@.str.2 = [26 x i8] c"First half of the list -\09\00"
@.str.3 = [27 x i8] c"Second half of the list -\09\00"
@str = [33 x i8] c"State of the list is as below -\0A\00"
@str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.l_node*
%4 = alloca %struct.l_node*
%5 = bitcast %struct.l_node** %3 to i8*
store %struct.l_node* null, %struct.l_node** %3
%6 = bitcast %struct.l_node** %4 to i8*
store %struct.l_node* null, %struct.l_node** %4
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1234
%9 = tail call %struct.l_node* @insert_node(%struct.l_node* null, i32 %8)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 1234
%12 = tail call %struct.l_node* @insert_node(%struct.l_node* %9, i32 %11)
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 1234
%15 = tail call %struct.l_node* @insert_node(%struct.l_node* %12, i32 %14)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 1234
%18 = tail call %struct.l_node* @insert_node(%struct.l_node* %15, i32 %17)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 1234
%21 = tail call %struct.l_node* @insert_node(%struct.l_node* %18, i32 %20)
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 1234
%24 = tail call %struct.l_node* @insert_node(%struct.l_node* %21, i32 %23)
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 1234
%27 = tail call %struct.l_node* @insert_node(%struct.l_node* %24, i32 %26)
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 1234
%30 = tail call %struct.l_node* @insert_node(%struct.l_node* %27, i32 %29)
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 1234
%33 = tail call %struct.l_node* @insert_node(%struct.l_node* %30, i32 %32)
%34 = tail call i32 (...) @rand()
%35 = srem i32 %34, 1234
%36 = tail call %struct.l_node* @insert_node(%struct.l_node* %33, i32 %35)
%37 = tail call i32 (...) @rand()
%38 = srem i32 %37, 1234
%39 = tail call %struct.l_node* @insert_node(%struct.l_node* %36, i32 %38)
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 1234
%42 = tail call %struct.l_node* @insert_node(%struct.l_node* %39, i32 %41)
%43 = tail call i32 (...) @rand()
%44 = srem i32 %43, 1234
%45 = tail call %struct.l_node* @insert_node(%struct.l_node* %42, i32 %44)
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%47 = tail call i32 @print_list(%struct.l_node* %45)
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%49 = call i32 @split_list(%struct.l_node* %45, %struct.l_node** %3, %struct.l_node** %4)
%50 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%51 = load %struct.l_node*, %struct.l_node** %3
%52 = call i32 @print_list(%struct.l_node* %51)
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%54 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%55 = load %struct.l_node*, %struct.l_node** %4
%56 = call i32 @print_list(%struct.l_node* %55)
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}