#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *, double *, double *);
int pow(int, int);
main() {
  FILE *fp, *fp2;
  double lmd, n, k, ref;
  fp = fopen("SiO2", "r");
  fp2 = fopen("REF", "w");
  while (1) {
    if (fscanf(fp, "%lf %lf %lf", &lmd, &n, &k) == EOF) {
      break;
    }
    ref = pow((1 - pow(k, 2) - pow(n, 2)) / (pow(1 + n, 2) + pow(k, 2)), 2) +
          pow(2 * k / (pow(1 + n, 2) + pow(k, 2)), 2);
    fprintf(fp2, "%f %f\n", lmd, ref);
  }
  fclose(fp);
  fclose(fp2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <fscanf@plt>
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%rax
jne    11be <main+0x6e>
jmp    12cb <main+0x17b>
cvttsd2si -0x30(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
cvttsd2si -0x28(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
movsd  0xe06(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,-0x50(%rbp)
cvttsd2si -0x30(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    -0x50(%rbp),%ecx
mov    %eax,%edx
mov    -0x4c(%rbp),%eax
add    %edx,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,-0x3c(%rbp)
movsd  0xdc5(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdab(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,-0x40(%rbp)
cvttsd2si -0x30(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  -0x48(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xd68(%rip),%rsi
call   1050 <fprintf@plt>
jmp    118d <main+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xea3(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
lea    0xe94(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe84(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r13,%rdi
call   1040 <fscanf@plt>
mov    0x2e39(%rip),%r15
cmp    (%r15),%rax
je     12da <main+0x18a>
nopl   0x0(%rax,%rax,1)
cvttsd2si 0x8(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ebp
cvttsd2si 0x10(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
add    %ebp,%eax
mov    $0x1,%ebp
sub    %eax,%ebp
movsd  0x10(%rsp),%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ebx
cvttsd2si 0x8(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
add    %ebx,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%r12d
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xdad(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ebx
cvttsd2si 0x8(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
add    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
add    %r12d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x18(%rsp),%xmm0
mov    %r14,%rdi
lea    0xd73(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r13,%rdi
lea    0xd58(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <fscanf@plt>
cmp    (%r15),%rax
jne    11c0 <main+0x70>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"SiO2\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"REF\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [12 x i8] c"%lf %lf %lf\00"
@EOF = global i64 0
@.str.5 = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 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** %2
%9 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %3
br label %10
10: ; preds = %0, %16
%11 = load i32*, i32** %2
%12 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double* %4, double* %5, double* %6)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %10
br label %55
16: ; preds = %10
%17 = load double, double* %6
%18 = fptosi double %17 to i32
%19 = call i32 @pow(i32 %18, i32 2)
%20 = sub nsw i32 1, %19
%21 = load double, double* %5
%22 = fptosi double %21 to i32
%23 = call i32 @pow(i32 %22, i32 2)
%24 = sub nsw i32 %20, %23
%25 = load double, double* %5
%26 = fadd double 1.000000e+00, %25
%27 = fptosi double %26 to i32
%28 = call i32 @pow(i32 %27, i32 2)
%29 = load double, double* %6
%30 = fptosi double %29 to i32
%31 = call i32 @pow(i32 %30, i32 2)
%32 = add nsw i32 %28, %31
%33 = sdiv i32 %24, %32
%34 = call i32 @pow(i32 %33, i32 2)
%35 = load double, double* %6
%36 = fmul double 2.000000e+00, %35
%37 = load double, double* %5
%38 = fadd double 1.000000e+00, %37
%39 = fptosi double %38 to i32
%40 = call i32 @pow(i32 %39, i32 2)
%41 = load double, double* %6
%42 = fptosi double %41 to i32
%43 = call i32 @pow(i32 %42, i32 2)
%44 = add nsw i32 %40, %43
%45 = sitofp i32 %44 to double
%46 = fdiv double %36, %45
%47 = fptosi double %46 to i32
%48 = call i32 @pow(i32 %47, i32 2)
%49 = add nsw i32 %34, %48
%50 = sitofp i32 %49 to double
store double %50, double* %7
%51 = load i32*, i32** %3
%52 = load double, double* %4
%53 = load double, double* %7
%54 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %52, double %53)
br label %10
55: ; preds = %15
%56 = load i32*, i32** %2
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %3
%59 = call i32 @fclose(i32* %58)
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [5 x i8] c"SiO2\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"REF\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [12 x i8] c"%lf %lf %lf\00"
@EOF = global i64 0
@.str.5 = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double* %1, double* %2, double* %3)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %52, label %12
12: ; preds = %0, %12
%13 = load double, double* %3
%14 = fptosi double %13 to i32
%15 = call i32 @pow(i32 %14, i32 2)
%16 = load double, double* %2
%17 = fptosi double %16 to i32
%18 = call i32 @pow(i32 %17, i32 2)
%19 = add i32 %15, %18
%20 = sub i32 1, %19
%21 = load double, double* %2
%22 = fadd double %21, 1.000000e+00
%23 = fptosi double %22 to i32
%24 = call i32 @pow(i32 %23, i32 2)
%25 = load double, double* %3
%26 = fptosi double %25 to i32
%27 = call i32 @pow(i32 %26, i32 2)
%28 = add nsw i32 %27, %24
%29 = sdiv i32 %20, %28
%30 = call i32 @pow(i32 %29, i32 2)
%31 = load double, double* %3
%32 = fmul double %31, 2.000000e+00
%33 = load double, double* %2
%34 = fadd double %33, 1.000000e+00
%35 = fptosi double %34 to i32
%36 = call i32 @pow(i32 %35, i32 2)
%37 = load double, double* %3
%38 = fptosi double %37 to i32
%39 = call i32 @pow(i32 %38, i32 2)
%40 = add nsw i32 %39, %36
%41 = sitofp i32 %40 to double
%42 = fdiv double %32, %41
%43 = fptosi double %42 to i32
%44 = call i32 @pow(i32 %43, i32 2)
%45 = add nsw i32 %44, %30
%46 = sitofp i32 %45 to double
%47 = load double, double* %1
%48 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %47, double %46)
%49 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double* %1, double* %2, double* %3)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %12
52: ; preds = %12, %0
%53 = call i32 @fclose(i32* %7)
%54 = call i32 @fclose(i32* %8)
ret i32 0
}