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

/* Variables and functions */
struct ListNode *createList(int *, int);
int /*<<< orphan*/ freeList(struct ListNode *);
struct ListNode *mergeTwoLists(struct ListNode *, struct ListNode *);
int /*<<< orphan*/ printList(struct ListNode *);
struct ListNode *sortList(struct ListNode *);
int main(void) {
  int arr1[1] = {2};
  int arr2[1] = {1};
  struct ListNode *l1 = NULL;
  struct ListNode *l2 = NULL;
  struct ListNode *res = NULL;
  l1 = createList(arr1, 1);
  l2 = createList(arr2, 1);
  l1 = sortList(l1);
  l2 = sortList(l2);
  res = mergeTwoLists(l1, l2);
  printList(res);
  freeList(l1);
  freeList(l2);
  freeList(res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xe96(%rip),%eax
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1050 <createList@plt>
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x1,%esi
call   1050 <createList@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sortList@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <sortList@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <mergeTwoLists@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <printList@plt>
mov    -0x18(%rbp),%rdi
call   1030 <freeList@plt>
mov    -0x20(%rbp),%rdi
call   1030 <freeList@plt>
mov    -0x28(%rbp),%rdi
call   1030 <freeList@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x2,0xc(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
call   1050 <createList@plt>
mov    %rax,%r14
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1050 <createList@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <sortList@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <sortList@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <mergeTwoLists@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %r14,%rdi
call   1030 <freeList@plt>
mov    %r15,%rdi
call   1030 <freeList@plt>
mov    %rbx,%rdi
call   1030 <freeList@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
@__const.main.arr1 = [1 x i32] [i32 2]
@__const.main.arr2 = [1 x i32] [i32 1]
define i32 @main() {
%1 = alloca i32
%2 = alloca [1 x i32]
%3 = alloca [1 x i32]
%4 = alloca %struct.ListNode*
%5 = alloca %struct.ListNode*
%6 = alloca %struct.ListNode*
store i32 0, i32* %1
%7 = bitcast [1 x i32]* %2 to i8*
%8 = bitcast [1 x i32]* %3 to i8*
store %struct.ListNode* null, %struct.ListNode** %4
store %struct.ListNode* null, %struct.ListNode** %5
store %struct.ListNode* null, %struct.ListNode** %6
%9 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%10 = call %struct.ListNode* @createList(i32* %9, i32 1)
store %struct.ListNode* %10, %struct.ListNode** %4
%11 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%12 = call %struct.ListNode* @createList(i32* %11, i32 1)
store %struct.ListNode* %12, %struct.ListNode** %5
%13 = load %struct.ListNode*, %struct.ListNode** %4
%14 = call %struct.ListNode* @sortList(%struct.ListNode* %13)
store %struct.ListNode* %14, %struct.ListNode** %4
%15 = load %struct.ListNode*, %struct.ListNode** %5
%16 = call %struct.ListNode* @sortList(%struct.ListNode* %15)
store %struct.ListNode* %16, %struct.ListNode** %5
%17 = load %struct.ListNode*, %struct.ListNode** %4
%18 = load %struct.ListNode*, %struct.ListNode** %5
%19 = call %struct.ListNode* @mergeTwoLists(%struct.ListNode* %17, %struct.ListNode* %18)
store %struct.ListNode* %19, %struct.ListNode** %6
%20 = load %struct.ListNode*, %struct.ListNode** %6
%21 = call i32 @printList(%struct.ListNode* %20)
%22 = load %struct.ListNode*, %struct.ListNode** %4
%23 = call i32 @freeList(%struct.ListNode* %22)
%24 = load %struct.ListNode*, %struct.ListNode** %5
%25 = call i32 @freeList(%struct.ListNode* %24)
%26 = load %struct.ListNode*, %struct.ListNode** %6
%27 = call i32 @freeList(%struct.ListNode* %26)
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
define i32 @main() {
%1 = alloca [1 x i32]
%2 = alloca [1 x i32]
%3 = bitcast [1 x i32]* %1 to i8*
%4 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
store i32 2, i32* %4
%5 = bitcast [1 x i32]* %2 to i8*
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 1, i32* %6
%7 = call %struct.ListNode* @createList(i32* %4, i32 1)
%8 = call %struct.ListNode* @createList(i32* %6, i32 1)
%9 = call %struct.ListNode* @sortList(%struct.ListNode* %7)
%10 = call %struct.ListNode* @sortList(%struct.ListNode* %8)
%11 = call %struct.ListNode* @mergeTwoLists(%struct.ListNode* %9, %struct.ListNode* %10)
%12 = call i32 @printList(%struct.ListNode* %11)
%13 = call i32 @freeList(%struct.ListNode* %9)
%14 = call i32 @freeList(%struct.ListNode* %10)
%15 = call i32 @freeList(%struct.ListNode* %11)
ret i32 0
}