#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 n(double);
double pow(double, double);
int /*<<< orphan*/ printf(char *, double, double);
double sin(double);
int main(int argc, char *argv[]) {
  double lP, lS, lI;
  double nP, nS, nI;
  double dnS, dnI, detuning;
  double k, x, eff[5000], lambda[5000];
  int i;
  for (i = 0; i < 5000; i++) {
    lP = 780e-9;
    detuning = (double)i * 15.e-9 / 5000;
    lS = lP + detuning;
    lI = lP - detuning;
    dnS = -1.e3 * lS + 0.0017;
    dnI = -1.e3 * lI + 0.0017;
    nP = n(lP);
    nS = n(lS) - dnS;
    nI = n(lI) - dnI;
    k = 2.0 * 3.141592653 * (nS / lS + nI / lI - 2 * nP / lP);
    x = k * 8.e-3 / 2;
    eff[i] = pow(sin(x) / x, 2.0);
    lambda[i] = detuning * 1.e9;
    printf("%f\t%f\n", lambda[i], eff[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13900,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x138f4(%rbp)
cmpl   $0x1388,-0x138f4(%rbp)
jge    1324 <main+0x1e4>
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x138f4(%rbp),%xmm0
ff
movsd  0xea8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe50(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <n@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <n@plt>
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <n@plt>
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdaa(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
subsd  %xmm0,%xmm1
movsd  0xda4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xd8b(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1050 <sin@plt>
divsd  -0x68(%rbp),%xmm0
movsd  0xd56(%rip),%xmm1
call   1060 <pow@plt>
movslq -0x138f4(%rbp),%rax
movsd  %xmm0,-0x9cb0(%rbp,%rax,8)
ff ff
movsd  0xd31(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movslq -0x138f4(%rbp),%rax
movsd  %xmm0,-0x138f0(%rbp,%rax,8)
fe ff
movslq -0x138f4(%rbp),%rax
movsd  -0x138f0(%rbp,%rax,8),%xmm0
fe ff
movslq -0x138f4(%rbp),%rax
movsd  -0x9cb0(%rbp,%rax,8),%xmm1
ff ff
lea    0xd3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x138f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138f4(%rbp)
jmp    1163 <main+0x23>
xor    %eax,%eax
add    $0x13900,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
xorpd  %xmm0,%xmm0
mov    $0x1388,%ebp
lea    0xf1a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x38(%rsp)
movapd %xmm0,%xmm1
mulsd  0xe9e(%rip),%xmm1
divsd  0xe9e(%rip),%xmm1
movsd  %xmm1,0x30(%rsp)
movapd %xmm1,%xmm2
movsd  0xe94(%rip),%xmm0
addsd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
movsd  %xmm4,0x8(%rsp)
movapd %xmm2,%xmm3
movsd  0xe78(%rip),%xmm1
mulsd  %xmm1,%xmm3
movsd  0xe74(%rip),%xmm2
addsd  %xmm2,%xmm3
movapd %xmm3,0x60(%rsp)
mulsd  %xmm1,%xmm4
addsd  %xmm2,%xmm4
movsd  %xmm4,0x28(%rsp)
call   1030 <n@plt>
movapd %xmm0,0x50(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <n@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <n@plt>
subsd  0x28(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movapd 0x40(%rsp),%xmm1
movapd %xmm1,%xmm2
unpcklpd 0x50(%rsp),%xmm2
subsd  0x60(%rsp),%xmm1
addpd  %xmm2,%xmm2
movsd  %xmm1,%xmm2
movapd 0x10(%rsp),%xmm1
shufpd $0x2,0xe2e(%rip),%xmm1
divpd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
unpckhpd %xmm2,%xmm2
subsd  %xmm2,%xmm0
mulsd  0xdee(%rip),%xmm0
mulsd  0xdee(%rip),%xmm0
mulsd  0xdee(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1050 <sin@plt>
movapd %xmm0,%xmm1
divsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0xdcf(%rip),%xmm0
mov    %rbx,%rdi
call   1040 <printf@plt>
movsd  0x38(%rsp),%xmm0
addsd  0xdc1(%rip),%xmm0
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%f\09%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca [5000 x double]
%18 = alloca [5000 x double]
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %19
br label %20
20: ; preds = %86, %2
%21 = load i32, i32* %19
%22 = icmp slt i32 %21, 5000
br i1 %22, label %23, label %89
23: ; preds = %20
store double 7.800000e-07, double* %6
%24 = load i32, i32* %19
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 1.500000e-08
%27 = fdiv double %26, 5.000000e+03
store double %27, double* %14
%28 = load double, double* %6
%29 = load double, double* %14
%30 = fadd double %28, %29
store double %30, double* %7
%31 = load double, double* %6
%32 = load double, double* %14
%33 = fsub double %31, %32
store double %33, double* %8
%34 = load double, double* %7
%35 = call double @llvm.fmuladd.f64(double -1.000000e+03, double %34, double 1.700000e-03)
store double %35, double* %12
%36 = load double, double* %8
%37 = call double @llvm.fmuladd.f64(double -1.000000e+03, double %36, double 1.700000e-03)
store double %37, double* %13
%38 = load double, double* %6
%39 = call double @n(double %38)
store double %39, double* %9
%40 = load double, double* %7
%41 = call double @n(double %40)
%42 = load double, double* %12
%43 = fsub double %41, %42
store double %43, double* %10
%44 = load double, double* %8
%45 = call double @n(double %44)
%46 = load double, double* %13
%47 = fsub double %45, %46
store double %47, double* %11
%48 = load double, double* %10
%49 = load double, double* %7
%50 = fdiv double %48, %49
%51 = load double, double* %11
%52 = load double, double* %8
%53 = fdiv double %51, %52
%54 = fadd double %50, %53
%55 = load double, double* %9
%56 = fmul double 2.000000e+00, %55
%57 = load double, double* %6
%58 = fdiv double %56, %57
%59 = fsub double %54, %58
%60 = fmul double 0x401921FB542FE938, %59
store double %60, double* %15
%61 = load double, double* %15
%62 = fmul double %61, 8.000000e-03
%63 = fdiv double %62, 2.000000e+00
store double %63, double* %16
%64 = load double, double* %16
%65 = call double @sin(double %64)
%66 = load double, double* %16
%67 = fdiv double %65, %66
%68 = call double @pow(double %67, double 2.000000e+00)
%69 = load i32, i32* %19
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [5000 x double], [5000 x double]* %17, i64 0, i64 %70
store double %68, double* %71
%72 = load double, double* %14
%73 = fmul double %72, 1.000000e+09
%74 = load i32, i32* %19
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [5000 x double], [5000 x double]* %18, i64 0, i64 %75
store double %73, double* %76
%77 = load i32, i32* %19
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [5000 x double], [5000 x double]* %18, i64 0, i64 %78
%80 = load double, double* %79
%81 = load i32, i32* %19
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [5000 x double], [5000 x double]* %17, i64 0, i64 %82
%84 = load double, double* %83
%85 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %80, double %84)
br label %86
86: ; preds = %23
%87 = load i32, i32* %19
%88 = add nsw i32 %87, 1
store i32 %88, i32* %19
br label %20
89: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%f\09%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %37, %3 ]
%5 = sitofp i32 %4 to double
%6 = fmul double %5, 1.500000e-08
%7 = fdiv double %6, 5.000000e+03
%8 = fadd double %7, 7.800000e-07
%9 = fsub double 7.800000e-07, %7
%10 = tail call double @llvm.fmuladd.f64(double %8, double -1.000000e+03, double 1.700000e-03)
%11 = tail call double @llvm.fmuladd.f64(double %9, double -1.000000e+03, double 1.700000e-03)
%12 = tail call double @n(double 7.800000e-07)
%13 = tail call double @n(double %8)
%14 = tail call double @n(double %9)
%15 = fsub double %14, %11
%16 = fdiv double %15, %9
%17 = insertelement <2 x double> poison, double %13, i64 0
%18 = insertelement <2 x double> %17, double %12, i64 1
%19 = insertelement <2 x double> <double poison, double 2.000000e+00>, double %10, i64 0
%20 = fsub <2 x double> %18, %19
%21 = fmul <2 x double> %18, %19
%22 = shufflevector <2 x double> %20, <2 x double> %21, <2 x i32> <i32 0, i32 3>
%23 = insertelement <2 x double> <double poison, double 7.800000e-07>, double %8, i64 0
%24 = fdiv <2 x double> %22, %23
%25 = extractelement <2 x double> %24, i64 0
%26 = fadd double %25, %16
%27 = extractelement <2 x double> %24, i64 1
%28 = fsub double %26, %27
%29 = fmul double %28, 0x401921FB542FE938
%30 = fmul double %29, 8.000000e-03
%31 = fmul double %30, 5.000000e-01
%32 = tail call double @sin(double %31)
%33 = fdiv double %32, %31
%34 = fmul double %33, %33
%35 = fmul double %7, 1.000000e+09
%36 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %35, double %34)
%37 = add nuw nsw i32 %4, 1
%38 = icmp eq i32 %37, 5000
br i1 %38, label %39, label %3
39: ; preds = %3
ret i32 0
}