#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*/ printPartition(int *, int);
void partition(int *arr, int ind, int left) {
  int val;
  if (left == 0) {
    printPartition(arr, ind);
    return;
  }
  for (val = 1; val <= left; val += 2) {
    arr[ind] = val;
    partition(arr, ind + 1, left - val);
  }
}


x86 assembly (clang, -O0):
<partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    114d <partition+0x2d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <printPartition@plt>
jmp    1191 <partition+0x71>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1191 <partition+0x71>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
sub    -0x14(%rbp),%edx
call   1030 <partition@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <partition+0x34>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
test   %edx,%edx
je     117c <partition+0x5c>
jle    116d <partition+0x4d>
mov    %edx,%r14d
movslq %esi,%r12
lea    0x1(%r12),%r15d
lea    -0x1(%r14),%ebp
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,0x0(%r13,%r12,4)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <partition@plt>
add    $0x2,%ebx
add    $0xfffffffe,%ebp
cmp    %r14d,%ebx
jle    1150 <partition+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printPartition@plt>

LLVM IR (-O0):
define void @partition(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @printPartition(i32* %11, i32 %12)
br label %34
14: ; preds = %3
store i32 1, i32* %7
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32, i32* %7
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
%25 = load i32*, i32** %4
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = sub nsw i32 %28, %29
br label %31
31: ; preds = %19
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 2
store i32 %33, i32* %7
br label %15
34: ; preds = %10, %15
ret void
}

LLVM IR (-O2):
define void @partition(i32* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = icmp slt i32 %2, 1
br i1 %6, label %18, label %7
7: ; preds = %5
%8 = sext i32 %1 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = add nsw i32 %1, 1
br label %13
11: ; preds = %3
%12 = tail call i32 @printPartition(i32* %0, i32 %1)
br label %18
13: ; preds = %7, %13
%14 = phi i32 [ 1, %7 ], [ %16, %13 ]
store i32 %14, i32* %9
%15 = sub nsw i32 %2, %14
tail call void @partition(i32* %0, i32 %10, i32 %15)
%16 = add nuw nsw i32 %14, 2
%17 = icmp sgt i32 %16, %2
br i1 %17, label %18, label %13
18: ; preds = %13, %5, %11
ret void
}