#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*/ COLOR_PAIR(int /*<<< orphan*/);
int abs(int);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ get_pattern(int, int);
scalar_t__ isInRange(int, int, int, int);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ usleep(int);
void draw(int height, int width) {
  int x, y;
  for (x = -height; x <= width; x++) {
    for (y = 0; y <= height; y++) {
      int dx = x + y;
      int dy = y;
      if (abs(x) % 2 == 0) {
        dy = height - y;
        dx = x + dy;
      }
      if (isInRange(dy, dx, height, width)) {
        attron(COLOR_PAIR(get_pattern(dy, dx)));
        mvaddch(dy, dx, '*');
        refresh();
        usleep(5000);
      }
    };
  }
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     126a <draw+0xea>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1257 <draw+0xd7>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ef <draw+0x6f>
mov    -0x4(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1040 <isInRange@plt>
cmp    $0x0,%rax
je     1244 <draw+0xc4>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <get_pattern@plt>
mov    %eax,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1060 <attron@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x2a,%edx
call   1090 <mvaddch@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
mov    $0x1388,%edi
call   10a0 <usleep@plt>
jmp    1249 <draw+0xc9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <draw+0x29>
jmp    125c <draw+0xdc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <draw+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
neg    %r12d
mov    %esi,0x4(%rsp)
cmp    %esi,%r12d
jle    1199 <draw+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r14d
jmp    11af <draw+0x3f>
xchg   %ax,%ax
lea    0x1(%r12),%eax
cmp    0x4(%rsp),%r12d
mov    %eax,%r12d
je     118a <draw+0x1a>
test   %r14d,%r14d
js     11a0 <draw+0x30>
xor    %ebp,%ebp
mov    %r14d,%r15d
jmp    11c9 <draw+0x59>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffff,%r15d
jae    11a0 <draw+0x30>
test   $0x1,%r12b
mov    %ebp,%ebx
cmove  %r15d,%ebx
lea    (%rbx,%r12,1),%r13d
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r14d,%edx
mov    0x4(%rsp),%ecx
call   1030 <isInRange@plt>
test   %rax,%rax
je     11c0 <draw+0x50>
mov    %ebx,%edi
mov    %r13d,%esi
call   1040 <get_pattern@plt>
mov    %eax,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x2a,%edx
call   1080 <mvaddch@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
mov    $0x1388,%edi
call   1090 <usleep@plt>
jmp    11c0 <draw+0x50>

LLVM IR (-O0):
define void @draw(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = sub nsw i32 0, %9
store i32 %10, i32* %5
br label %11
11: ; preds = %59, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %62
15: ; preds = %11
store i32 0, i32* %6
br label %16
16: ; preds = %55, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %58
20: ; preds = %16
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = add nsw i32 %21, %22
store i32 %23, i32* %7
%24 = load i32, i32* %6
store i32 %24, i32* %8
%25 = load i32, i32* %5
%26 = call i32 @abs(i32 %25)
%27 = srem i32 %26, 2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %20
%30 = load i32, i32* %3
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
store i32 %32, i32* %8
%33 = load i32, i32* %5
%34 = load i32, i32* %8
%35 = add nsw i32 %33, %34
store i32 %35, i32* %7
br label %36
36: ; preds = %29, %20
%37 = load i32, i32* %8
%38 = load i32, i32* %7
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = call i64 @isInRange(i32 %37, i32 %38, i32 %39, i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %36
%44 = load i32, i32* %8
%45 = load i32, i32* %7
%46 = call i32 @get_pattern(i32 %44, i32 %45)
%47 = call i32 @COLOR_PAIR(i32 %46)
%48 = call i32 @attron(i32 %47)
%49 = load i32, i32* %8
%50 = load i32, i32* %7
%51 = call i32 @mvaddch(i32 %49, i32 %50, i8 signext 42)
%52 = call i32 (...) @refresh()
%53 = call i32 @usleep(i32 5000)
br label %54
54: ; preds = %43, %36
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %16
58: ; preds = %16
br label %59
59: ; preds = %58
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %11
62: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @draw(i32 %0, i32 %1) {
%3 = sub nsw i32 0, %0
%4 = icmp sgt i32 %3, %1
br i1 %4, label %32, label %5
5: ; preds = %2
%6 = icmp slt i32 %0, 0
br label %7
7: ; preds = %5, %29
%8 = phi i32 [ %3, %5 ], [ %30, %29 ]
br i1 %6, label %29, label %9
9: ; preds = %7
%10 = and i32 %8, 1
%11 = icmp eq i32 %10, 0
br label %12
12: ; preds = %9, %26
%13 = phi i32 [ 0, %9 ], [ %27, %26 ]
%14 = sub nsw i32 %0, %13
%15 = select i1 %11, i32 %14, i32 %13
%16 = add nsw i32 %15, %8
%17 = tail call i64 @isInRange(i32 %15, i32 %16, i32 %0, i32 %1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = tail call i32 @get_pattern(i32 %15, i32 %16)
%21 = tail call i32 @COLOR_PAIR(i32 %20)
%22 = tail call i32 @attron(i32 %21)
%23 = tail call i32 @mvaddch(i32 %15, i32 %16, i8 signext 42)
%24 = tail call i32 (...) @refresh()
%25 = tail call i32 @usleep(i32 5000)
br label %26
26: ; preds = %19, %12
%27 = add nuw i32 %13, 1
%28 = icmp eq i32 %13, %0
br i1 %28, label %29, label %12
29: ; preds = %26, %7
%30 = add i32 %8, 1
%31 = icmp eq i32 %8, %1
br i1 %31, label %32, label %7
32: ; preds = %29, %2
ret void
}