#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*/ printf(char *, ...);
int compare(float *h_out, float *h_sorted, int ARRAY_SIZE) {
  int failure = 0;
  for (int i = 0; i < ARRAY_SIZE; i++) {
    if (h_out[i] != h_sorted[i]) {
      printf("Oops! Index %i is %f, should be %f\n", i, h_out[i], h_sorted[i]);
      failure = 1;
    }
  }
  if (failure == 0) {
    printf("Success! Your bitonic sort worked.");
  }
  return failure;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b4 <compare+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
ucomiss (%rax,%rcx,4),%xmm0
jne    1167 <compare+0x57>
jp     1167 <compare+0x57>
jmp    11a1 <compare+0x91>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe6d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    11a6 <compare+0x96>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <compare+0x21>
cmpl   $0x0,-0x18(%rbp)
jne    11cc <compare+0xbc>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    117d <compare+0x6d>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%ebp
xor    %ebx,%ebx
lea    0xed0(%rip),%r12
xor    %r13d,%r13d
jmp    1149 <compare+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1178 <compare+0x68>
movss  (%r15,%rbx,4),%xmm0
movss  (%r14,%rbx,4),%xmm1
ucomiss %xmm1,%xmm0
jne    115c <compare+0x4c>
jnp    1140 <compare+0x30>
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x1,%r13d
jmp    1140 <compare+0x30>
test   %r13d,%r13d
jne    118e <compare+0x7e>
lea    0xea0(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Oops! Index %i is %f, should be %f\0A\00"
@.str.1 = [35 x i8] c"Success! Your bitonic sort worked.\00"
define i32 @compare(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %41, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
%14 = load float*, float** %4
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %14, i64 %16
%18 = load float, float* %17
%19 = load float*, float** %5
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
%23 = load float, float* %22
%24 = fcmp une float %18, %23
br i1 %24, label %25, label %40
25: ; preds = %13
%26 = load i32, i32* %8
%27 = load float*, float** %4
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
%31 = load float, float* %30
%32 = fpext float %31 to double
%33 = load float*, float** %5
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %26, double %32, double %38)
store i32 1, i32* %7
br label %40
40: ; preds = %25, %13
br label %41
41: ; preds = %40
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %9
44: ; preds = %9
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = load i32, i32* %7
ret i32 %50
}

LLVM IR (-O2):
@.str = [36 x i8] c"Oops! Index %i is %f, should be %f\0A\00"
@.str.1 = [35 x i8] c"Success! Your bitonic sort worked.\00"
define i32 @compare(float* nocapture %0, float* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %26
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %22
%8 = icmp eq i32 %23, 0
br i1 %8, label %26, label %28
9: ; preds = %5, %22
%10 = phi i64 [ 0, %5 ], [ %24, %22 ]
%11 = phi i32 [ 0, %5 ], [ %23, %22 ]
%12 = getelementptr inbounds float, float* %0, i64 %10
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %1, i64 %10
%15 = load float, float* %14
%16 = fcmp une float %13, %15
br i1 %16, label %17, label %22
17: ; preds = %9
%18 = fpext float %13 to double
%19 = fpext float %15 to double
%20 = trunc i64 %10 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %20, double %18, double %19)
br label %22
22: ; preds = %9, %17
%23 = phi i32 [ 1, %17 ], [ %11, %9 ]
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %7, label %9
26: ; preds = %3, %7
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %7
%29 = phi i32 [ 0, %26 ], [ %23, %7 ]
ret i32 %29
}