#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 ellf(float, float);
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*/ nrerror(char *);
int /*<<< orphan*/ printf(char *, ...);
float sin(float);
scalar_t__ strncmp(char *, char *, int);
int main(void) {
  char txt[80];
  int i, nval;
  float ak, alpha, phi, val;
  FILE *fp;
  if ((fp = fopen("fncval.dat", "r")) == NULL)
    nrerror("Data file fncval.dat not found\n");
  fgets(txt, 80, fp);
  while (strncmp(txt, "Legendre Elliptic Integral First Kind", 37)) {
    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("%5s %10s %11s %22s\n", "phi", "sin(alpha)", "actual", "ellf(phi,ak)");
  for (i = 1; i <= nval; i++) {
    fscanf(fp, "%f %f %f", &phi, &alpha, &val);
    alpha = alpha * (3.1415926535 / 180.0);
    ak = sin(alpha);
    phi = phi * (3.1415926535 / 180.0);
    printf("%6.2f %6.2f %18.6e %18.6e\n", phi, ak, val, ellf(phi, ak));
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe4f(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x80(%rbp)
cmp    $0x0,%rax
jne    11df <main+0x3f>
lea    0xe3b(%rip),%rdi
call   1040 <nrerror@plt>
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
lea    -0x60(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x25,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1246 <main+0xa6>
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x80(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%rax
je     1241 <main+0xa1>
lea    0xe1f(%rip),%rdi
call   1040 <nrerror@plt>
jmp    11f1 <main+0x51>
mov    -0x80(%rbp),%rdi
lea    0xe28(%rip),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe10(%rip),%rdi
lea    0xe1d(%rip),%rsi
lea    0xe1a(%rip),%rdx
lea    0xe1e(%rip),%rcx
lea    0xe1e(%rip),%r8
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x68(%rbp),%eax
jg     138d <main+0x1ed>
mov    -0x80(%rbp),%rdi
lea    0xe06(%rip),%rsi
lea    -0x74(%rbp),%rdx
lea    -0x70(%rbp),%rcx
lea    -0x78(%rbp),%r8
mov    $0x0,%al
call   1070 <fscanf@plt>
movss  -0x70(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd26(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x70(%rbp)
movss  -0x70(%rbp),%xmm0
call   10b0 <sin@plt>
movss  %xmm0,-0x6c(%rbp)
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x74(%rbp)
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movss  -0x74(%rbp),%xmm0
movss  -0x6c(%rbp),%xmm1
call   1090 <ellf@plt>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x88(%rbp),%xmm0
ff
lea    0xd4d(%rip),%rdi
mov    $0x4,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    129f <main+0xff>
mov    -0x80(%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    $0x88,%rsp
lea    0xe50(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d8 <main+0x38>
lea    0xe42(%rip),%rdi
call   1040 <nrerror@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
lea    0xe41(%rip),%rsi
mov    %rbp,%rdi
mov    $0x25,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     125c <main+0xbc>
lea    0x30(%rsp),%rbp
lea    0xe23(%rip),%r14
lea    0xe42(%rip),%r15
jmp    1235 <main+0x95>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x25,%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   10a0 <feof@plt>
test   %rax,%rax
je     1220 <main+0x80>
mov    %r15,%rdi
call   1040 <nrerror@plt>
jmp    1220 <main+0x80>
lea    0xe16(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0xe07(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf9(%rip),%rdi
lea    0xe06(%rip),%rsi
lea    0xe03(%rip),%rdx
lea    0xe07(%rip),%rcx
lea    0xe07(%rip),%r8
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x10(%rsp)
jle    139b <main+0x1fb>
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0xdf5(%rip),%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
lea    0xdd2(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1070 <fscanf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcf4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
call   10b0 <sin@plt>
movaps %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xccc(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x28(%rsp)
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
movsd  %xmm2,0x20(%rsp)
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
movsd  %xmm2,0x18(%rsp)
call   1090 <ellf@plt>
movaps %xmm0,%xmm3
mov    %rbp,%rdi
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mov    $0x4,%al
call   1060 <printf@plt>
add    $0x1,%r14d
cmp    0x10(%rsp),%r14d
jl     12e0 <main+0x140>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x88,%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 = [38 x i8] c"Legendre Elliptic Integral First Kind\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 = [20 x i8] c"%5s %10s %11s %22s\0A\00"
@.str.8 = [4 x i8] c"phi\00"
@.str.9 = [11 x i8] c"sin(alpha)\00"
@.str.10 = [7 x i8] c"actual\00"
@.str.11 = [13 x i8] c"ellf(phi,ak)\00"
@.str.12 = [9 x i8] c"%f %f %f\00"
@.str.13 = [27 x i8] c"%6.2f %6.2f %18.6e %18.6e\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 i32*
store i32 0, i32* %1
%10 = 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* %10, i32** %9
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%16 = load i32*, i32** %9
%17 = call i32 @fgets(i8* %15, i32 80, i32* %16)
br label %18
18: ; preds = %31, %14
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%20 = call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 37)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%24 = load i32*, i32** %9
%25 = call i32 @fgets(i8* %23, i32 80, i32* %24)
%26 = load i32*, i32** %9
%27 = call i64 @feof(i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %22
br label %18
32: ; preds = %18
%33 = load i32*, i32** %9
%34 = call i32 (i32*, i8*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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 ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %38
38: ; preds = %65, %32
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = icmp sle i32 %39, %40
br i1 %41, label %42, label %68
42: ; preds = %38
%43 = load i32*, i32** %9
%44 = call i32 (i32*, i8*, ...) @fscanf(i32* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), float* %7, float* %6, float* %8)
%45 = load float, float* %6
%46 = fpext float %45 to double
%47 = fmul double %46, 0x3F91DF46A2506B91
%48 = fptrunc double %47 to float
store float %48, float* %6
%49 = load float, float* %6
%50 = call float @sin(float %49)
store float %50, float* %5
%51 = load float, float* %7
%52 = fpext float %51 to double
%53 = fmul double %52, 0x3F91DF46A2506B91
%54 = fptrunc double %53 to float
store float %54, float* %7
%55 = load float, float* %7
%56 = fpext float %55 to double
%57 = load float, float* %5
%58 = fpext float %57 to double
%59 = load float, float* %8
%60 = fpext float %59 to double
%61 = load float, float* %7
%62 = load float, float* %5
%63 = call double @ellf(float %61, float %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), double %56, double %58, double %60, double %63)
br label %65
65: ; preds = %42
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
store i32 %67, i32* %3
br label %38
68: ; preds = %38
%69 = load i32*, i32** %9
%70 = call i32 @fclose(i32* %69)
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 = [38 x i8] c"Legendre Elliptic Integral First Kind\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 = [20 x i8] c"%5s %10s %11s %22s\0A\00"
@.str.8 = [4 x i8] c"phi\00"
@.str.9 = [11 x i8] c"sin(alpha)\00"
@.str.10 = [7 x i8] c"actual\00"
@.str.11 = [13 x i8] c"ellf(phi,ak)\00"
@.str.12 = [9 x i8] c"%f %f %f\00"
@.str.13 = [27 x i8] c"%6.2f %6.2f %18.6e %18.6e\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%7 = bitcast i32* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = 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))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = tail 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 = call i32 @fgets(i8* %6, i32 80, i32* %11)
%17 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 37)
%18 = icmp eq i64 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %15, %25
%20 = call i32 @fgets(i8* %6, i32 80, i32* %11)
%21 = call i64 @feof(i32* %11)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 37)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %19
28: ; preds = %25, %15
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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 ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 1
br i1 %33, label %55, label %34
34: ; preds = %28, %34
%35 = phi i32 [ %52, %34 ], [ 1, %28 ]
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), float* %4, float* %3, float* %5)
%37 = load float, float* %3
%38 = fpext float %37 to double
%39 = fmul double %38, 0x3F91DF46A2506B91
%40 = fptrunc double %39 to float
store float %40, float* %3
%41 = call float @sin(float %40)
%42 = load float, float* %4
%43 = fpext float %42 to double
%44 = fmul double %43, 0x3F91DF46A2506B91
%45 = fptrunc double %44 to float
store float %45, float* %4
%46 = fpext float %45 to double
%47 = fpext float %41 to double
%48 = load float, float* %5
%49 = fpext float %48 to double
%50 = call double @ellf(float %45, float %41)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), double %46, double %47, double %49, double %50)
%52 = add nuw nsw i32 %35, 1
%53 = load i32, i32* %2
%54 = icmp slt i32 %35, %53
br i1 %54, label %34, label %55
55: ; preds = %34, %28
%56 = call i32 @fclose(i32* %11)
ret i32 0
}