#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*/ getchar();
int /*<<< orphan*/ merge(struct node *, struct node **);
int /*<<< orphan*/ printList(struct node *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(struct node **, int);
int main() {
  struct node *p = NULL, *q = NULL;
  push(&p, 3);
  push(&p, 2);
  push(&p, 1);
  printf("First linked list: \n");
  printList(p);
  push(&q, 8);
  push(&q, 7);
  push(&q, 6);
  push(&q, 5);
  push(&q, 4);
  printf("Second linked list:\n");
  printList(q);
  merge(p, &q);
  printf("Modified first linked list:\n");
  printList(p);
  printf("Modified second linked list:\n");
  printList(q);
  getchar();
  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    $0x3,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <push@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <printList@plt>
lea    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1060 <push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x7,%esi
call   1060 <push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x6,%esi
call   1060 <push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1060 <push@plt>
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1060 <push@plt>
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <printList@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <merge@plt>
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <printList@plt>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <printList@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <push@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
call   1070 <printList@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <push@plt>
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1070 <printList@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1050 <merge@plt>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
call   1070 <printList@plt>
lea    0xe1b(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1070 <printList@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [21 x i8] c"First linked list: \0A\00"
@.str.1 = [21 x i8] c"Second linked list:\0A\00"
@.str.2 = [29 x i8] c"Modified first linked list:\0A\00"
@.str.3 = [30 x i8] c"Modified second linked list:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca %struct.node*
store i32 0, i32* %1
store %struct.node* null, %struct.node** %2
store %struct.node* null, %struct.node** %3
%4 = call i32 @push(%struct.node** %2, i32 3)
%5 = call i32 @push(%struct.node** %2, i32 2)
%6 = call i32 @push(%struct.node** %2, i32 1)
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.node*, %struct.node** %2
%9 = call i32 @printList(%struct.node* %8)
%10 = call i32 @push(%struct.node** %3, i32 8)
%11 = call i32 @push(%struct.node** %3, i32 7)
%12 = call i32 @push(%struct.node** %3, i32 6)
%13 = call i32 @push(%struct.node** %3, i32 5)
%14 = call i32 @push(%struct.node** %3, i32 4)
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%16 = load %struct.node*, %struct.node** %3
%17 = call i32 @printList(%struct.node* %16)
%18 = load %struct.node*, %struct.node** %2
%19 = call i32 @merge(%struct.node* %18, %struct.node** %3)
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%21 = load %struct.node*, %struct.node** %2
%22 = call i32 @printList(%struct.node* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%24 = load %struct.node*, %struct.node** %3
%25 = call i32 @printList(%struct.node* %24)
%26 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@str = [20 x i8] c"First linked list: \00"
@str.4 = [20 x i8] c"Second linked list:\00"
@str.5 = [28 x i8] c"Modified first linked list:\00"
@str.6 = [29 x i8] c"Modified second linked list:\00"
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 @push(%struct.node** %1, i32 3)
%6 = call i32 @push(%struct.node** %1, i32 2)
%7 = call i32 @push(%struct.node** %1, i32 1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = load %struct.node*, %struct.node** %1
%10 = call i32 @printList(%struct.node* %9)
%11 = call i32 @push(%struct.node** %2, i32 8)
%12 = call i32 @push(%struct.node** %2, i32 7)
%13 = call i32 @push(%struct.node** %2, i32 6)
%14 = call i32 @push(%struct.node** %2, i32 5)
%15 = call i32 @push(%struct.node** %2, i32 4)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
%17 = load %struct.node*, %struct.node** %2
%18 = call i32 @printList(%struct.node* %17)
%19 = load %struct.node*, %struct.node** %1
%20 = call i32 @merge(%struct.node* %19, %struct.node** %2)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%22 = load %struct.node*, %struct.node** %1
%23 = call i32 @printList(%struct.node* %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%25 = load %struct.node*, %struct.node** %2
%26 = call i32 @printList(%struct.node* %25)
%27 = call i32 (...) @getchar()
ret i32 0
}