#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ DrawHorizontalLine(int, int, int, int /*<<< orphan*/);
void DrawArrowTip(int x, int y, int xstep, int ysize, int dir,
                  uint8_t backcolor) {
  int xsize;
  xsize = (((ysize - 1) / 2) * xstep);
  if (dir >= 0) {
    dir = (+1);
    x = (x - xsize + 1);
  } else
    dir = (-1);
  while (xsize > 0 && ysize > 0) {
    DrawHorizontalLine(x, y, xsize, backcolor);
    DrawHorizontalLine(x, (y + ysize - 1), xsize, backcolor);
    if (dir == +1)
      x += xstep;
    xsize -= xstep;
    y++;
    ysize -= 2;
  }
}


x86 assembly (clang, -O0):
<DrawArrowTip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1163 <DrawArrowTip+0x53>
movl   $0x1,-0x14(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116a <DrawArrowTip+0x5a>
movl   $0xffffffff,-0x14(%rbp)
jmp    116f <DrawArrowTip+0x5f>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jle    1188 <DrawArrowTip+0x78>
cmpl   $0x0,-0x10(%rbp)
setg   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1198 <DrawArrowTip+0x88>
jmp    11f5 <DrawArrowTip+0xe5>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <DrawHorizontalLine@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <DrawHorizontalLine@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11d3 <DrawArrowTip+0xc3>
mov    -0xc(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <DrawArrowTip+0x5f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawArrowTip>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
lea    -0x1(%rcx),%eax
shr    $0x1f,%eax
lea    (%rcx,%rax,1),%r15d
add    $0xffffffff,%r15d
sar    %r15d
mov    %r15d,%ebp
mov    %edx,0x4(%rsp)
imul   %edx,%ebp
test   %ebp,%ebp
jle    11cc <DrawArrowTip+0xbc>
test   %ecx,%ecx
jle    11cc <DrawArrowTip+0xbc>
mov    %esi,%r13d
mov    %edi,%ebx
sub    %ebp,%ebx
add    $0x1,%ebx
xor    %edx,%edx
test   %r8d,%r8d
cmovs  %edi,%ebx
mov    0x4(%rsp),%eax
cmovns %eax,%edx
mov    %edx,0x8(%rsp)
add    $0xffffffff,%r15d
imul   %eax,%r15d
lea    (%rcx,%r13,1),%r14d
add    $0xffffffff,%r14d
mov    0xc(%rsp),%r12d
mov    %rcx,0x10(%rsp)
mov    %ebx,%edi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <DrawHorizontalLine@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <DrawHorizontalLine@plt>
mov    0x10(%rsp),%rdx
test   %r15d,%r15d
jle    11cc <DrawArrowTip+0xbc>
add    0x8(%rsp),%ebx
mov    0x4(%rsp),%ecx
sub    %ecx,%ebp
add    $0x1,%r13d
lea    -0x2(%rdx),%eax
sub    %ecx,%r15d
add    $0xffffffff,%r14d
cmp    $0x2,%edx
mov    %eax,%ecx
ja     1180 <DrawArrowTip+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DrawArrowTip(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %10
%15 = sub nsw i32 %14, 1
%16 = sdiv i32 %15, 2
%17 = load i32, i32* %9
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %13
%19 = load i32, i32* %11
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %6
store i32 1, i32* %11
%22 = load i32, i32* %7
%23 = load i32, i32* %13
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %27
26: ; preds = %6
store i32 -1, i32* %11
br label %27
27: ; preds = %26, %21
br label %28
28: ; preds = %56, %27
%29 = load i32, i32* %13
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %10
%33 = icmp sgt i32 %32, 0
br label %34
34: ; preds = %31, %28
%35 = phi i1 [ false, %28 ], [ %33, %31 ]
br i1 %35, label %36, label %64
36: ; preds = %34
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %13
%40 = load i32, i32* %12
%41 = call i32 @DrawHorizontalLine(i32 %37, i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %10
%45 = add nsw i32 %43, %44
%46 = sub nsw i32 %45, 1
%47 = load i32, i32* %13
%48 = load i32, i32* %12
%49 = call i32 @DrawHorizontalLine(i32 %42, i32 %46, i32 %47, i32 %48)
%50 = load i32, i32* %11
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %56
52: ; preds = %36
%53 = load i32, i32* %9
%54 = load i32, i32* %7
%55 = add nsw i32 %54, %53
store i32 %55, i32* %7
br label %56
56: ; preds = %52, %36
%57 = load i32, i32* %9
%58 = load i32, i32* %13
%59 = sub nsw i32 %58, %57
store i32 %59, i32* %13
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
%62 = load i32, i32* %10
%63 = sub nsw i32 %62, 2
store i32 %63, i32* %10
br label %28
64: ; preds = %34
ret void
}

LLVM IR (-O2):
define void @DrawArrowTip(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = add nsw i32 %3, -1
%8 = sdiv i32 %7, 2
%9 = mul nsw i32 %8, %2
%10 = icmp sgt i32 %4, -1
%11 = icmp sgt i32 %9, 0
%12 = icmp sgt i32 %3, 0
%13 = and i1 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %6
%15 = add i32 %0, 1
%16 = sub i32 %15, %9
%17 = select i1 %10, i32 %16, i32 %0
%18 = select i1 %10, i32 %2, i32 0
br label %19
19: ; preds = %14, %19
%20 = phi i32 [ %9, %14 ], [ %29, %19 ]
%21 = phi i32 [ %17, %14 ], [ %28, %19 ]
%22 = phi i32 [ %3, %14 ], [ %31, %19 ]
%23 = phi i32 [ %1, %14 ], [ %30, %19 ]
%24 = tail call i32 @DrawHorizontalLine(i32 %21, i32 %23, i32 %20, i32 %5)
%25 = add i32 %23, -1
%26 = add i32 %25, %22
%27 = tail call i32 @DrawHorizontalLine(i32 %21, i32 %26, i32 %20, i32 %5)
%28 = add nsw i32 %21, %18
%29 = sub nsw i32 %20, %2
%30 = add nsw i32 %23, 1
%31 = add nsw i32 %22, -2
%32 = icmp sgt i32 %29, 0
%33 = icmp ugt i32 %22, 2
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %19, label %35
35: ; preds = %19, %6
ret void
}