#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*/ move(int, int);
int /*<<< orphan*/ printw(char *);
int rand();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ usleep(int);
void sink_lorcha(int x, int y) {
  int delay = rand() % 20;
  move(y, x);
  printw("        ");
  move((y + 1), x);
  printw("-|-_|_  ");
  move((y + 2), x);
  printw("-|-_|_  ");
  move((y + 3), x);
  printw("_|__|__/");
  refresh();
  usleep(500000);
  if (delay == 0) {
    usleep(500000);
  }
  move((y + 1), x);
  printw("        ");
  move((y + 2), x);
  printw("-|-_|_  ");
  move((y + 3), x);
  printw("-|-_|_  ");
  refresh();
  usleep(500000);
  if (delay == 0) {
    usleep(500000);
  }
  move((y + 2), x);
  printw("        ");
  move((y + 3), x);
  printw("-|-_|_  ");
  refresh();
  usleep(500000);
  if (delay == 0) {
    usleep(500000);
  }
  move((y + 3), x);
  printw("        ");
  refresh();
  usleep(500000);
  if (delay == 0) {
    usleep(500000);
  }
}


x86 assembly (clang, -O0):
<sink_lorcha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xe7e(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xe6d(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xe53(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x3,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xe42(%rip),%rdi
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11fa <sink_lorcha+0xaa>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xdf1(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xde0(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x3,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xdc6(%rip),%rdi
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
cmpl   $0x0,-0xc(%rbp)
jne    126d <sink_lorcha+0x11d>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xd7e(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
add    $0x3,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xd6d(%rip),%rdi
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
cmpl   $0x0,-0xc(%rbp)
jne    12c6 <sink_lorcha+0x176>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%edi
add    $0x3,%edi
mov    -0x4(%rbp),%esi
call   1070 <move@plt>
lea    0xd25(%rip),%rdi
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1305 <sink_lorcha+0x1b5>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sink_lorcha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%r13
imul   $0x66666667,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x4(%rsp)
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xe67(%rip),%rdi
call   1030 <printw@plt>
lea    0x1(%r14),%r12d
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xe56(%rip),%rbp
mov    %rbp,%rdi
call   1030 <printw@plt>
lea    0x2(%r14),%r15d
mov    %r15d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
mov    %rbp,%rdi
call   1030 <printw@plt>
add    $0x3,%r14d
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xe2c(%rip),%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
sub    0x4(%rsp),%r13d
je     124d <sink_lorcha+0xfd>
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xdec(%rip),%rdi
call   1030 <printw@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xddf(%rip),%rbp
mov    %rbp,%rdi
call   1030 <printw@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
mov    %rbp,%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
jmp    12a9 <sink_lorcha+0x159>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xd98(%rip),%rdi
call   1030 <printw@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xd8b(%rip),%rbp
mov    %rbp,%rdi
call   1030 <printw@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
mov    %rbp,%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xd3c(%rip),%rdi
call   1030 <printw@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xd2f(%rip),%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
test   %r13d,%r13d
je     1314 <sink_lorcha+0x1c4>
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xcfa(%rip),%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
jmp    1345 <sink_lorcha+0x1f5>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <move@plt>
lea    0xcd1(%rip),%rdi
call   1030 <printw@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    $0x7a120,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <usleep@plt>

LLVM IR (-O0):
@.str = [9 x i8] c" \00"
@.str.1 = [9 x i8] c"-|-_|_ \00"
@.str.2 = [9 x i8] c"_|__|__/\00"
define void @sink_lorcha(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 20
store i32 %7, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = call i32 @move(i32 %8, i32 %9)
%11 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
%14 = load i32, i32* %3
%15 = call i32 @move(i32 %13, i32 %14)
%16 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 2
%19 = load i32, i32* %3
%20 = call i32 @move(i32 %18, i32 %19)
%21 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 3
%24 = load i32, i32* %3
%25 = call i32 @move(i32 %23, i32 %24)
%26 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @refresh()
%28 = call i32 @usleep(i32 500000)
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 @usleep(i32 500000)
br label %33
33: ; preds = %31, %2
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
%36 = load i32, i32* %3
%37 = call i32 @move(i32 %35, i32 %36)
%38 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 2
%41 = load i32, i32* %3
%42 = call i32 @move(i32 %40, i32 %41)
%43 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 3
%46 = load i32, i32* %3
%47 = call i32 @move(i32 %45, i32 %46)
%48 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 (...) @refresh()
%50 = call i32 @usleep(i32 500000)
%51 = load i32, i32* %5
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %33
%54 = call i32 @usleep(i32 500000)
br label %55
55: ; preds = %53, %33
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 2
%58 = load i32, i32* %3
%59 = call i32 @move(i32 %57, i32 %58)
%60 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 3
%63 = load i32, i32* %3
%64 = call i32 @move(i32 %62, i32 %63)
%65 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%66 = call i32 (...) @refresh()
%67 = call i32 @usleep(i32 500000)
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %55
%71 = call i32 @usleep(i32 500000)
br label %72
72: ; preds = %70, %55
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 3
%75 = load i32, i32* %3
%76 = call i32 @move(i32 %74, i32 %75)
%77 = call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%78 = call i32 (...) @refresh()
%79 = call i32 @usleep(i32 500000)
%80 = load i32, i32* %5
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %72
%83 = call i32 @usleep(i32 500000)
br label %84
84: ; preds = %82, %72
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c" \00"
@.str.1 = [9 x i8] c"-|-_|_ \00"
@.str.2 = [9 x i8] c"_|__|__/\00"
define void @sink_lorcha(i32 %0, i32 %1) {
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 20
%5 = tail call i32 @move(i32 %1, i32 %0)
%6 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = add nsw i32 %1, 1
%8 = tail call i32 @move(i32 %7, i32 %0)
%9 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = add nsw i32 %1, 2
%11 = tail call i32 @move(i32 %10, i32 %0)
%12 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%13 = add nsw i32 %1, 3
%14 = tail call i32 @move(i32 %13, i32 %0)
%15 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @refresh()
%17 = tail call i32 @usleep(i32 500000)
%18 = icmp eq i32 %4, 0
br i1 %18, label %19, label %29
19: ; preds = %2
%20 = tail call i32 @usleep(i32 500000)
%21 = tail call i32 @move(i32 %7, i32 %0)
%22 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @move(i32 %10, i32 %0)
%24 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call i32 @move(i32 %13, i32 %0)
%26 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 (...) @refresh()
%28 = tail call i32 @usleep(i32 500000)
br label %37
29: ; preds = %2
%30 = tail call i32 @move(i32 %7, i32 %0)
%31 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @move(i32 %10, i32 %0)
%33 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @move(i32 %13, i32 %0)
%35 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%36 = tail call i32 (...) @refresh()
br label %37
37: ; preds = %29, %19
%38 = tail call i32 @usleep(i32 500000)
%39 = tail call i32 @move(i32 %10, i32 %0)
%40 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%41 = tail call i32 @move(i32 %13, i32 %0)
%42 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%43 = tail call i32 (...) @refresh()
%44 = tail call i32 @usleep(i32 500000)
br i1 %18, label %45, label %51
45: ; preds = %37
%46 = tail call i32 @usleep(i32 500000)
%47 = tail call i32 @move(i32 %13, i32 %0)
%48 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%49 = tail call i32 (...) @refresh()
%50 = tail call i32 @usleep(i32 500000)
br label %55
51: ; preds = %37
%52 = tail call i32 @move(i32 %13, i32 %0)
%53 = tail call i32 @printw(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%54 = tail call i32 (...) @refresh()
br label %55
55: ; preds = %51, %45
%56 = tail call i32 @usleep(i32 500000)
ret void
}