#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 */
double gamma(double);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, double, double);
main() {
  int i;
  double x;
  for (i = 1; i < 5; i++) {
    x = 0.5 * i;
    printf("\n gamma(%4.2f)=%2.5f", x, gamma(x));
  }
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    119c <main+0x6c>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xea3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <gamma@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
mov    $0x0,%al
call   1050 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
movsd  0xec7(%rip),%xmm0
call   1030 <gamma@plt>
movaps %xmm0,%xmm1
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
movsd  0xead(%rip),%xmm0
call   1040 <printf@plt>
movsd  0xea8(%rip),%xmm0
call   1030 <gamma@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0xe95(%rip),%xmm0
call   1040 <printf@plt>
movsd  0xe90(%rip),%xmm0
call   1030 <gamma@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0xe7d(%rip),%xmm0
call   1040 <printf@plt>
movsd  0xe78(%rip),%xmm0
call   1030 <gamma@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0xe65(%rip),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getch@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0A gamma(%4.2f)=%2.5f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 5
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to double
%10 = fmul double 5.000000e-01, %9
store double %10, double* %3
%11 = load double, double* %3
%12 = load double, double* %3
%13 = call double @gamma(double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %11, double %13)
br label %15
15: ; preds = %7
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %4
18: ; preds = %4
%19 = call i32 (...) @getch()
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0A gamma(%4.2f)=%2.5f\00"
define i32 @main() {
%1 = tail call double @gamma(double 5.000000e-01)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 5.000000e-01, double %1)
%3 = tail call double @gamma(double 1.000000e+00)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 1.000000e+00, double %3)
%5 = tail call double @gamma(double 1.500000e+00)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 1.500000e+00, double %5)
%7 = tail call double @gamma(double 2.000000e+00)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 2.000000e+00, double %7)
%9 = tail call i32 (...) @getch()
ret i32 0
}