#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*/ funca(int, int);
int /*<<< orphan*/ printf(char *, ...);
int funcs(int i, int n) {
  if (i <= 1) {
    funca(1, 1);
    return 1;
  } else {
    printf("(");
    int d = funcs(i - 1, n) + (n - i + 1);
    printf("+%d)", d);
    funca(1, i);
    return 1;
  }
}


x86 assembly (clang, -O0):
<funcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1160 <funcs+0x30>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <funca@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <funcs+0x7f>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
call   1040 <funcs@plt>
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1030 <funca@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funcs>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    $0x1,%esi
cmp    $0x1,%edi
jle    117c <funcs+0x3c>
mov    %edi,%ebx
mov    $0x28,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%edi
mov    %ebp,%esi
call   1050 <funcs@plt>
sub    %ebx,%ebp
add    $0x2,%ebp
lea    0xe8f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%esi
mov    $0x1,%edi
call   1040 <funca@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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