#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 calculate_binomial(int, int);
int getpid();
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ spend_CPU_time();
void print_binomials(int start) {
  int i;
  int binomial_coef;
  for (i = start; i < 11; i += 2) {
    binomial_coef = calculate_binomial(i, i - 2);
    printf("The process %d calculated %i choose %i is %i.\n", getpid(), i,
           i - 2, binomial_coef);
    sleep(4);
  }
  spend_CPU_time();
}


x86 assembly (clang, -O0):
<print_binomials>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xb,-0x8(%rbp)
jge    11b6 <print_binomials+0x66>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
call   1060 <calculate_binomial@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
mov    -0xc(%rbp),%r8d
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
call   1070 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1161 <print_binomials+0x11>
mov    $0x0,%al
call   1050 <spend_CPU_time@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binomials>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0xa,%edi
jg     11ab <print_binomials+0x5b>
mov    %edi,%ebx
lea    0xe9b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbx),%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <calculate_binomial@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1040 <printf@plt>
mov    $0x4,%edi
call   1070 <sleep@plt>
lea    0x2(%rbx),%eax
cmp    $0x9,%ebx
mov    %eax,%ebx
jl     1170 <print_binomials+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <spend_CPU_time@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"The process %d calculated %i choose %i is %i.\0A\00"
define void @print_binomials(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
store i32 %5, i32* %3
br label %6
6: ; preds = %21, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 11
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 2
%13 = call i32 @calculate_binomial(i32 %10, i32 %12)
store i32 %13, i32* %4
%14 = call i32 (...) @getpid()
%15 = load i32, i32* %3
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 2
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %17, i32 %18)
%20 = call i32 @sleep(i32 4)
br label %21
21: ; preds = %9
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 2
store i32 %23, i32* %3
br label %6
24: ; preds = %6
%25 = call i32 (...) @spend_CPU_time()
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"The process %d calculated %i choose %i is %i.\0A\00"
define void @print_binomials(i32 %0) {
%2 = icmp slt i32 %0, 11
br i1 %2, label %3, label %12
3: ; preds = %1, %3
%4 = phi i32 [ %10, %3 ], [ %0, %1 ]
%5 = add nsw i32 %4, -2
%6 = tail call i32 @calculate_binomial(i32 %4, i32 %5)
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %4, i32 %5, i32 %6)
%9 = tail call i32 @sleep(i32 4)
%10 = add nsw i32 %4, 2
%11 = icmp slt i32 %4, 9
br i1 %11, label %3, label %12
12: ; preds = %3, %1
%13 = tail call i32 (...) @spend_CPU_time()
ret void
}