#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 */
double factrl(int);
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 *, ...);
int /*<<< orphan*/ nrerror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
int main(void) {
  char txt[80];
  float actual;
  int i, n, nval;
  FILE *fp;
  if ((fp = fopen("fncval.dat", "r")) == NULL)
    nrerror("Data file fncval.dat not found\n");
  fgets(txt, 80, fp);
  while (strncmp(txt, "N-factorial", 11)) {
    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("%6s %18s %20s \n", "n", "actual", "factrl(n)");
  for (i = 1; i <= nval; i++) {
    fscanf(fp, "%d %f ", &n, &actual);
    if (actual < 1.0e10)
      printf("%6d %20.0f %20.0f\n", n, actual, factrl(n));
    else
      printf("%6d %20e %20e \n", n, actual, factrl(n));
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5f(%rip),%rdi
lea    0xe63(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    11cf <main+0x3f>
lea    0xe4b(%rip),%rdi
call   1040 <nrerror@plt>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
lea    -0x60(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1236 <main+0xa6>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x78(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1231 <main+0xa1>
lea    0xe15(%rip),%rdi
call   1040 <nrerror@plt>
jmp    11e1 <main+0x51>
mov    -0x78(%rbp),%rdi
lea    0xe1e(%rip),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe06(%rip),%rdi
lea    0xe0f(%rip),%rsi
lea    0xe0a(%rip),%rdx
lea    0xe0a(%rip),%rcx
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x70(%rbp),%eax
jg     135d <main+0x1cd>
mov    -0x78(%rbp),%rdi
lea    0xdef(%rip),%rsi
lea    -0x6c(%rbp),%rdx
lea    -0x64(%rbp),%rcx
mov    $0x0,%al
call   1070 <fscanf@plt>
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd41(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1309 <main+0x179>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x84(%rbp)
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x6c(%rbp),%edi
call   10b0 <factrl@plt>
mov    -0x84(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
lea    0xd98(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
jmp    134a <main+0x1ba>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x94(%rbp)
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x6c(%rbp),%edi
call   10b0 <factrl@plt>
mov    -0x94(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
lea    0xd65(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
jmp    134f <main+0x1bf>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1288 <main+0xf8>
mov    -0x78(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe5f(%rip),%rdi
lea    0xe63(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c5 <main+0x35>
lea    0xe51(%rip),%rdi
call   1040 <nrerror@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
lea    0xe50(%rip),%rsi
mov    %r14,%rdi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     124c <main+0xbc>
lea    0x20(%rsp),%r14
lea    0xe32(%rip),%r15
lea    0xe37(%rip),%r12
jmp    1225 <main+0x95>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     124c <main+0xbc>
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1210 <main+0x80>
mov    %r12,%rdi
call   1040 <nrerror@plt>
jmp    1210 <main+0x80>
lea    0xe08(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0xdf9(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdeb(%rip),%rdi
lea    0xdf4(%rip),%rsi
lea    0xdef(%rip),%rdx
lea    0xdef(%rip),%rcx
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    132b <main+0x19b>
lea    0x14(%rsp),%r12
lea    0xde2(%rip),%r13
lea    0xdee(%rip),%r14
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xdc0(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1070 <fscanf@plt>
movss  0x14(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
call   10b0 <factrl@plt>
movss  0xcfe(%rip),%xmm1
ucomiss 0xc(%rsp),%xmm1
movaps %xmm0,%xmm1
mov    %r14,%rdi
cmova  %r13,%rdi
mov    %ebp,%esi
movsd  0x18(%rsp),%xmm0
mov    $0x2,%al
call   1060 <printf@plt>
add    $0x1,%r15d
cmp    0x8(%rsp),%r15d
jl     12c0 <main+0x130>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x78,%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 = [12 x i8] c"N-factorial\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 = [16 x i8] c"%6s %18s %20s \0A\00"
@.str.8 = [2 x i8] c"n\00"
@.str.9 = [7 x i8] c"actual\00"
@.str.10 = [10 x i8] c"factrl(n)\00"
@.str.11 = [7 x i8] c"%d %f \00"
@.str.12 = [19 x i8] c"%6d %20.0f %20.0f\0A\00"
@.str.13 = [16 x i8] c"%6d %20e %20e \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %1
%8 = 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* %8, i32** %7
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%14 = load i32*, i32** %7
%15 = call i32 @fgets(i8* %13, i32 80, i32* %14)
br label %16
16: ; preds = %29, %12
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 11)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%22 = load i32*, i32** %7
%23 = call i32 @fgets(i8* %21, i32 80, i32* %22)
%24 = load i32*, i32** %7
%25 = call i64 @feof(i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%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, %20
br label %16
30: ; preds = %16
%31 = load i32*, i32** %7
%32 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 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 ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %4
br label %36
36: ; preds = %61, %30
%37 = load i32, i32* %4
%38 = load i32, i32* %6
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %64
40: ; preds = %36
%41 = load i32*, i32** %7
%42 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32* %5, float* %3)
%43 = load float, float* %3
%44 = fpext float %43 to double
%45 = fcmp olt double %44, 1.000000e+10
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = load i32, i32* %5
%48 = load float, float* %3
%49 = fpext float %48 to double
%50 = load i32, i32* %5
%51 = call double @factrl(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i32 %47, double %49, double %51)
br label %60
53: ; preds = %40
%54 = load i32, i32* %5
%55 = load float, float* %3
%56 = fpext float %55 to double
%57 = load i32, i32* %5
%58 = call double @factrl(i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i32 %54, double %56, double %58)
br label %60
60: ; preds = %53, %46
br label %61
61: ; preds = %60
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
br label %36
64: ; preds = %36
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
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 = [12 x i8] c"N-factorial\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 = [16 x i8] c"%6s %18s %20s \0A\00"
@.str.8 = [2 x i8] c"n\00"
@.str.9 = [7 x i8] c"actual\00"
@.str.10 = [10 x i8] c"factrl(n)\00"
@.str.11 = [7 x i8] c"%d %f \00"
@.str.12 = [19 x i8] c"%6d %20.0f %20.0f\0A\00"
@.str.13 = [16 x i8] c"%6d %20e %20e \0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%6 = bitcast float* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = 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))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = call i32 @fgets(i8* %5, i32 80, i32* %9)
%15 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 11)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %13, %23
%18 = call i32 @fgets(i8* %5, i32 80, i32* %9)
%19 = call i64 @feof(i32* %9)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 11)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %17
26: ; preds = %23, %13
%27 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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 ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 1
br i1 %31, label %45, label %32
32: ; preds = %26, %32
%33 = phi i32 [ %42, %32 ], [ 1, %26 ]
%34 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32* %3, float* %2)
%35 = load float, float* %2
%36 = fpext float %35 to double
%37 = fcmp olt float %35, 1.000000e+10
%38 = load i32, i32* %3
%39 = call double @factrl(i32 %38)
%40 = select i1 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %40, i32 %38, double %36, double %39)
%42 = add nuw nsw i32 %33, 1
%43 = load i32, i32* %4
%44 = icmp slt i32 %33, %43
br i1 %44, label %32, label %45
45: ; preds = %32, %26
%46 = call i32 @fclose(i32* %9)
ret i32 0
}