#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 */
typedef int /*<<< orphan*/ nums;

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ traverse(int *, int, int, int, int, int *, int, int ***,
                            int **, int *);
int **combinationSum3(int k, int target, int **colSizes, int *returnSize) {
  int nums[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int size = sizeof(nums) / sizeof(int);
  int **arr = (int **)malloc(sizeof(int *));
  *returnSize = 0;
  *colSizes = (int *)malloc(sizeof(int));
  int *stack = (int *)malloc(sizeof(int) * k);
  int top = -1;
  for (int i = 0; i < size; i++) {
    if (nums[i] > target)
      break;
    stack[top + 1] = nums[i];
    traverse(nums, size, i + 1, k, target - nums[i], stack, top + 1, &arr,
             colSizes, returnSize);
  }
  return arr;
}


x86 assembly (clang, -O0):
<combinationSum3>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeab(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
movl   $0x9,-0x54(%rbp)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x68(%rbp)
movl   $0xffffffff,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1245 <combinationSum3+0x115>
movslq -0x70(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
cmp    -0x10(%rbp),%eax
jle    11d5 <combinationSum3+0xa5>
jmp    1245 <combinationSum3+0x115>
movslq -0x70(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
mov    -0x68(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x70(%rbp),%edx
add    $0x1,%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
movslq -0x70(%rbp),%rax
sub    -0x50(%rbp,%rax,4),%r8d
mov    -0x68(%rbp),%r9
mov    -0x6c(%rbp),%ebx
add    $0x1,%ebx
mov    -0x18(%rbp),%r10
mov    -0x20(%rbp),%rax
lea    -0x60(%rbp),%r11
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <traverse@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    11b3 <combinationSum3+0x83>
mov    -0x60(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<combinationSum3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r13d
mov    %edi,%r12d
mov    0xee0(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rsp)
movl   $0x0,(%r14)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
lea    0x0(,%r12,4),%edi
call   1040 <malloc@plt>
test   %r13d,%r13d
jle    11e4 <combinationSum3+0xc4>
mov    %rax,%rbx
mov    $0x1,%eax
mov    $0x1,%ebp
xchg   %ax,%ax
mov    %eax,(%rbx)
mov    %r13d,%r8d
sub    0xc(%rsp,%rbp,4),%r8d
lea    0x10(%rsp),%rdi
mov    $0x9,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %rbx,%r9
push   %r14
push   %r15
lea    0x18(%rsp),%rax
push   %rax
push   $0x0
call   1030 <traverse@plt>
add    $0x20,%rsp
cmp    $0x9,%rbp
je     11e4 <combinationSum3+0xc4>
mov    0x10(%rsp,%rbp,4),%eax
add    $0x1,%rbp
cmp    %r13d,%eax
jle    11a0 <combinationSum3+0x80>
mov    0x8(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.combinationSum3.nums = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32** @combinationSum3(i32 %0, i32 %1, i32** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca [9 x i32]
%10 = alloca i32
%11 = alloca i32**
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32** %2, i32*** %7
store i32* %3, i32** %8
%15 = bitcast [9 x i32]* %9 to i8*
store i32 9, i32* %10
%16 = call i64 @malloc(i32 8)
%17 = inttoptr i64 %16 to i32**
store i32** %17, i32*** %11
%18 = load i32*, i32** %8
store i32 0, i32* %18
%19 = call i64 @malloc(i32 4)
%20 = inttoptr i64 %19 to i32*
%21 = load i32**, i32*** %7
store i32* %20, i32** %21
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = mul i64 4, %23
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %12
store i32 -1, i32* %13
store i32 0, i32* %14
br label %28
28: ; preds = %67, %4
%29 = load i32, i32* %14
%30 = load i32, i32* %10
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %70
32: ; preds = %28
%33 = load i32, i32* %14
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %6
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %32
br label %70
40: ; preds = %32
%41 = load i32, i32* %14
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32*, i32** %12
%46 = load i32, i32* %13
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %45, i64 %48
store i32 %44, i32* %49
%50 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 0, i64 0
%51 = load i32, i32* %10
%52 = load i32, i32* %14
%53 = add nsw i32 %52, 1
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = load i32, i32* %14
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = sub nsw i32 %55, %59
%61 = load i32*, i32** %12
%62 = load i32, i32* %13
%63 = add nsw i32 %62, 1
%64 = load i32**, i32*** %7
%65 = load i32*, i32** %8
%66 = call i32 @traverse(i32* %50, i32 %51, i32 %53, i32 %54, i32 %60, i32* %61, i32 %63, i32*** %11, i32** %64, i32* %65)
br label %67
67: ; preds = %40
%68 = load i32, i32* %14
%69 = add nsw i32 %68, 1
store i32 %69, i32* %14
br label %28
70: ; preds = %39, %28
%71 = load i32**, i32*** %11
ret i32** %71
}

LLVM IR (-O2):
@__const.combinationSum3.nums = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32** @combinationSum3(i32 %0, i32 %1, i32** %2, i32* %3) {
%5 = alloca [9 x i32]
%6 = alloca i32**
%7 = bitcast [9 x i32]* %5 to i8*
%8 = bitcast i32*** %6 to i8*
%9 = tail call i64 @malloc(i32 8)
%10 = inttoptr i64 %9 to i32**
store i32** %10, i32*** %6
store i32 0, i32* %3
%11 = tail call i64 @malloc(i32 4)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %2
%13 = shl i32 %0, 2
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%17 = icmp slt i32 %1, 1
br i1 %17, label %32, label %18
18: ; preds = %4, %28
%19 = phi i64 [ %22, %28 ], [ 0, %4 ]
%20 = phi i32 [ %30, %28 ], [ 1, %4 ]
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %19
store i32 %20, i32* %15
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %21
%24 = sub nsw i32 %1, %23
%25 = trunc i64 %22 to i32
%26 = call i32 @traverse(i32* %16, i32 9, i32 %25, i32 %0, i32 %24, i32* %15, i32 0, i32*** %6, i32** %2, i32* %3)
%27 = icmp eq i64 %22, 9
br i1 %27, label %32, label %28
28: ; preds = %18
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %22
%30 = load i32, i32* %29
%31 = icmp sgt i32 %30, %1
br i1 %31, label %32, label %18
32: ; preds = %18, %28, %4
%33 = load i32**, i32*** %6
ret i32** %33
}