#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 *mergeTwoLists(struct ListNode *, struct ListNode *);
struct ListNode *mergeKLists(struct ListNode **lists, int listsSize) {
  if (listsSize <= 1)
    return *lists;
  lists[1] = mergeTwoLists(lists[0], lists[1]);
  return mergeKLists(lists + 1, listsSize - 1);
}


x86 assembly (clang, -O0):
<mergeKLists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     1149 <mergeKLists+0x29>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <mergeKLists+0x5f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <mergeTwoLists@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
call   1030 <mergeKLists@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergeKLists>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%rax
cmp    $0x2,%esi
jl     114a <mergeKLists+0x3a>
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x1,%ebp
add    $0x8,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%rsi
mov    %rax,%rdi
call   1030 <mergeTwoLists@plt>
mov    %rax,(%rbx)
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x3,%ebp
jae    1130 <mergeKLists+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
define %struct.ListNode* @mergeKLists(%struct.ListNode** %0, i32 %1) {
%3 = alloca %struct.ListNode*
%4 = alloca %struct.ListNode**
%5 = alloca i32
store %struct.ListNode** %0, %struct.ListNode*** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp sle i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load %struct.ListNode**, %struct.ListNode*** %4
%10 = load %struct.ListNode*, %struct.ListNode** %9
store %struct.ListNode* %10, %struct.ListNode** %3
br label %26
11: ; preds = %2
%12 = load %struct.ListNode**, %struct.ListNode*** %4
%13 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %12, i64 0
%14 = load %struct.ListNode*, %struct.ListNode** %13
%15 = load %struct.ListNode**, %struct.ListNode*** %4
%16 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %15, i64 1
%17 = load %struct.ListNode*, %struct.ListNode** %16
%18 = call %struct.ListNode* @mergeTwoLists(%struct.ListNode* %14, %struct.ListNode* %17)
%19 = load %struct.ListNode**, %struct.ListNode*** %4
%20 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %19, i64 1
store %struct.ListNode* %18, %struct.ListNode** %20
%21 = load %struct.ListNode**, %struct.ListNode*** %4
%22 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %21, i64 1
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 1
%25 = call %struct.ListNode* @mergeKLists(%struct.ListNode** %22, i32 %24)
store %struct.ListNode* %25, %struct.ListNode** %3
br label %26
26: ; preds = %11, %8
%27 = load %struct.ListNode*, %struct.ListNode** %3
ret %struct.ListNode* %27
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
define %struct.ListNode* @mergeKLists(%struct.ListNode** nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 2
%4 = load %struct.ListNode*, %struct.ListNode** %0
br i1 %3, label %5, label %7
5: ; preds = %7, %2
%6 = phi %struct.ListNode* [ %4, %2 ], [ %13, %7 ]
ret %struct.ListNode* %6
7: ; preds = %2, %7
%8 = phi %struct.ListNode* [ %13, %7 ], [ %4, %2 ]
%9 = phi i32 [ %14, %7 ], [ %1, %2 ]
%10 = phi %struct.ListNode** [ %11, %7 ], [ %0, %2 ]
%11 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %10, i64 1
%12 = load %struct.ListNode*, %struct.ListNode** %11
%13 = tail call %struct.ListNode* @mergeTwoLists(%struct.ListNode* %8, %struct.ListNode* %12)
store %struct.ListNode* %13, %struct.ListNode** %11
%14 = add nsw i32 %9, -1
%15 = icmp ult i32 %9, 3
br i1 %15, label %5, label %7
}