#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*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ rand_dice();
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int /*<<< orphan*/ yatzy_ui_print_die(int /*<<< orphan*/ *, int, int, int,
                                      int /*<<< orphan*/, int);
void yatzy_ui_animate_dice(WINDOW *win, bool enabled[]) {
  int repeat = 60;
  while (--repeat) {
    for (int i = 0; i < 5; i++) {
      if (enabled[i] == true) {
        yatzy_ui_print_die(win, 3, 2 + i * 9, i + 1, rand_dice(), true);
      }
    }
    wrefresh(win);
    usleep(16666);
  }
}


x86 assembly (clang, -O0):
<yatzy_ui_animate_dice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3c,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11f6 <yatzy_ui_animate_dice+0xb6>
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    11de <yatzy_ui_animate_dice+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11cb <yatzy_ui_animate_dice+0x8b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
imul   $0x9,-0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <rand_dice@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    %eax,%r8d
mov    $0x3,%esi
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
jmp    11d0 <yatzy_ui_animate_dice+0x90>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <yatzy_ui_animate_dice+0x30>
mov    -0x8(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    $0x411a,%edi
call   1060 <usleep@plt>
jmp    1157 <yatzy_ui_animate_dice+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yatzy_ui_animate_dice>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0xffffffc5,%ebp
jmp    117a <yatzy_ui_animate_dice+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <wrefresh@plt>
mov    $0x411a,%edi
call   1060 <usleep@plt>
inc    %ebp
je     1288 <yatzy_ui_animate_dice+0x148>
cmpl   $0x1,(%rbx)
je     11a0 <yatzy_ui_animate_dice+0x60>
cmpl   $0x1,0x4(%rbx)
je     11cd <yatzy_ui_animate_dice+0x8d>
cmpl   $0x1,0x8(%rbx)
je     11fa <yatzy_ui_animate_dice+0xba>
cmpl   $0x1,0xc(%rbx)
je     122b <yatzy_ui_animate_dice+0xeb>
cmpl   $0x1,0x10(%rbx)
jne    1160 <yatzy_ui_animate_dice+0x20>
jmp    125c <yatzy_ui_animate_dice+0x11c>
xor    %eax,%eax
call   1050 <rand_dice@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
mov    %eax,%r8d
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
cmpl   $0x1,0x4(%rbx)
jne    1185 <yatzy_ui_animate_dice+0x45>
xor    %eax,%eax
call   1050 <rand_dice@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0xb,%edx
mov    $0x2,%ecx
mov    %eax,%r8d
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
cmpl   $0x1,0x8(%rbx)
jne    118b <yatzy_ui_animate_dice+0x4b>
xor    %eax,%eax
call   1050 <rand_dice@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x14,%edx
mov    $0x3,%ecx
mov    %eax,%r8d
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
cmpl   $0x1,0xc(%rbx)
jne    1195 <yatzy_ui_animate_dice+0x55>
xor    %eax,%eax
call   1050 <rand_dice@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x1d,%edx
mov    $0x4,%ecx
mov    %eax,%r8d
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
cmpl   $0x1,0x10(%rbx)
jne    1160 <yatzy_ui_animate_dice+0x20>
xor    %eax,%eax
call   1050 <rand_dice@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x26,%edx
mov    $0x5,%ecx
mov    %eax,%r8d
mov    $0x1,%r9d
call   1040 <yatzy_ui_print_die@plt>
jmp    1160 <yatzy_ui_animate_dice+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @yatzy_ui_animate_dice(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 60, i32* %5
br label %7
7: ; preds = %35, %2
%8 = load i32, i32* %5
%9 = add nsw i32 %8, -1
store i32 %9, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %39
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %32, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %31
22: ; preds = %15
%23 = load i32*, i32** %3
%24 = load i32, i32* %6
%25 = mul nsw i32 %24, 9
%26 = add nsw i32 2, %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
%29 = call i32 (...) @rand_dice()
%30 = call i32 @yatzy_ui_print_die(i32* %23, i32 3, i32 %26, i32 %28, i32 %29, i32 1)
br label %31
31: ; preds = %22, %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %12
35: ; preds = %12
%36 = load i32*, i32** %3
%37 = call i32 @wrefresh(i32* %36)
%38 = call i32 @usleep(i32 16666)
br label %7
39: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @yatzy_ui_animate_dice(i32* %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = getelementptr inbounds i32, i32* %1, i64 2
%5 = getelementptr inbounds i32, i32* %1, i64 3
%6 = getelementptr inbounds i32, i32* %1, i64 4
br label %7
7: ; preds = %2, %38
%8 = phi i32 [ 59, %2 ], [ %41, %38 ]
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 (...) @rand_dice()
%13 = tail call i32 @yatzy_ui_print_die(i32* %0, i32 3, i32 2, i32 1, i32 %12, i32 1)
br label %14
14: ; preds = %7, %11
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 (...) @rand_dice()
%19 = tail call i32 @yatzy_ui_print_die(i32* %0, i32 3, i32 11, i32 2, i32 %18, i32 1)
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = tail call i32 (...) @rand_dice()
%25 = tail call i32 @yatzy_ui_print_die(i32* %0, i32 3, i32 20, i32 3, i32 %24, i32 1)
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 (...) @rand_dice()
%31 = tail call i32 @yatzy_ui_print_die(i32* %0, i32 3, i32 29, i32 4, i32 %30, i32 1)
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = tail call i32 (...) @rand_dice()
%37 = tail call i32 @yatzy_ui_print_die(i32* %0, i32 3, i32 38, i32 5, i32 %36, i32 1)
br label %38
38: ; preds = %35, %32
%39 = tail call i32 @wrefresh(i32* %0)
%40 = tail call i32 @usleep(i32 16666)
%41 = add nsw i32 %8, -1
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %7
43: ; preds = %38
ret void
}