#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 /*<<< orphan*/ putchar(char);
int yanghui(int m, int n) {
  int result;
  result = 1;
  if (m == 0 && n == 1) {
    printf("1");
    return result;
  } else if (m == 0) {
    yanghui(n - 1, n - 1);
    printf("1");
    return result;
  } else {
    result = yanghui(m - 1, n) * (n - m + 1) / m;
    printf(" %d", result);
  }
  if (m == n)
    putchar('\n');
  return result;
}


x86 assembly (clang, -O0):
<yanghui>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1172 <yanghui+0x42>
cmpl   $0x1,-0xc(%rbp)
jne    1172 <yanghui+0x42>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <yanghui+0xc9>
cmpl   $0x0,-0x8(%rbp)
jne    11a6 <yanghui+0x76>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1050 <yanghui@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <yanghui+0xc9>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
call   1050 <yanghui@plt>
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11dd <yanghui+0xad>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11f3 <yanghui+0xc3>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yanghui>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
test   %edi,%edi
jne    1141 <yanghui+0x11>
cmp    $0x1,%ebp
je     118b <yanghui+0x5b>
test   %ebx,%ebx
je     117f <yanghui+0x4f>
lea    -0x1(%rbx),%edi
mov    %ebp,%esi
call   1050 <yanghui@plt>
mov    %ebp,%ecx
sub    %ebx,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cltd
idiv   %ebx
mov    %eax,%r14d
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%ebp
jne    119b <yanghui+0x6b>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    119b <yanghui+0x6b>
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %ebp,%esi
call   1050 <yanghui@plt>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %d\00"
define i32 @yanghui(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = icmp eq i32 %1, 1
%5 = and i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 49)
br label %9
8: ; preds = %2
br i1 %3, label %11, label %15
9: ; preds = %6, %24, %15, %11
%10 = phi i32 [ 1, %11 ], [ 1, %6 ], [ %21, %24 ], [ %21, %15 ]
ret i32 %10
11: ; preds = %8
%12 = add nsw i32 %1, -1
%13 = tail call i32 @yanghui(i32 %12, i32 %12)
%14 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 49)
br label %9
15: ; preds = %8
%16 = add nsw i32 %0, -1
%17 = tail call i32 @yanghui(i32 %16, i32 %1)
%18 = sub i32 1, %0
%19 = add i32 %18, %1
%20 = mul nsw i32 %17, %19
%21 = sdiv i32 %20, %0
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = icmp eq i32 %1, %0
br i1 %23, label %24, label %9
24: ; preds = %15
%25 = tail call i32 @putchar(i8 signext 10)
br label %9
}