#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 */

/* Variables and functions */
int /*<<< orphan*/ dfs(int *, int, int *, int *, int /*<<< orphan*/, int **,
                       int *, int *);
void *malloc(int);
int /*<<< orphan*/ memset(int *, int, int);
int **permute(int *nums, int numsSize, int *returnSize,
              int **returnColumnSizes) {
  int count = 0, cap = 5000;
  int **results = malloc(cap * sizeof(int *));
  bool *used = malloc(numsSize * sizeof(bool));
  int *stack = malloc(numsSize * sizeof(int));
  *returnSize = 0;
  *returnColumnSizes = malloc(cap * sizeof(int));
  memset(used, false, numsSize * sizeof(bool));
  dfs(nums, numsSize, used, stack, 0, results, returnSize, *returnColumnSizes);
  return results;
}


x86 assembly (clang, -O0):
<permute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1388,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%r9
mov    -0x18(%rbp),%r10
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
xor    %r8d,%r8d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <dfs@plt>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
mov    $0x9c40,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
lea    0x0(,%rbx,4),%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rsp)
movl   $0x0,(%r15)
mov    $0x4e20,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    %r13,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
mov    0x10(%rsp),%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    0x8(%rsp),%rcx
xor    %r8d,%r8d
mov    %r12,%r9
push   (%r14)
push   %r15
call   1050 <dfs@plt>
add    $0x10,%rsp
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @permute(i32* %0, i32 %1, i32* %2, i32** %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32**
%12 = alloca i32*
%13 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32** %3, i32*** %8
store i32 0, i32* %9
store i32 5000, i32* %10
%14 = load i32, i32* %10
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
%19 = bitcast i8* %18 to i32**
store i32** %19, i32*** %11
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i8* @malloc(i32 %23)
%25 = bitcast i8* %24 to i32*
store i32* %25, i32** %12
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i8* @malloc(i32 %29)
%31 = bitcast i8* %30 to i32*
store i32* %31, i32** %13
%32 = load i32*, i32** %7
store i32 0, i32* %32
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 4
%36 = trunc i64 %35 to i32
%37 = call i8* @malloc(i32 %36)
%38 = bitcast i8* %37 to i32*
%39 = load i32**, i32*** %8
store i32* %38, i32** %39
%40 = load i32*, i32** %12
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = mul i64 %42, 4
%44 = trunc i64 %43 to i32
%45 = call i32 @memset(i32* %40, i32 0, i32 %44)
%46 = load i32*, i32** %5
%47 = load i32, i32* %6
%48 = load i32*, i32** %12
%49 = load i32*, i32** %13
%50 = load i32**, i32*** %11
%51 = load i32*, i32** %7
%52 = load i32**, i32*** %8
%53 = load i32*, i32** %52
%54 = call i32 @dfs(i32* %46, i32 %47, i32* %48, i32* %49, i32 0, i32** %50, i32* %51, i32* %53)
%55 = load i32**, i32*** %11
ret i32** %55
}

LLVM IR (-O2):
define i32** @permute(i32* %0, i32 %1, i32* %2, i32** nocapture %3) {
%5 = tail call dereferenceable_or_null(40000) i8* @malloc(i32 40000)
%6 = bitcast i8* %5 to i32**
%7 = shl i32 %1, 2
%8 = tail call i8* @malloc(i32 %7)
%9 = bitcast i8* %8 to i32*
%10 = tail call i8* @malloc(i32 %7)
%11 = bitcast i8* %10 to i32*
store i32 0, i32* %2
%12 = tail call dereferenceable_or_null(20000) i8* @malloc(i32 20000)
%13 = bitcast i32** %3 to i8**
store i8* %12, i8** %13
%14 = tail call i32 @memset(i32* %9, i32 0, i32 %7)
%15 = load i32*, i32** %3
%16 = tail call i32 @dfs(i32* %0, i32 %1, i32* %9, i32* %11, i32 0, i32** %6, i32* %2, i32* %15)
ret i32** %6
}