#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*/ printf(char *, int);
void f(int *r, int *p, int n, int m) {
  if (m == 1) {
    for (; r != p; ++r)
      printf("%d ", *r);
    printf("%d\n", n);
  } else
    for (*p = 0; *p <= n; ++*p)
      f(r, p + 1, n - *p, m - 1);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    118a <f+0x6a>
jmp    1145 <f+0x25>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1176 <f+0x56>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1145 <f+0x25>
mov    -0x14(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
jmp    11d8 <f+0xb8>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jg     11d3 <f+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
sub    (%rax),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
call   1030 <f@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1194 <f+0x74>
jmp    11d8 <f+0xb8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
cmp    $0x1,%ecx
jne    117b <f+0x5b>
cmp    %rbx,%rbp
je     1164 <f+0x44>
lea    0xebe(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x4,%rbp
cmp    %rbx,%rbp
jne    1150 <f+0x30>
lea    0xe99(%rip),%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
movl   $0x0,(%rbx)
test   %r14d,%r14d
js     11bf <f+0x9f>
mov    %ecx,%r15d
lea    0x4(%rbx),%r12
add    $0xffffffff,%r15d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,%edx
sub    %eax,%edx
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%ecx
call   1030 <f@plt>
mov    (%rbx),%ecx
lea    0x1(%rcx),%eax
mov    %eax,(%rbx)
cmp    %r14d,%ecx
jl     11a0 <f+0x80>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @f(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %26
11: ; preds = %4
br label %12
12: ; preds = %20, %11
%13 = load i32*, i32** %5
%14 = load i32*, i32** %6
%15 = icmp ne i32* %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = getelementptr inbounds i32, i32* %21, i32 1
store i32* %22, i32** %5
br label %12
23: ; preds = %12
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %48
26: ; preds = %4
%27 = load i32*, i32** %6
store i32 0, i32* %27
br label %28
28: ; preds = %43, %26
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = load i32, i32* %7
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %47
33: ; preds = %28
%34 = load i32*, i32** %5
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %7
%38 = load i32*, i32** %6
%39 = load i32, i32* %38
%40 = sub nsw i32 %37, %39
%41 = load i32, i32* %8
%42 = sub nsw i32 %41, 1
br label %43
43: ; preds = %33
%44 = load i32*, i32** %6
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
br label %28
47: ; preds = %28
br label %48
48: ; preds = %47, %23
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @f(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 1
br i1 %5, label %11, label %6
6: ; preds = %4
store i32 0, i32* %1
%7 = icmp slt i32 %2, 0
br i1 %7, label %27, label %8
8: ; preds = %6
%9 = getelementptr inbounds i32, i32* %1, i64 1
%10 = add nsw i32 %3, -1
br label %21
11: ; preds = %4
%12 = icmp eq i32* %0, %1
br i1 %12, label %19, label %13
13: ; preds = %11, %13
%14 = phi i32* [ %17, %13 ], [ %0, %11 ]
%15 = load i32, i32* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %14, i64 1
%18 = icmp eq i32* %17, %1
br i1 %18, label %19, label %13
19: ; preds = %13, %11
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %27
21: ; preds = %8, %21
%22 = phi i32 [ 0, %8 ], [ %25, %21 ]
%23 = sub nsw i32 %2, %22
tail call void @f(i32* %0, i32* %9, i32 %23, i32 %10)
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
%26 = icmp slt i32 %24, %2
br i1 %26, label %21, label %27
27: ; preds = %21, %6, %19
ret void
}