#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 labs(int);
scalar_t__ priceClose(int);
scalar_t__ priceHigh(int);
scalar_t__ priceLow(int);
scalar_t__ priceOpen(int);
int candle_harami_white(int idx) {
  idx = -labs(idx);
  if ((priceOpen(idx) < priceClose(idx)) &&
      priceHigh(idx) < priceOpen(idx - 1) &&
      priceLow(idx) > priceClose(idx - 1))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<candle_harami_white>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <labs@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <priceOpen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <priceClose@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
jge    11ea <candle_harami_white+0x9a>
mov    -0x8(%rbp),%edi
call   1040 <priceHigh@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1070 <priceOpen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jge    11ea <candle_harami_white+0x9a>
mov    -0x8(%rbp),%edi
call   1060 <priceLow@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <priceClose@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jle    11ea <candle_harami_white+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <candle_harami_white+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<candle_harami_white>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
neg    %ebx
cmovs  %edi,%ebx
mov    %ebx,%ebp
neg    %ebp
mov    %ebp,%edi
call   1060 <priceOpen@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1030 <priceClose@plt>
cmp    %rax,%r14
jge    119b <candle_harami_white+0x5b>
mov    %ebp,%edi
call   1040 <priceHigh@plt>
mov    %rax,%r14
not    %ebx
mov    %ebx,%edi
call   1060 <priceOpen@plt>
cmp    %rax,%r14
jge    119b <candle_harami_white+0x5b>
mov    %ebp,%edi
call   1050 <priceLow@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1030 <priceClose@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %rcx,%rbp
jg     119d <candle_harami_white+0x5d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @candle_harami_white(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @labs(i32 %4)
%6 = sub nsw i32 0, %5
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i64 @priceOpen(i32 %7)
%9 = load i32, i32* %3
%10 = call i64 @priceClose(i32 %9)
%11 = icmp slt i64 %8, %10
br i1 %11, label %12, label %27
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i64 @priceHigh(i32 %13)
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = call i64 @priceOpen(i32 %16)
%18 = icmp slt i64 %14, %17
br i1 %18, label %19, label %27
19: ; preds = %12
%20 = load i32, i32* %3
%21 = call i64 @priceLow(i32 %20)
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = call i64 @priceClose(i32 %23)
%25 = icmp sgt i64 %21, %24
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 1, i32* %2
br label %28
27: ; preds = %19, %12, %1
store i32 0, i32* %2
br label %28
28: ; preds = %27, %26
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @candle_harami_white(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%3 = sub nsw i32 0, %2
%4 = tail call i64 @priceOpen(i32 %3)
%5 = tail call i64 @priceClose(i32 %3)
%6 = icmp slt i64 %4, %5
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = tail call i64 @priceHigh(i32 %3)
%9 = xor i32 %2, -1
%10 = tail call i64 @priceOpen(i32 %9)
%11 = icmp slt i64 %8, %10
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = tail call i64 @priceLow(i32 %3)
%14 = tail call i64 @priceClose(i32 %9)
%15 = icmp sgt i64 %13, %14
br i1 %15, label %17, label %16
16: ; preds = %12, %7, %1
br label %17
17: ; preds = %12, %16
%18 = phi i32 [ 0, %16 ], [ 1, %12 ]
ret i32 %18
}