#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 */
scalar_t__ nfall0(unsigned int, unsigned int);
unsigned int nfall(unsigned int k) {
  unsigned int i;
  unsigned int sum;
  sum = 0;
  for (i = 1; i <= 9; ++i) {
    sum += nfall0(k, i);
  }
  return sum;
}


x86 assembly (clang, -O0):
<nfall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
ja     1158 <nfall+0x48>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <nfall0@plt>
mov    %rax,%rcx
mov    -0xc(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <nfall+0x19>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nfall>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    $0x1,%esi
call   1030 <nfall0@plt>
mov    %rax,%r14
mov    %r15d,%edi
mov    $0x2,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbx
add    %r14d,%ebx
mov    %r15d,%edi
mov    $0x3,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    %r15d,%edi
mov    $0x4,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r15d,%edi
mov    $0x5,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    %r15d,%edi
mov    $0x6,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r15d,%edi
mov    $0x7,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    %r15d,%edi
mov    $0x8,%esi
call   1030 <nfall0@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r15d,%edi
mov    $0x9,%esi
call   1030 <nfall0@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nfall(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
store i32 1, i32* %3
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %3
%7 = icmp ule i32 %6, 9
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i64 @nfall0(i32 %9, i32 %10)
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = add nsw i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %4
br label %16
16: ; preds = %8
%17 = load i32, i32* %3
%18 = add i32 %17, 1
store i32 %18, i32* %3
br label %5
19: ; preds = %5
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
define i32 @nfall(i32 %0) {
%2 = tail call i64 @nfall0(i32 %0, i32 1)
%3 = trunc i64 %2 to i32
%4 = tail call i64 @nfall0(i32 %0, i32 2)
%5 = trunc i64 %4 to i32
%6 = add i32 %3, %5
%7 = tail call i64 @nfall0(i32 %0, i32 3)
%8 = trunc i64 %7 to i32
%9 = add i32 %6, %8
%10 = tail call i64 @nfall0(i32 %0, i32 4)
%11 = trunc i64 %10 to i32
%12 = add i32 %9, %11
%13 = tail call i64 @nfall0(i32 %0, i32 5)
%14 = trunc i64 %13 to i32
%15 = add i32 %12, %14
%16 = tail call i64 @nfall0(i32 %0, i32 6)
%17 = trunc i64 %16 to i32
%18 = add i32 %15, %17
%19 = tail call i64 @nfall0(i32 %0, i32 7)
%20 = trunc i64 %19 to i32
%21 = add i32 %18, %20
%22 = tail call i64 @nfall0(i32 %0, i32 8)
%23 = trunc i64 %22 to i32
%24 = add i32 %21, %23
%25 = tail call i64 @nfall0(i32 %0, i32 9)
%26 = trunc i64 %25 to i32
%27 = add i32 %24, %26
ret i32 %27
}