#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 */
int /*<<< orphan*/ evalResidua(int, int, double, double, double *, double,
                               double);
double log(double);
int /*<<< orphan*/ printf(char *, double, double, double);
void scanResidua(int n, int i0, double dx, int nE, double Emin, double Emax,
                 double *V_buff, double *E_buff, double *y2out_buff) {
  double dE = (Emax - Emin) / nE;
  for (int i = 0; i < nE; i++) {
    double E = i * dE;
    double y2out = 0, fb_best = 0;
    evalResidua(n, i0, dx, E, V_buff, fb_best, y2out);
    y2out_buff[i] = log(y2out) * 0.05;
    E_buff[i] = E;
    printf(" E= %f y2out= %f  log(y2out) %f \n", E, y2out, y2out_buff[i]);
  }
}


x86 assembly (clang, -O0):
<scanResidua>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <scanResidua+0xff>
cvtsi2sdl -0x4c(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    -0x30(%rbp),%rdx
movsd  -0x68(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
call   1040 <evalResidua@plt>
movsd  -0x60(%rbp),%xmm0
call   1050 <log@plt>
movsd  0xe25(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    117b <scanResidua+0x4b>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanResidua>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x18(%rsp)
test   %edx,%edx
jle    11f5 <scanResidua+0xc5>
mov    %r9,%rbx
mov    %rcx,%r15
mov    %esi,%r12d
mov    %edi,%ebp
subsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %edx,%r13d
xor    %r14d,%r14d
movsd  %xmm0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
xorpd  %xmm2,%xmm2
xorps  %xmm3,%xmm3
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15,%rdx
call   1040 <evalResidua@plt>
xorpd  %xmm0,%xmm0
call   1050 <log@plt>
mulsd  0xe47(%rip),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
mov    0x18(%rsp),%rax
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rax,%r14,8)
movsd  (%rbx,%r14,8),%xmm2
xorpd  %xmm1,%xmm1
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x1,%r14
cmp    %r14,%r13
jne    1180 <scanResidua+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c" E= %f y2out= %f log(y2out) %f \0A\00"
define void @scanResidua(i32 %0, i32 %1, double %2, i32 %3, double %4, double %5, double* %6, double* %7, double* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store double %2, double* %12
store i32 %3, i32* %13
store double %4, double* %14
store double %5, double* %15
store double* %6, double** %16
store double* %7, double** %17
store double* %8, double** %18
%24 = load double, double* %15
%25 = load double, double* %14
%26 = fsub double %24, %25
%27 = load i32, i32* %13
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
store double %29, double* %19
store i32 0, i32* %20
br label %30
30: ; preds = %67, %9
%31 = load i32, i32* %20
%32 = load i32, i32* %13
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %70
34: ; preds = %30
%35 = load i32, i32* %20
%36 = sitofp i32 %35 to double
%37 = load double, double* %19
%38 = fmul double %36, %37
store double %38, double* %21
store double 0.000000e+00, double* %22
store double 0.000000e+00, double* %23
%39 = load i32, i32* %10
%40 = load i32, i32* %11
%41 = load double, double* %12
%42 = load double, double* %21
%43 = load double*, double** %16
%44 = load double, double* %23
%45 = load double, double* %22
%46 = call i32 @evalResidua(i32 %39, i32 %40, double %41, double %42, double* %43, double %44, double %45)
%47 = load double, double* %22
%48 = call double @log(double %47)
%49 = fmul double %48, 5.000000e-02
%50 = load double*, double** %18
%51 = load i32, i32* %20
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %49, double* %53
%54 = load double, double* %21
%55 = load double*, double** %17
%56 = load i32, i32* %20
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
store double %54, double* %58
%59 = load double, double* %21
%60 = load double, double* %22
%61 = load double*, double** %18
%62 = load i32, i32* %20
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
%65 = load double, double* %64
%66 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %59, double %60, double %65)
br label %67
67: ; preds = %34
%68 = load i32, i32* %20
%69 = add nsw i32 %68, 1
store i32 %69, i32* %20
br label %30
70: ; preds = %30
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c" E= %f y2out= %f log(y2out) %f \0A\00"
define void @scanResidua(i32 %0, i32 %1, double %2, i32 %3, double %4, double %5, double* %6, double* nocapture writeonly %7, double* nocapture %8) {
%10 = fsub double %5, %4
%11 = sitofp i32 %3 to double
%12 = fdiv double %10, %11
%13 = icmp sgt i32 %3, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = zext i32 %3 to i64
br label %17
16: ; preds = %17, %9
ret void
17: ; preds = %14, %17
%18 = phi i64 [ 0, %14 ], [ %29, %17 ]
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to double
%21 = fmul double %12, %20
%22 = tail call i32 @evalResidua(i32 %0, i32 %1, double %2, double %21, double* %6, double 0.000000e+00, double 0.000000e+00)
%23 = tail call double @log(double 0.000000e+00)
%24 = fmul double %23, 5.000000e-02
%25 = getelementptr inbounds double, double* %8, i64 %18
store double %24, double* %25
%26 = getelementptr inbounds double, double* %7, i64 %18
store double %21, double* %26
%27 = load double, double* %25
%28 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %21, double 0.000000e+00, double %27)
%29 = add nuw nsw i64 %18, 1
%30 = icmp eq i64 %29, %15
br i1 %30, label %16, label %17
}