#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 ncr(unsigned int, int);
int power(int, int);
int /*<<< orphan*/ printf(char *, ...);
void printBinomialExpansion(int a, int b, unsigned int n) {
  int r;
  long int result = 0;
  printf("\n = ");
  for (r = 0; r <= n; r++) {
    printf("%dC%d * %d^%d * %d^%d", n, r, a, n - r, r);
    if (r != n)
      printf(" + ");
  }
  printf("\n = ");
  for (r = 0; r <= n; r++) {
    printf("%d * %d * %d", ncr(n, r), power(a, n - r), power(b, r));
    if (r != n)
      printf(" + ");
  }
  printf("\n = ");
  for (r = 0; r <= n; r++) {
    result += ncr(n, r) * power(a, n - r) * power(b, r);
    printf("%d", ncr(n, r) * power(a, n - r) * power(b, r));
    if (r != n)
      printf(" + ");
  }
  printf("\n = %d", result);
}


x86 assembly (clang, -O0):
<printBinomialExpansion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     11ba <printBinomialExpansion+0x8a>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    -0xc(%rbp),%r8d
sub    -0x10(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11a7 <printBinomialExpansion+0x77>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ac <printBinomialExpansion+0x7c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <printBinomialExpansion+0x2e>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     1248 <printBinomialExpansion+0x118>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <ncr@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1235 <printBinomialExpansion+0x105>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123a <printBinomialExpansion+0x10a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11cf <printBinomialExpansion+0x9f>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     1320 <printBinomialExpansion+0x1f0>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <ncr@plt>
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <ncr@plt>
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    -0x24(%rbp),%esi
imul   %eax,%esi
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     130d <printBinomialExpansion+0x1dd>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1312 <printBinomialExpansion+0x1e2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    125d <printBinomialExpansion+0x12d>
mov    -0x18(%rbp),%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBinomialExpansion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %esi,0x8(%rsp)
mov    %edi,0x4(%rsp)
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%r12
lea    0xeb6(%rip),%r14
mov    %r15d,%ebp
xor    %ebx,%ebx
jmp    1178 <printBinomialExpansion+0x48>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0xffffffff,%ebp
je     11a2 <printBinomialExpansion+0x72>
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    0x4(%rsp),%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
sub    $0x1,%ebp
jb     1170 <printBinomialExpansion+0x40>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <printBinomialExpansion+0x40>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe68(%rip),%r13
mov    %r15d,%ebp
xor    %r12d,%r12d
jmp    11c9 <printBinomialExpansion+0x99>
nop
add    $0x1,%r12d
cmp    $0xffffffff,%ebp
je     1216 <printBinomialExpansion+0xe6>
mov    %r15d,%edi
mov    %r12d,%esi
call   1050 <ncr@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    %ebp,%esi
call   1030 <power@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%edi
mov    %r12d,%esi
call   1030 <power@plt>
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
sub    $0x1,%ebp
jb     11c0 <printBinomialExpansion+0x90>
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <printBinomialExpansion+0x90>
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%r13d
xor    %esi,%esi
xor    %r12d,%r12d
mov    %r15d,0xc(%rsp)
mov    0x8(%rsp),%ebp
jmp    1259 <printBinomialExpansion+0x129>
nopw   0x0(%rax,%rax,1)
movslq %r14d,%rax
mov    0x10(%rsp),%rsi
add    %rax,%rsi
add    $0x1,%r12d
cmp    $0xffffffff,%r13d
je     12ea <printBinomialExpansion+0x1ba>
mov    %rsi,0x10(%rsp)
mov    %r15d,%edi
mov    %r12d,%esi
call   1050 <ncr@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    %r13d,%esi
call   1030 <power@plt>
mov    %eax,%r15d
imul   %ebx,%r15d
mov    %ebp,%edi
mov    %r12d,%esi
call   1030 <power@plt>
mov    %eax,%r14d
imul   %r15d,%r14d
mov    0xc(%rsp),%r15d
mov    %r15d,%edi
mov    %r12d,%esi
call   1050 <ncr@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    %r13d,%esi
call   1030 <power@plt>
imul   %eax,%ebx
mov    %ebp,%edi
mov    %r12d,%esi
call   1030 <power@plt>
imul   %eax,%ebx
lea    0xd65(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
sub    $0x1,%r13d
jb     1240 <printBinomialExpansion+0x110>
lea    0xd3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <printBinomialExpansion+0x110>
lea    0xd3b(%rip),%rdi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\0A = \00"
@.str.1 = [22 x i8] c"%dC%d * %d^%d * %d^%d\00"
@.str.2 = [4 x i8] c" + \00"
@.str.3 = [13 x i8] c"%d * %d * %d\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [7 x i8] c"\0A = %d\00"
define void @printBinomialExpansion(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i64 0, i64* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %10
10: ; preds = %29, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp ule i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = sub i32 %18, %19
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %20, i32 %21)
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %14
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %10
32: ; preds = %10
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %34
34: ; preds = %57, %32
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = icmp ule i32 %35, %36
br i1 %37, label %38, label %60
38: ; preds = %34
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = call i32 @ncr(i32 %39, i32 %40)
%42 = load i32, i32* %4
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = sub i32 %43, %44
%46 = call i32 @power(i32 %42, i32 %45)
%47 = load i32, i32* %5
%48 = load i32, i32* %7
%49 = call i32 @power(i32 %47, i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %46, i32 %49)
%51 = load i32, i32* %7
%52 = load i32, i32* %6
%53 = icmp ne i32 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %38
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %38
br label %57
57: ; preds = %56
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %34
60: ; preds = %34
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %62
62: ; preds = %103, %60
%63 = load i32, i32* %7
%64 = load i32, i32* %6
%65 = icmp ule i32 %63, %64
br i1 %65, label %66, label %106
66: ; preds = %62
%67 = load i32, i32* %6
%68 = load i32, i32* %7
%69 = call i32 @ncr(i32 %67, i32 %68)
%70 = load i32, i32* %4
%71 = load i32, i32* %6
%72 = load i32, i32* %7
%73 = sub i32 %71, %72
%74 = call i32 @power(i32 %70, i32 %73)
%75 = mul nsw i32 %69, %74
%76 = load i32, i32* %5
%77 = load i32, i32* %7
%78 = call i32 @power(i32 %76, i32 %77)
%79 = mul nsw i32 %75, %78
%80 = sext i32 %79 to i64
%81 = load i64, i64* %8
%82 = add nsw i64 %81, %80
store i64 %82, i64* %8
%83 = load i32, i32* %6
%84 = load i32, i32* %7
%85 = call i32 @ncr(i32 %83, i32 %84)
%86 = load i32, i32* %4
%87 = load i32, i32* %6
%88 = load i32, i32* %7
%89 = sub i32 %87, %88
%90 = call i32 @power(i32 %86, i32 %89)
%91 = mul nsw i32 %85, %90
%92 = load i32, i32* %5
%93 = load i32, i32* %7
%94 = call i32 @power(i32 %92, i32 %93)
%95 = mul nsw i32 %91, %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %95)
%97 = load i32, i32* %7
%98 = load i32, i32* %6
%99 = icmp ne i32 %97, %98
br i1 %99, label %100, label %102
100: ; preds = %66
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %102
102: ; preds = %100, %66
br label %103
103: ; preds = %102
%104 = load i32, i32* %7
%105 = add nsw i32 %104, 1
store i32 %105, i32* %7
br label %62
106: ; preds = %62
%107 = load i64, i64* %8
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %107)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\0A = \00"
@.str.1 = [22 x i8] c"%dC%d * %d^%d * %d^%d\00"
@.str.2 = [4 x i8] c" + \00"
@.str.3 = [13 x i8] c"%d * %d * %d\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [7 x i8] c"\0A = %d\00"
define void @printBinomialExpansion(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %12
%6 = phi i32 [ 0, %3 ], [ %13, %12 ]
%7 = sub i32 %2, %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %6, i32 %0, i32 %7, i32 %6)
%9 = icmp eq i32 %6, %2
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %5, %10
%13 = add nuw i32 %6, 1
%14 = icmp eq i32 %6, %2
br i1 %14, label %15, label %5
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %27
%18 = phi i32 [ 0, %15 ], [ %28, %27 ]
%19 = tail call i32 @ncr(i32 %2, i32 %18)
%20 = sub i32 %2, %18
%21 = tail call i32 @power(i32 %0, i32 %20)
%22 = tail call i32 @power(i32 %1, i32 %18)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %21, i32 %22)
%24 = icmp eq i32 %18, %2
br i1 %24, label %27, label %25
25: ; preds = %17
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %17, %25
%28 = add nuw i32 %18, 1
%29 = icmp eq i32 %18, %2
br i1 %29, label %30, label %17
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %52
%33 = phi i64 [ 0, %30 ], [ %42, %52 ]
%34 = phi i32 [ 0, %30 ], [ %53, %52 ]
%35 = tail call i32 @ncr(i32 %2, i32 %34)
%36 = sub i32 %2, %34
%37 = tail call i32 @power(i32 %0, i32 %36)
%38 = mul nsw i32 %37, %35
%39 = tail call i32 @power(i32 %1, i32 %34)
%40 = mul nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = add nsw i64 %33, %41
%43 = tail call i32 @ncr(i32 %2, i32 %34)
%44 = tail call i32 @power(i32 %0, i32 %36)
%45 = mul nsw i32 %44, %43
%46 = tail call i32 @power(i32 %1, i32 %34)
%47 = mul nsw i32 %45, %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = icmp eq i32 %34, %2
br i1 %49, label %52, label %50
50: ; preds = %32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %32, %50
%53 = add nuw i32 %34, 1
%54 = icmp eq i32 %34, %2
br i1 %54, label %55, label %32
55: ; preds = %52
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %42)
ret void
}