#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*/ insertNode(struct node **, int);
struct node *mergelist(struct node *, struct node *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printlist(struct node *);
int main() {
  struct node *head1 = NULL;
  struct node *head2 = NULL;
  insertNode(&head1, 2);
  insertNode(&head1, 4);
  insertNode(&head1, 6);
  insertNode(&head1, 8);
  insertNode(&head1, 10);
  printlist(head1);
  printf("\n");
  insertNode(&head2, 1);
  insertNode(&head2, 3);
  insertNode(&head2, 5);
  insertNode(&head2, 9);
  insertNode(&head2, 12);
  printlist(head2);
  struct node *result = mergelist(head1, head2);
  printf("\n");
  printlist(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1030 <insertNode@plt>
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1030 <insertNode@plt>
lea    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1030 <insertNode@plt>
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1030 <insertNode@plt>
lea    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1030 <insertNode@plt>
mov    -0x10(%rbp),%rdi
call   1060 <printlist@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1030 <insertNode@plt>
lea    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1030 <insertNode@plt>
lea    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1030 <insertNode@plt>
lea    -0x18(%rbp),%rdi
mov    $0x9,%esi
call   1030 <insertNode@plt>
lea    -0x18(%rbp),%rdi
mov    $0xc,%esi
call   1030 <insertNode@plt>
mov    -0x18(%rbp),%rdi
call   1060 <printlist@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <mergelist@plt>
mov    %rax,-0x20(%rbp)
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <printlist@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <insertNode@plt>
mov    0x8(%rsp),%rdi
call   1060 <printlist@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <insertNode@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1040 <insertNode@plt>
mov    (%rsp),%rdi
call   1060 <printlist@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1050 <mergelist@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <printlist@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.node = type { i32 }
define i32 @main() {
%1 = alloca %struct.node*
%2 = alloca %struct.node*
%3 = bitcast %struct.node** %1 to i8*
store %struct.node* null, %struct.node** %1
%4 = bitcast %struct.node** %2 to i8*
store %struct.node* null, %struct.node** %2
%5 = call i32 @insertNode(%struct.node** %1, i32 2)
%6 = call i32 @insertNode(%struct.node** %1, i32 4)
%7 = call i32 @insertNode(%struct.node** %1, i32 6)
%8 = call i32 @insertNode(%struct.node** %1, i32 8)
%9 = call i32 @insertNode(%struct.node** %1, i32 10)
%10 = load %struct.node*, %struct.node** %1
%11 = call i32 @printlist(%struct.node* %10)
%12 = call i32 @putchar(i32 10)
%13 = call i32 @insertNode(%struct.node** %2, i32 1)
%14 = call i32 @insertNode(%struct.node** %2, i32 3)
%15 = call i32 @insertNode(%struct.node** %2, i32 5)
%16 = call i32 @insertNode(%struct.node** %2, i32 9)
%17 = call i32 @insertNode(%struct.node** %2, i32 12)
%18 = load %struct.node*, %struct.node** %2
%19 = call i32 @printlist(%struct.node* %18)
%20 = load %struct.node*, %struct.node** %1
%21 = load %struct.node*, %struct.node** %2
%22 = call %struct.node* @mergelist(%struct.node* %20, %struct.node* %21)
%23 = call i32 @putchar(i32 10)
%24 = call i32 @printlist(%struct.node* %22)
ret i32 0
}