#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 round_down(double, double);
double round_up(double, double);
void rs_rainflow_round_from_to(double *cycle, double scale) {
  double a, b;
  a = cycle[0];
  b = cycle[1];
  if (a < b) {
    a = round_down(a, scale);
    b = round_up(b, scale);
  } else {
    a = round_up(a, scale);
    b = round_down(b, scale);
  }
  cycle[0] = a;
  cycle[1] = b;
}


x86 assembly (clang, -O0):
<rs_rainflow_round_from_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118d <rs_rainflow_round_from_to+0x6d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <round_down@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <round_up@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11b5 <rs_rainflow_round_from_to+0x95>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <round_up@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <round_down@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs_rainflow_round_from_to>:
push   %rbx
sub    $0x20,%rsp
movaps %xmm0,%xmm1
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm2
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm0,%xmm2
movsd  %xmm1,0x8(%rsp)
jbe    1164 <rs_rainflow_round_from_to+0x44>
call   1040 <round_down@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <round_up@plt>
jmp    1180 <rs_rainflow_round_from_to+0x60>
call   1030 <round_up@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <round_down@plt>
movsd  0x18(%rsp),%xmm1
movsd  %xmm1,(%rbx)
movsd  %xmm0,0x8(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @rs_rainflow_round_from_to(double* %0, double %1) {
%3 = alloca double*
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double* %0, double** %3
store double %1, double* %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
store double %9, double* %5
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
store double %12, double* %6
%13 = load double, double* %5
%14 = load double, double* %6
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load double, double* %5
%18 = load double, double* %4
%19 = call double @round_down(double %17, double %18)
store double %19, double* %5
%20 = load double, double* %6
%21 = load double, double* %4
%22 = call double @round_up(double %20, double %21)
store double %22, double* %6
br label %30
23: ; preds = %2
%24 = load double, double* %5
%25 = load double, double* %4
%26 = call double @round_up(double %24, double %25)
store double %26, double* %5
%27 = load double, double* %6
%28 = load double, double* %4
%29 = call double @round_down(double %27, double %28)
store double %29, double* %6
br label %30
30: ; preds = %23, %16
%31 = load double, double* %5
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i64 0
store double %31, double* %33
%34 = load double, double* %6
%35 = load double*, double** %3
%36 = getelementptr inbounds double, double* %35, i64 1
store double %34, double* %36
ret void
}

LLVM IR (-O2):
define void @rs_rainflow_round_from_to(double* nocapture %0, double %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = fcmp olt double %3, %5
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call double @round_down(double %3, double %1)
%9 = tail call double @round_up(double %5, double %1)
br label %13
10: ; preds = %2
%11 = tail call double @round_up(double %3, double %1)
%12 = tail call double @round_down(double %5, double %1)
br label %13
13: ; preds = %10, %7
%14 = phi double [ %8, %7 ], [ %11, %10 ]
%15 = phi double [ %9, %7 ], [ %12, %10 ]
store double %14, double* %0
store double %15, double* %4
ret void
}