#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gammln(float);
int /*<<< orphan*/ gcf(float *, float, float, float *);
int /*<<< orphan*/ nrerror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
int main(void) {
  char txt[80];
  int i, nval;
  float a, val, x, gammcf, gln;
  FILE *fp;
  if ((fp = fopen("fncval.dat", "r")) == NULL)
    nrerror("Data file fncval.dat not found\n");
  fgets(txt, 80, fp);
  while (strncmp(txt, "Incomplete Gamma Function", 25)) {
    fgets(txt, 80, fp);
    if (feof(fp))
      nrerror("Data not found in fncval.dat\n");
  }
  fscanf(fp, "%d %*s", &nval);
  printf("\n%s\n", txt);
  printf("%4s %11s %14s %13s %13s %8s\n", "a", "x", "actual", "gcf(a,x)",
         "gammln(a)", "gln");
  for (i = 1; i <= nval; i++) {
    fscanf(fp, "%f %f %f", &a, &x, &val);
    if (x >= (a + 1.0)) {
      gcf(&gammcf, a, x, &gln);
      printf("%6.2f%13.6f%13.6f%13.6f%12.6f%13.6f\n", a, x, (1.0 - val), gammcf,
             gammln(a), gln);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe4f(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    11e2 <main+0x42>
lea    0xe38(%rip),%rdi
call   1040 <nrerror@plt>
lea    -0x60(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
lea    -0x60(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1252 <main+0xb2>
lea    -0x60(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x88(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     124d <main+0xad>
lea    0xe07(%rip),%rdi
call   1040 <nrerror@plt>
jmp    11f7 <main+0x57>
mov    -0x88(%rbp),%rdi
lea    0xe0d(%rip),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf5(%rip),%rdi
lea    0xe0b(%rip),%rsi
lea    0xe06(%rip),%rdx
lea    0xe01(%rip),%rcx
lea    0xe01(%rip),%r8
lea    0xe03(%rip),%r9
lea    0xe06(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x68(%rbp),%eax
jg     13d2 <main+0x232>
mov    -0x88(%rbp),%rdi
lea    0xdde(%rip),%rsi
lea    -0x6c(%rbp),%rdx
lea    -0x74(%rbp),%rcx
lea    -0x70(%rbp),%r8
mov    $0x0,%al
call   1070 <fscanf@plt>
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x6c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xcf9(%rip),%xmm2
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     13bf <main+0x21f>
movss  -0x6c(%rbp),%xmm0
movss  -0x74(%rbp),%xmm1
lea    -0x78(%rbp),%rdi
lea    -0x7c(%rbp),%rsi
call   10b0 <gcf@plt>
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movss  -0x70(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xca1(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movss  -0x6c(%rbp),%xmm0
call   10c0 <gammln@plt>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x98(%rbp),%xmm2
ff
movsd  -0x90(%rbp),%xmm3
ff
mov    %eax,%esi
movss  -0x7c(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
lea    0xd09(%rip),%rdi
mov    $0x5,%al
call   1060 <printf@plt>
jmp    13c4 <main+0x224>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12c0 <main+0x120>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe50(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d8 <main+0x38>
lea    0xe42(%rip),%rdi
call   1040 <nrerror@plt>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
lea    0xe41(%rip),%rsi
mov    %rbp,%rdi
mov    $0x19,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     125c <main+0xbc>
lea    0x40(%rsp),%rbp
lea    0xe23(%rip),%r14
lea    0xe36(%rip),%r15
jmp    1235 <main+0x95>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     125c <main+0xbc>
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1220 <main+0x80>
mov    %r15,%rdi
call   1040 <nrerror@plt>
jmp    1220 <main+0x80>
lea    0xe0a(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0xdfb(%rip),%rdi
lea    0x40(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe28(%rip),%rax
mov    %rax,(%rsp)
lea    0xde2(%rip),%rdi
lea    0xdf8(%rip),%rsi
lea    0xdf3(%rip),%rdx
lea    0xdee(%rip),%rcx
lea    0xdee(%rip),%r8
lea    0xdf0(%rip),%r9
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x10(%rsp)
jle    13d8 <main+0x238>
lea    0xde5(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x1c(%rsp),%r13
xor    %ebp,%ebp
jmp    12fd <main+0x15d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    0x10(%rsp),%ebp
jge    13d8 <main+0x238>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1070 <fscanf@plt>
movss  0x8(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
movss  0xc(%rsp),%xmm0
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
addsd  0xccb(%rip),%xmm3
ucomisd %xmm3,%xmm2
jb     12f0 <main+0x150>
lea    0x18(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   10b0 <gcf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x30(%rsp)
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xc81(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x28(%rsp)
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x20(%rsp)
call   10c0 <gammln@plt>
movss  0x14(%rsp),%xmm0
xorps  %xmm4,%xmm4
cvtss2sd %xmm0,%xmm4
lea    0xd0f(%rip),%rdi
movsd  0x38(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
mov    %eax,%esi
mov    $0x5,%al
call   1060 <printf@plt>
jmp    12f0 <main+0x150>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"fncval.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"Data file fncval.dat not found\0A\00"
@.str.3 = [26 x i8] c"Incomplete Gamma Function\00"
@.str.4 = [30 x i8] c"Data not found in fncval.dat\0A\00"
@.str.5 = [7 x i8] c"%d %*s\00"
@.str.6 = [5 x i8] c"\0A%s\0A\00"
@.str.7 = [29 x i8] c"%4s %11s %14s %13s %13s %8s\0A\00"
@.str.8 = [2 x i8] c"a\00"
@.str.9 = [2 x i8] c"x\00"
@.str.10 = [7 x i8] c"actual\00"
@.str.11 = [9 x i8] c"gcf(a,x)\00"
@.str.12 = [10 x i8] c"gammln(a)\00"
@.str.13 = [4 x i8] c"gln\00"
@.str.14 = [9 x i8] c"%f %f %f\00"
@.str.15 = [37 x i8] c"%6.2f%13.6f%13.6f%13.6f%12.6f%13.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32*
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %10
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %10
%18 = call i32 @fgets(i8* %16, i32 80, i32* %17)
br label %19
19: ; preds = %32, %15
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%21 = call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 25)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%25 = load i32*, i32** %10
%26 = call i32 @fgets(i8* %24, i32 80, i32* %25)
%27 = load i32*, i32** %10
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %23
br label %19
33: ; preds = %19
%34 = load i32*, i32** %10
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %3
br label %39
39: ; preds = %71, %33
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %74
43: ; preds = %39
%44 = load i32*, i32** %10
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), float* %5, float* %7, float* %6)
%46 = load float, float* %7
%47 = fpext float %46 to double
%48 = load float, float* %5
%49 = fpext float %48 to double
%50 = fadd double %49, 1.000000e+00
%51 = fcmp oge double %47, %50
br i1 %51, label %52, label %70
52: ; preds = %43
%53 = load float, float* %5
%54 = load float, float* %7
%55 = call i32 @gcf(float* %8, float %53, float %54, float* %9)
%56 = load float, float* %5
%57 = fpext float %56 to double
%58 = load float, float* %7
%59 = fpext float %58 to double
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = fsub double 1.000000e+00, %61
%63 = load float, float* %8
%64 = fpext float %63 to double
%65 = load float, float* %5
%66 = call i32 @gammln(float %65)
%67 = load float, float* %9
%68 = fpext float %67 to double
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0), double %57, double %59, double %62, double %64, i32 %66, double %68)
br label %70
70: ; preds = %52, %43
br label %71
71: ; preds = %70
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 1
store i32 %73, i32* %3
br label %39
74: ; preds = %39
%75 = load i32*, i32** %10
%76 = call i32 @fclose(i32* %75)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"fncval.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"Data file fncval.dat not found\0A\00"
@.str.3 = [26 x i8] c"Incomplete Gamma Function\00"
@.str.4 = [30 x i8] c"Data not found in fncval.dat\0A\00"
@.str.5 = [7 x i8] c"%d %*s\00"
@.str.6 = [5 x i8] c"\0A%s\0A\00"
@.str.7 = [29 x i8] c"%4s %11s %14s %13s %13s %8s\0A\00"
@.str.8 = [2 x i8] c"a\00"
@.str.9 = [2 x i8] c"x\00"
@.str.10 = [7 x i8] c"actual\00"
@.str.11 = [9 x i8] c"gcf(a,x)\00"
@.str.12 = [10 x i8] c"gammln(a)\00"
@.str.13 = [4 x i8] c"gln\00"
@.str.14 = [9 x i8] c"%f %f %f\00"
@.str.15 = [37 x i8] c"%6.2f%13.6f%13.6f%13.6f%12.6f%13.6f\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%9 = bitcast i32* %2 to i8*
%10 = bitcast float* %3 to i8*
%11 = bitcast float* %4 to i8*
%12 = bitcast float* %5 to i8*
%13 = bitcast float* %6 to i8*
%14 = bitcast float* %7 to i8*
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = tail call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %0
%20 = call i32 @fgets(i8* %8, i32 80, i32* %15)
%21 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 25)
%22 = icmp eq i64 %21, 0
br i1 %22, label %32, label %23
23: ; preds = %19, %29
%24 = call i32 @fgets(i8* %8, i32 80, i32* %15)
%25 = call i64 @feof(i32* %15)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 25)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %23
32: ; preds = %29, %19
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%36 = load i32, i32* %2
%37 = icmp slt i32 %36, 1
br i1 %37, label %66, label %38
38: ; preds = %32, %62
%39 = phi i32 [ %63, %62 ], [ 1, %32 ]
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), float* %3, float* %5, float* %4)
%41 = load float, float* %5
%42 = fpext float %41 to double
%43 = load float, float* %3
%44 = fpext float %43 to double
%45 = fadd double %44, 1.000000e+00
%46 = fcmp ugt double %45, %42
br i1 %46, label %62, label %47
47: ; preds = %38
%48 = call i32 @gcf(float* %6, float %43, float %41, float* %7)
%49 = load float, float* %3
%50 = fpext float %49 to double
%51 = load float, float* %5
%52 = fpext float %51 to double
%53 = load float, float* %4
%54 = fpext float %53 to double
%55 = fsub double 1.000000e+00, %54
%56 = load float, float* %6
%57 = fpext float %56 to double
%58 = call i32 @gammln(float %49)
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0), double %50, double %52, double %55, double %57, i32 %58, double %60)
br label %62
62: ; preds = %38, %47
%63 = add nuw nsw i32 %39, 1
%64 = load i32, i32* %2
%65 = icmp slt i32 %39, %64
br i1 %65, label %38, label %66
66: ; preds = %62, %32
%67 = call i32 @fclose(i32* %15)
ret i32 0
}