#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*/ EINVAL;
int /*<<< orphan*/ errno;
int merge_cycles(double *, size_t *, size_t,
                 int (*)(void const *, void const *));
int rs_rainflow_merge_cycles(double *buffer, size_t *count, size_t size,
                             int (*compare)(void const *, void const *)) {
  if (buffer == NULL || count == NULL || (size % sizeof(double)) != 0 ||
      compare == NULL) {
    errno = EINVAL;
    return -1;
  }
  return merge_cycles(buffer, count, size, compare);
}


x86 assembly (clang, -O0):
<rs_rainflow_merge_cycles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115b <rs_rainflow_merge_cycles+0x4b>
cmpq   $0x0,-0x18(%rbp)
je     115b <rs_rainflow_merge_cycles+0x4b>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    115b <rs_rainflow_merge_cycles+0x4b>
cmpq   $0x0,-0x28(%rbp)
jne    1179 <rs_rainflow_merge_cycles+0x69>
mov    0x2e76(%rip),%rax
mov    (%rax),%ecx
mov    0x2e75(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <rs_rainflow_merge_cycles+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <merge_cycles@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs_rainflow_merge_cycles>:
test   %rdi,%rdi
je     1129 <rs_rainflow_merge_cycles+0x19>
test   %rsi,%rsi
je     1129 <rs_rainflow_merge_cycles+0x19>
test   $0x7,%dl
jne    1129 <rs_rainflow_merge_cycles+0x19>
test   %rcx,%rcx
je     1129 <rs_rainflow_merge_cycles+0x19>
jmp    1030 <merge_cycles@plt>
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
mov    0x2ea7(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @rs_rainflow_merge_cycles(double* %0, i64* %1, i64 %2, i32 (i8*, i8*)* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32 (i8*, i8*)*
store double* %0, double** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i32 (i8*, i8*)* %3, i32 (i8*, i8*)** %9
%10 = load double*, double** %6
%11 = icmp eq double* %10, null
br i1 %11, label %22, label %12
12: ; preds = %4
%13 = load i64*, i64** %7
%14 = icmp eq i64* %13, null
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = load i64, i64* %8
%17 = urem i64 %16, 8
%18 = icmp ne i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %9
%21 = icmp eq i32 (i8*, i8*)* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19, %15, %12, %4
%23 = load i32, i32* @EINVAL
store i32 %23, i32* @errno
store i32 -1, i32* %5
br label %30
24: ; preds = %19
%25 = load double*, double** %6
%26 = load i64*, i64** %7
%27 = load i64, i64* %8
%28 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %9
%29 = call i32 @merge_cycles(double* %25, i64* %26, i64 %27, i32 (i8*, i8*)* %28)
store i32 %29, i32* %5
br label %30
30: ; preds = %24, %22
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @rs_rainflow_merge_cycles(double* %0, i64* %1, i64 %2, i32 (i8*, i8*)* %3) {
%5 = icmp eq double* %0, null
%6 = icmp eq i64* %1, null
%7 = or i1 %5, %6
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = and i64 %2, 7
%10 = icmp ne i64 %9, 0
%11 = icmp eq i32 (i8*, i8*)* %3, null
%12 = or i1 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %8, %4
%14 = load i32, i32* @EINVAL
store i32 %14, i32* @errno
br label %17
15: ; preds = %8
%16 = tail call i32 @merge_cycles(double* %0, i64* %1, i64 %2, i32 (i8*, i8*)* %3)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ -1, %13 ], [ %16, %15 ]
ret i32 %18
}