#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_simple(struct conf *, struct marker *,
                                  struct marker *, unsigned int, unsigned int *,
                                  unsigned int *);
unsigned int log10(double);
void calc_rflod_simple(struct conf *c, struct marker *m1, struct marker *m2,
                       unsigned x, double *_lod, double *_rf) {
  unsigned R, S, N;
  double r, s, lod;
  calc_RN_simple(c, m1, m2, x, &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_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    -0x34(%rbp),%r8
lea    -0x3c(%rbp),%r9
call   1030 <calc_RN_simple@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    118a <calc_rflod_simple+0x6a>
mov    -0x30(%rbp),%rax
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    125a <calc_rflod_simple+0x13a>
mov    -0x34(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x3c(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe55(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x3c(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1203 <calc_rflod_simple+0xe3>
mov    -0x38(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  %xmm0,%xmm0
call   1040 <log10@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1240 <calc_rflod_simple+0x120>
mov    -0x34(%rbp),%eax
mov    %eax,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  %xmm0,%xmm0
call   1040 <log10@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_rflod_simple>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r9,%r14
mov    %r8,%rbx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
call   1030 <calc_RN_simple@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
je     11d7 <calc_rflod_simple+0xb7>
mov    0x8(%rsp),%eax
cvtsi2sd %rax,%xmm1
mov    %ebp,%ecx
cvtsi2sd %rcx,%xmm0
divsd  %xmm0,%xmm1
movsd  0xea3(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
xorpd  %xmm2,%xmm2
movsd  %xmm1,0x10(%rsp)
jbe    119d <calc_rflod_simple+0x7d>
sub    %eax,%ebp
addsd  %xmm0,%xmm0
call   1040 <log10@plt>
xorpd  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm1
imul   %ebp,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
ucomisd %xmm3,%xmm1
jbe    11e3 <calc_rflod_simple+0xc3>
mov    0x8(%rsp),%ebp
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm2,0x18(%rsp)
call   1040 <log10@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm2
jmp    11e3 <calc_rflod_simple+0xc3>
movsd  0xe21(%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_simple(%struct.conf* %0, %struct.marker* %1, %struct.marker* %2, i32 %3, double* %4, double* %5) {
%7 = alloca %struct.conf*
%8 = alloca %struct.marker*
%9 = alloca %struct.marker*
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
store %struct.conf* %0, %struct.conf** %7
store %struct.marker* %1, %struct.marker** %8
store %struct.marker* %2, %struct.marker** %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%19 = load %struct.conf*, %struct.conf** %7
%20 = load %struct.marker*, %struct.marker** %8
%21 = load %struct.marker*, %struct.marker** %9
%22 = load i32, i32* %10
%23 = call i32 @calc_RN_simple(%struct.conf* %19, %struct.marker* %20, %struct.marker* %21, i32 %22, i32* %13, i32* %15)
%24 = load i32, i32* %15
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %6
%27 = load double*, double** %12
store double -1.000000e+02, double* %27
%28 = load double*, double** %11
store double -1.000000e+02, double* %28
br label %68
29: ; preds = %6
%30 = load i32, i32* %13
%31 = uitofp i32 %30 to double
%32 = load i32, i32* %15
%33 = uitofp i32 %32 to double
%34 = fdiv double %31, %33
store double %34, double* %16
%35 = load double, double* %16
%36 = fsub double 1.000000e+00, %35
store double %36, double* %17
%37 = load i32, i32* %15
%38 = load i32, i32* %13
%39 = sub i32 %37, %38
store i32 %39, i32* %14
store double 0.000000e+00, double* %18
%40 = load double, double* %17
%41 = fcmp ogt double %40, 0.000000e+00
br i1 %41, label %42, label %51
42: ; preds = %29
%43 = load i32, i32* %14
%44 = load double, double* %17
%45 = fmul double 2.000000e+00, %44
%46 = call i32 @log10(double %45)
%47 = mul i32 %43, %46
%48 = uitofp i32 %47 to double
%49 = load double, double* %18
%50 = fadd double %49, %48
store double %50, double* %18
br label %51
51: ; preds = %42, %29
%52 = load double, double* %16
%53 = fcmp ogt double %52, 0.000000e+00
br i1 %53, label %54, label %63
54: ; preds = %51
%55 = load i32, i32* %13
%56 = load double, double* %16
%57 = fmul double 2.000000e+00, %56
%58 = call i32 @log10(double %57)
%59 = mul i32 %55, %58
%60 = uitofp i32 %59 to double
%61 = load double, double* %18
%62 = fadd double %61, %60
store double %62, double* %18
br label %63
63: ; preds = %54, %51
%64 = load double, double* %16
%65 = load double*, double** %12
store double %64, double* %65
%66 = load double, double* %18
%67 = load double*, double** %11
store double %66, double* %67
br label %68
68: ; preds = %63, %26
ret void
}

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