#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 *, ...);
void f(int n) {
  int iter;
  if (n <= 0) {
    return;
  }
  if (n == 1) {
    printf("1 0\n");
    return;
  }
  for (iter = 1; iter < n; iter++) {
    printf("%d %d\n", iter, n - iter);
    f(n - iter);
    printf("%d %d\n", iter, n - iter);
  }
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     113a <f+0x1a>
jmp    11b1 <f+0x91>
cmpl   $0x1,-0x4(%rbp)
jne    1157 <f+0x37>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b1 <f+0x91>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b1 <f+0x91>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
sub    -0x8(%rbp),%edx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
sub    -0x8(%rbp),%edi
call   1030 <f@plt>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
sub    -0x8(%rbp),%edx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <f+0x3e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    118b <f+0x5b>
mov    %edi,%ebx
cmp    $0x1,%edi
jne    114f <f+0x1f>
lea    0xec1(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
add    $0xffffffff,%ebx
mov    $0x1,%ebp
lea    0xea2(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1040 <f@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1160 <f+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d %d\0A\00"
@str = [4 x i8] c"1 0\00"
define void @f(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %14
7: ; preds = %3, %7
%8 = phi i32 [ %12, %7 ], [ 1, %3 ]
%9 = sub nsw i32 %0, %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
tail call void @f(i32 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %7
14: ; preds = %7, %1, %5
ret void
}