#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 formula(int x, int y, int z) {
  if (x == 1) {
    printf("Solve:0\n");
    return 0;
  } else {
    if ((y + 1) == x) {
      printf("Solve:%d\n", z);
      return 0;
    } else {
      formula(x, (y + 1), (z + 1));
    }
  }
}


x86 assembly (clang, -O0):
<formula>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1155 <formula+0x35>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119a <formula+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    1181 <formula+0x61>
mov    -0x10(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119a <formula+0x7a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1040 <formula@plt>
jmp    119a <formula+0x7a>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formula>:
push   %rax
cmp    $0x1,%edi
jne    1134 <formula+0x14>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
jmp    1148 <formula+0x28>
add    %edi,%edx
not    %esi
add    %edx,%esi
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [10 x i8] c"Solve:%d\0A\00"
@str = [8 x i8] c"Solve:0\00"
define i32 @formula(i32 %0, i32 %1, i32 %2) {
%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 ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %12
7: ; preds = %3
%8 = add i32 %2, %0
%9 = xor i32 %1, -1
%10 = add i32 %8, %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %5, %7
ret i32 0
}