#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 */
struct marker {
  int dummy;
};
struct conf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ calc_RN_simple2(struct conf *, struct marker *,
                                   struct marker *, unsigned int, unsigned int,
                                   unsigned int *, unsigned int *);
unsigned int log10(double);
void calc_rflod_simple2(struct conf *c, struct marker *m1, struct marker *m2,
                        unsigned x, unsigned y, double *_lod, double *_rf) {
  unsigned R, S, N;
  double r, s, lod;
  calc_RN_simple2(c, m1, m2, x, y, &R, &N);
  if (N == 0) {
    *_rf = -100.0;
    *_lod = -100.0;
    return;
  }
  r = (double)R / N;
  s = 1.0 - r;
  S = N - R;
  lod = 0.0;
  if (s > 0.0)
    lod += S * log10(2.0 * s);
  if (r > 0.0)
    lod += R * log10(2.0 * r);
  *_rf = r;
  *_lod = lod;
}


x86 assembly (clang, -O0):
<calc_rflod_simple2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    -0x2c(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <calc_RN_simple2@plt>
cmpl   $0x0,-0x34(%rbp)
jne    1196 <calc_rflod_simple2+0x76>
mov    0x10(%rbp),%rax
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1266 <calc_rflod_simple2+0x146>
mov    -0x2c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x34(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe49(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    120f <calc_rflod_simple2+0xef>
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <log10@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    124c <calc_rflod_simple2+0x12c>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <log10@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_rflod_simple2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r9,%rbx
mov    0x40(%rsp),%r14
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0x8(%rsp),%r9
call   1040 <calc_RN_simple2@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
je     11dd <calc_rflod_simple2+0xbd>
mov    0x8(%rsp),%eax
cvtsi2sd %rax,%xmm1
mov    %ebp,%ecx
cvtsi2sd %rcx,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
xorpd  %xmm2,%xmm2
movsd  %xmm1,0x10(%rsp)
jbe    11a3 <calc_rflod_simple2+0x83>
sub    %eax,%ebp
addsd  %xmm0,%xmm0
call   1030 <log10@plt>
xorpd  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm1
imul   %ebp,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
ucomisd %xmm3,%xmm1
jbe    11e9 <calc_rflod_simple2+0xc9>
mov    0x8(%rsp),%ebp
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm2,0x18(%rsp)
call   1030 <log10@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm2
jmp    11e9 <calc_rflod_simple2+0xc9>
movsd  0xe1b(%rip),%xmm1
movapd %xmm1,%xmm2
movsd  %xmm1,(%r14)
movsd  %xmm2,(%rbx)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.conf = type { i32 }
%struct.marker = type { i32 }
define void @calc_rflod_simple2(%struct.conf* %0, %struct.marker* %1, %struct.marker* %2, i32 %3, i32 %4, double* %5, double* %6) {
%8 = alloca %struct.conf*
%9 = alloca %struct.marker*
%10 = alloca %struct.marker*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
store %struct.conf* %0, %struct.conf** %8
store %struct.marker* %1, %struct.marker** %9
store %struct.marker* %2, %struct.marker** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store double* %5, double** %13
store double* %6, double** %14
%21 = load %struct.conf*, %struct.conf** %8
%22 = load %struct.marker*, %struct.marker** %9
%23 = load %struct.marker*, %struct.marker** %10
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = call i32 @calc_RN_simple2(%struct.conf* %21, %struct.marker* %22, %struct.marker* %23, i32 %24, i32 %25, i32* %15, i32* %17)
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %7
%30 = load double*, double** %14
store double -1.000000e+02, double* %30
%31 = load double*, double** %13
store double -1.000000e+02, double* %31
br label %71
32: ; preds = %7
%33 = load i32, i32* %15
%34 = uitofp i32 %33 to double
%35 = load i32, i32* %17
%36 = uitofp i32 %35 to double
%37 = fdiv double %34, %36
store double %37, double* %18
%38 = load double, double* %18
%39 = fsub double 1.000000e+00, %38
store double %39, double* %19
%40 = load i32, i32* %17
%41 = load i32, i32* %15
%42 = sub i32 %40, %41
store i32 %42, i32* %16
store double 0.000000e+00, double* %20
%43 = load double, double* %19
%44 = fcmp ogt double %43, 0.000000e+00
br i1 %44, label %45, label %54
45: ; preds = %32
%46 = load i32, i32* %16
%47 = load double, double* %19
%48 = fmul double 2.000000e+00, %47
%49 = call i32 @log10(double %48)
%50 = mul i32 %46, %49
%51 = uitofp i32 %50 to double
%52 = load double, double* %20
%53 = fadd double %52, %51
store double %53, double* %20
br label %54
54: ; preds = %45, %32
%55 = load double, double* %18
%56 = fcmp ogt double %55, 0.000000e+00
br i1 %56, label %57, label %66
57: ; preds = %54
%58 = load i32, i32* %15
%59 = load double, double* %18
%60 = fmul double 2.000000e+00, %59
%61 = call i32 @log10(double %60)
%62 = mul i32 %58, %61
%63 = uitofp i32 %62 to double
%64 = load double, double* %20
%65 = fadd double %64, %63
store double %65, double* %20
br label %66
66: ; preds = %57, %54
%67 = load double, double* %18
%68 = load double*, double** %14
store double %67, double* %68
%69 = load double, double* %20
%70 = load double*, double** %13
store double %69, double* %70
br label %71
71: ; preds = %66, %29
ret void
}

LLVM IR (-O2):
%struct.conf = type { i32 }
%struct.marker = type { i32 }
define void @calc_rflod_simple2(%struct.conf* %0, %struct.marker* %1, %struct.marker* %2, i32 %3, i32 %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %8 to i8*
%11 = bitcast i32* %9 to i8*
%12 = call i32 @calc_RN_simple2(%struct.conf* %0, %struct.marker* %1, %struct.marker* %2, i32 %3, i32 %4, i32* %8, i32* %9)
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %38, label %15
15: ; preds = %7
%16 = load i32, i32* %8
%17 = uitofp i32 %16 to double
%18 = uitofp i32 %13 to double
%19 = fdiv double %17, %18
%20 = fsub double 1.000000e+00, %19
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = sub i32 %13, %16
%24 = fmul double %20, 2.000000e+00
%25 = call i32 @log10(double %24)
%26 = mul i32 %25, %23
%27 = uitofp i32 %26 to double
br label %28
28: ; preds = %22, %15
%29 = phi double [ %27, %22 ], [ 0.000000e+00, %15 ]
%30 = fcmp ogt double %19, 0.000000e+00
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %8
%33 = fmul double %19, 2.000000e+00
%34 = call i32 @log10(double %33)
%35 = mul i32 %34, %32
%36 = uitofp i32 %35 to double
%37 = fadd double %29, %36
br label %38
38: ; preds = %28, %31, %7
%39 = phi double [ -1.000000e+02, %7 ], [ %19, %31 ], [ %19, %28 ]
%40 = phi double [ -1.000000e+02, %7 ], [ %37, %31 ], [ %29, %28 ]
store double %39, double* %6
store double %40, double* %5
ret void
}