#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 */
float detect_mean(float *, int);
float detect_variance(float *, int, float);
int /*<<< orphan*/ light_curve_base(float *, float *, int, float, float *,
                                    float *, int);
int /*<<< orphan*/ light_curve_resample(float, float, float *, float *, int,
                                        float, float *, int);
int missing_data(float *, int);
int light_curve(float timestamp[], float series[], int series_length,
                float period_days, float curve[], float density[],
                int curve_length) {
  float mean, variance;
  light_curve_base(timestamp, series, series_length, period_days, curve,
                   density, curve_length);
  if (missing_data(density, curve_length) * 100 / curve_length > 0)
    return -1;
  mean = detect_mean(series, series_length);
  variance = detect_variance(series, series_length, mean);
  light_curve_resample(mean - variance, mean + variance, timestamp, series,
                       series_length, period_days, curve, curve_length);
  return 0;
}


x86 assembly (clang, -O0):
<light_curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movss  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movss  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
call   1030 <light_curve_base@plt>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <missing_data@plt>
imul   $0x64,%eax,%eax
cltd
idivl  -0x34(%rbp)
cmp    $0x0,%eax
jle    11bd <light_curve+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    121c <light_curve+0xcc>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <detect_mean@plt>
movss  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
movss  -0x38(%rbp),%xmm0
call   1050 <detect_variance@plt>
movss  %xmm0,-0x3c(%rbp)
movss  -0x38(%rbp),%xmm0
subss  -0x3c(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
addss  -0x3c(%rbp),%xmm1
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movss  -0x20(%rbp),%xmm2
mov    -0x28(%rbp),%rcx
mov    -0x34(%rbp),%r8d
call   1060 <light_curve_resample@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<light_curve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8,%rbp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%r12
movss  %xmm0,0x4(%rsp)
call   1030 <light_curve_base@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <missing_data@plt>
imul   $0x64,%eax,%eax
cltd
idiv   %ebx
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jg     11e0 <light_curve+0x90>
mov    %r13,%rdi
mov    %r15d,%esi
call   1070 <detect_mean@plt>
movss  %xmm0,(%rsp)
mov    %r13,%rdi
mov    %r15d,%esi
call   1050 <detect_variance@plt>
movss  (%rsp),%xmm2
movaps %xmm2,%xmm1
subss  %xmm0,%xmm1
addss  %xmm0,%xmm2
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
movss  0x4(%rsp),%xmm2
mov    %r14,%rcx
mov    %ebx,%r8d
call   1060 <light_curve_resample@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @light_curve(float* %0, float* %1, i32 %2, float %3, float* %4, float* %5, i32 %6) {
%8 = alloca i32
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32
%12 = alloca float
%13 = alloca float*
%14 = alloca float*
%15 = alloca i32
%16 = alloca float
%17 = alloca float
store float* %0, float** %9
store float* %1, float** %10
store i32 %2, i32* %11
store float %3, float* %12
store float* %4, float** %13
store float* %5, float** %14
store i32 %6, i32* %15
%18 = load float*, float** %9
%19 = load float*, float** %10
%20 = load i32, i32* %11
%21 = load float, float* %12
%22 = load float*, float** %13
%23 = load float*, float** %14
%24 = load i32, i32* %15
%25 = call i32 @light_curve_base(float* %18, float* %19, i32 %20, float %21, float* %22, float* %23, i32 %24)
%26 = load float*, float** %14
%27 = load i32, i32* %15
%28 = call i32 @missing_data(float* %26, i32 %27)
%29 = mul nsw i32 %28, 100
%30 = load i32, i32* %15
%31 = sdiv i32 %29, %30
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %7
store i32 -1, i32* %8
br label %55
34: ; preds = %7
%35 = load float*, float** %10
%36 = load i32, i32* %11
%37 = call float @detect_mean(float* %35, i32 %36)
store float %37, float* %16
%38 = load float*, float** %10
%39 = load i32, i32* %11
%40 = load float, float* %16
%41 = call float @detect_variance(float* %38, i32 %39, float %40)
store float %41, float* %17
%42 = load float, float* %16
%43 = load float, float* %17
%44 = fsub float %42, %43
%45 = load float, float* %16
%46 = load float, float* %17
%47 = fadd float %45, %46
%48 = load float*, float** %9
%49 = load float*, float** %10
%50 = load i32, i32* %11
%51 = load float, float* %12
%52 = load float*, float** %13
%53 = load i32, i32* %15
%54 = call i32 @light_curve_resample(float %44, float %47, float* %48, float* %49, i32 %50, float %51, float* %52, i32 %53)
store i32 0, i32* %8
br label %55
55: ; preds = %34, %33
%56 = load i32, i32* %8
ret i32 %56
}

LLVM IR (-O2):
define i32 @light_curve(float* %0, float* %1, i32 %2, float %3, float* %4, float* %5, i32 %6) {
%8 = tail call i32 @light_curve_base(float* %0, float* %1, i32 %2, float %3, float* %4, float* %5, i32 %6)
%9 = tail call i32 @missing_data(float* %5, i32 %6)
%10 = mul nsw i32 %9, 100
%11 = sdiv i32 %10, %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %7
%14 = tail call float @detect_mean(float* %1, i32 %2)
%15 = tail call float @detect_variance(float* %1, i32 %2, float %14)
%16 = fsub float %14, %15
%17 = fadd float %14, %15
%18 = tail call i32 @light_curve_resample(float %16, float %17, float* %0, float* %1, i32 %2, float %3, float* %4, i32 %6)
br label %19
19: ; preds = %7, %13
%20 = phi i32 [ 0, %13 ], [ -1, %7 ]
ret i32 %20
}