#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*/ mergeSB(int *, int, int, int);
void bitonicSortSB(int *dataSB, int startIndexSB, int sizeSB, int dirSB) {
  if (sizeSB == 1) {
    return;
  } else {
    bitonicSortSB(dataSB, startIndexSB, sizeSB / 2, dirSB);
    if (dirSB == 1) {
      bitonicSortSB(dataSB, startIndexSB + (sizeSB / 2), sizeSB / 2, 0);
    } else {
      bitonicSortSB(dataSB, startIndexSB + (sizeSB / 2), sizeSB / 2, 1);
    }
    mergeSB(dataSB, startIndexSB, sizeSB, dirSB);
  }
  return;
}


x86 assembly (clang, -O0):
<bitonicSortSB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1144 <bitonicSortSB+0x24>
jmp    11d9 <bitonicSortSB+0xb9>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
call   1030 <bitonicSortSB@plt>
cmpl   $0x1,-0x14(%rbp)
jne    1197 <bitonicSortSB+0x77>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
xor    %ecx,%ecx
call   1030 <bitonicSortSB@plt>
jmp    11c2 <bitonicSortSB+0xa2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    $0x1,%ecx
call   1030 <bitonicSortSB@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <mergeSB@plt>
jmp    11d9 <bitonicSortSB+0xb9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitonicSortSB>:
cmp    $0x1,%edx
jne    1126 <bitonicSortSB+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r12
mov    %edx,%ebx
shr    $0x1f,%ebx
add    %edx,%ebx
sar    %ebx
mov    %ebx,%edx
call   1030 <bitonicSortSB@plt>
xor    %ecx,%ecx
cmp    $0x1,%r14d
setne  %cl
lea    (%rbx,%r15,1),%esi
mov    %r12,%rdi
mov    %ebx,%edx
call   1030 <bitonicSortSB@plt>
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mergeSB@plt>

LLVM IR (-O0):
define void @bitonicSortSB(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %4
br label %43
12: ; preds = %4
%13 = load i32*, i32** %5
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = sdiv i32 %15, 2
%17 = load i32, i32* %8
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = sdiv i32 %23, 2
%25 = add nsw i32 %22, %24
%26 = load i32, i32* %7
%27 = sdiv i32 %26, 2
br label %36
28: ; preds = %12
%29 = load i32*, i32** %5
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = sdiv i32 %31, 2
%33 = add nsw i32 %30, %32
%34 = load i32, i32* %7
%35 = sdiv i32 %34, 2
br label %36
36: ; preds = %28, %20
%37 = load i32*, i32** %5
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = call i32 @mergeSB(i32* %37, i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %36
br label %43
43: ; preds = %42, %11
ret void
}

LLVM IR (-O2):
define void @bitonicSortSB(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 1
br i1 %5, label %12, label %6
6: ; preds = %4
%7 = sdiv i32 %2, 2
tail call void @bitonicSortSB(i32* %0, i32 %1, i32 %7, i32 %3)
%8 = icmp ne i32 %3, 1
%9 = add nsw i32 %7, %1
%10 = zext i1 %8 to i32
tail call void @bitonicSortSB(i32* %0, i32 %9, i32 %7, i32 %10)
%11 = tail call i32 @mergeSB(i32* %0, i32 %1, i32 %2, i32 %3)
br label %12
12: ; preds = %4, %6
ret void
}