#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*/ box_apeak_xy(int, int, int /*<<< orphan*/, int, int, int,
                                int, int);
int /*<<< orphan*/ delay_ms(int);
void roll_3_xy(int n, int delay) {
  int i;
  switch (n) {
  case 1:
    for (i = 0; i < 8; i++) {
      box_apeak_xy(0, i, 0, 7, 7 - i, 7, 1, 1);
      delay_ms(delay);
      if (i < 7)
        box_apeak_xy(3, 3, 0, 0, i, 7, 1, 0);
    };
    break;
  case 2:
    for (i = 0; i < 8; i++) {
      box_apeak_xy(7 - i, 0, 0, i, 7, 7, 1, 1);
      delay_ms(delay);
      if (i < 7)
        box_apeak_xy(3, 4, 0, i, 7, 7, 1, 0);
    };
    break;
  case 3:
    for (i = 0; i < 8; i++) {
      box_apeak_xy(0, i, 0, 7, 7 - i, 7, 1, 1);
      delay_ms(delay);
      if (i < 7)
        box_apeak_xy(4, 4, 0, 7, 7 - i, 7, 1, 0);
    };
    break;
  case 0:
    for (i = 0; i < 8; i++) {
      box_apeak_xy(7 - i, 0, 0, i, 7, 7, 1, 1);
      delay_ms(delay);
      if (i < 7)
        box_apeak_xy(4, 3, 0, 7 - i, 0, 7, 1, 0);
    };
  }
}


x86 assembly (clang, -O0):
<roll_3_xy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     13aa <roll_3_xy+0x28a>
mov    -0x18(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11e0 <roll_3_xy+0xc0>
mov    -0xc(%rbp),%esi
mov    $0x7,%r8d
sub    -0xc(%rbp),%r8d
xor    %edx,%edx
mov    $0x7,%r9d
mov    %edx,%edi
mov    %r9d,%ecx
movl   $0x1,(%rsp)
movl   $0x1,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
mov    -0x8(%rbp),%edi
call   1040 <delay_ms@plt>
cmpl   $0x7,-0xc(%rbp)
jge    11cd <roll_3_xy+0xad>
mov    -0xc(%rbp),%r8d
mov    $0x3,%esi
xor    %ecx,%ecx
mov    $0x7,%r9d
mov    %esi,%edi
mov    %ecx,%edx
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
jmp    11d2 <roll_3_xy+0xb2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <roll_3_xy+0x3a>
jmp    13aa <roll_3_xy+0x28a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1273 <roll_3_xy+0x153>
mov    $0x7,%edi
sub    -0xc(%rbp),%edi
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
mov    $0x7,%r9d
mov    %edx,%esi
mov    %r9d,%r8d
movl   $0x1,(%rsp)
movl   $0x1,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
mov    -0x8(%rbp),%edi
call   1040 <delay_ms@plt>
cmpl   $0x7,-0xc(%rbp)
jge    1260 <roll_3_xy+0x140>
mov    -0xc(%rbp),%ecx
mov    $0x3,%edi
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x7,%r9d
mov    %r9d,%r8d
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
jmp    1265 <roll_3_xy+0x145>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ec <roll_3_xy+0xcc>
jmp    13aa <roll_3_xy+0x28a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    130c <roll_3_xy+0x1ec>
mov    -0xc(%rbp),%esi
mov    $0x7,%r8d
sub    -0xc(%rbp),%r8d
xor    %edx,%edx
mov    $0x7,%r9d
mov    %edx,%edi
mov    %r9d,%ecx
movl   $0x1,(%rsp)
movl   $0x1,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
mov    -0x8(%rbp),%edi
call   1040 <delay_ms@plt>
cmpl   $0x7,-0xc(%rbp)
jge    12f9 <roll_3_xy+0x1d9>
mov    $0x7,%r8d
sub    -0xc(%rbp),%r8d
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x7,%r9d
mov    %esi,%edi
mov    %r9d,%ecx
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
jmp    12fe <roll_3_xy+0x1de>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    127f <roll_3_xy+0x15f>
jmp    13aa <roll_3_xy+0x28a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    13a5 <roll_3_xy+0x285>
mov    $0x7,%edi
sub    -0xc(%rbp),%edi
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
mov    $0x7,%r9d
mov    %edx,%esi
mov    %r9d,%r8d
movl   $0x1,(%rsp)
movl   $0x1,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
mov    -0x8(%rbp),%edi
call   1040 <delay_ms@plt>
cmpl   $0x7,-0xc(%rbp)
jge    1392 <roll_3_xy+0x272>
mov    $0x7,%ecx
sub    -0xc(%rbp),%ecx
mov    $0x4,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
mov    $0x7,%r9d
mov    %r8d,%edx
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <box_apeak_xy@plt>
jmp    1397 <roll_3_xy+0x277>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1318 <roll_3_xy+0x1f8>
jmp    13aa <roll_3_xy+0x28a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roll_3_xy>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
ja     1399 <roll_3_xy+0x279>
mov    %esi,%r14d
mov    %edi,%eax
lea    0xec7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x7,%ebx
mov    $0x7,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edi
mov    $0x3,%esi
xor    %edx,%edx
mov    %ebx,%ecx
xor    %r8d,%r8d
mov    $0x7,%r9d
push   $0x0
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
lea    -0x1(%rbx),%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1180 <roll_3_xy+0x60>
jmp    1399 <roll_3_xy+0x279>
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x7,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
mov    $0x6,%ebp
xchg   %ax,%ax
mov    $0x3,%edi
mov    $0x3,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
mov    $0x7,%r9d
push   $0x0
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
add    $0x1,%ebx
xor    %edi,%edi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0x7,%ecx
mov    %ebp,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
add    $0xffffffff,%ebp
jb     1210 <roll_3_xy+0xf0>
jmp    1399 <roll_3_xy+0x279>
xor    %ebx,%ebx
mov    $0x7,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
mov    $0x6,%ebp
nopl   (%rax)
mov    $0x3,%edi
mov    $0x4,%esi
xor    %edx,%edx
mov    %ebx,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x0
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
add    $0x1,%ebx
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %ebx,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
add    $0xffffffff,%ebp
jb     12a0 <roll_3_xy+0x180>
jmp    1399 <roll_3_xy+0x279>
mov    $0x7,%ebx
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x7,%ecx
mov    $0x7,%r8d
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x4,%edi
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x7,%ecx
mov    %ebx,%r8d
mov    $0x7,%r9d
push   $0x0
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
lea    -0x1(%rbx),%r8d
xor    %edi,%edi
mov    %ebp,%esi
xor    %edx,%edx
mov    $0x7,%ecx
mov    $0x7,%r9d
push   $0x1
push   $0x1
call   1030 <box_apeak_xy@plt>
add    $0x10,%rsp
mov    %r14d,%edi
call   1040 <delay_ms@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1340 <roll_3_xy+0x220>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @roll_3_xy(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
switch i32 %6, label %93 [
i32 1, label %7
i32 2, label %28
i32 3, label %49
i32 0, label %71
]
7: ; preds = %2
store i32 0, i32* %5
br label %8
8: ; preds = %24, %7
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %5
%13 = load i32, i32* %5
%14 = sub nsw i32 7, %13
%15 = call i32 @box_apeak_xy(i32 0, i32 %12, i32 0, i32 7, i32 %14, i32 7, i32 1, i32 1)
%16 = load i32, i32* %4
%17 = call i32 @delay_ms(i32 %16)
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 7
br i1 %19, label %20, label %23
20: ; preds = %11
%21 = load i32, i32* %5
%22 = call i32 @box_apeak_xy(i32 3, i32 3, i32 0, i32 0, i32 %21, i32 7, i32 1, i32 0)
br label %23
23: ; preds = %20, %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %8
27: ; preds = %8
br label %93
28: ; preds = %2
store i32 0, i32* %5
br label %29
29: ; preds = %45, %28
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 8
br i1 %31, label %32, label %48
32: ; preds = %29
%33 = load i32, i32* %5
%34 = sub nsw i32 7, %33
%35 = load i32, i32* %5
%36 = call i32 @box_apeak_xy(i32 %34, i32 0, i32 0, i32 %35, i32 7, i32 7, i32 1, i32 1)
%37 = load i32, i32* %4
%38 = call i32 @delay_ms(i32 %37)
%39 = load i32, i32* %5
%40 = icmp slt i32 %39, 7
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i32, i32* %5
%43 = call i32 @box_apeak_xy(i32 3, i32 4, i32 0, i32 %42, i32 7, i32 7, i32 1, i32 0)
br label %44
44: ; preds = %41, %32
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %29
48: ; preds = %29
br label %93
49: ; preds = %2
store i32 0, i32* %5
br label %50
50: ; preds = %67, %49
%51 = load i32, i32* %5
%52 = icmp slt i32 %51, 8
br i1 %52, label %53, label %70
53: ; preds = %50
%54 = load i32, i32* %5
%55 = load i32, i32* %5
%56 = sub nsw i32 7, %55
%57 = call i32 @box_apeak_xy(i32 0, i32 %54, i32 0, i32 7, i32 %56, i32 7, i32 1, i32 1)
%58 = load i32, i32* %4
%59 = call i32 @delay_ms(i32 %58)
%60 = load i32, i32* %5
%61 = icmp slt i32 %60, 7
br i1 %61, label %62, label %66
62: ; preds = %53
%63 = load i32, i32* %5
%64 = sub nsw i32 7, %63
%65 = call i32 @box_apeak_xy(i32 4, i32 4, i32 0, i32 7, i32 %64, i32 7, i32 1, i32 0)
br label %66
66: ; preds = %62, %53
br label %67
67: ; preds = %66
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %50
70: ; preds = %50
br label %93
71: ; preds = %2
store i32 0, i32* %5
br label %72
72: ; preds = %89, %71
%73 = load i32, i32* %5
%74 = icmp slt i32 %73, 8
br i1 %74, label %75, label %92
75: ; preds = %72
%76 = load i32, i32* %5
%77 = sub nsw i32 7, %76
%78 = load i32, i32* %5
%79 = call i32 @box_apeak_xy(i32 %77, i32 0, i32 0, i32 %78, i32 7, i32 7, i32 1, i32 1)
%80 = load i32, i32* %4
%81 = call i32 @delay_ms(i32 %80)
%82 = load i32, i32* %5
%83 = icmp slt i32 %82, 7
br i1 %83, label %84, label %88
84: ; preds = %75
%85 = load i32, i32* %5
%86 = sub nsw i32 7, %85
%87 = call i32 @box_apeak_xy(i32 4, i32 3, i32 0, i32 %86, i32 0, i32 7, i32 1, i32 0)
br label %88
88: ; preds = %84, %75
br label %89
89: ; preds = %88
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 1
store i32 %91, i32* %5
br label %72
92: ; preds = %72
br label %93
93: ; preds = %92, %2, %70, %48, %27
ret void
}

LLVM IR (-O2):
define void @roll_3_xy(i32 %0, i32 %1) {
switch i32 %0, label %49 [
i32 1, label %12
i32 2, label %9
i32 3, label %6
i32 0, label %3
]
3: ; preds = %2
%4 = tail call i32 @box_apeak_xy(i32 7, i32 0, i32 0, i32 0, i32 7, i32 7, i32 1, i32 1)
%5 = tail call i32 @delay_ms(i32 %1)
br label %40
6: ; preds = %2
%7 = tail call i32 @box_apeak_xy(i32 0, i32 0, i32 0, i32 7, i32 7, i32 7, i32 1, i32 1)
%8 = tail call i32 @delay_ms(i32 %1)
br label %31
9: ; preds = %2
%10 = tail call i32 @box_apeak_xy(i32 7, i32 0, i32 0, i32 0, i32 7, i32 7, i32 1, i32 1)
%11 = tail call i32 @delay_ms(i32 %1)
br label %23
12: ; preds = %2
%13 = tail call i32 @box_apeak_xy(i32 0, i32 0, i32 0, i32 7, i32 7, i32 7, i32 1, i32 1)
%14 = tail call i32 @delay_ms(i32 %1)
br label %15
15: ; preds = %12, %15
%16 = phi i32 [ 0, %12 ], [ %18, %15 ]
%17 = tail call i32 @box_apeak_xy(i32 3, i32 3, i32 0, i32 0, i32 %16, i32 7, i32 1, i32 0)
%18 = add nuw nsw i32 %16, 1
%19 = sub nsw i32 6, %16
%20 = tail call i32 @box_apeak_xy(i32 0, i32 %18, i32 0, i32 7, i32 %19, i32 7, i32 1, i32 1)
%21 = tail call i32 @delay_ms(i32 %1)
%22 = icmp eq i32 %18, 7
br i1 %22, label %49, label %15
23: ; preds = %9, %23
%24 = phi i32 [ 0, %9 ], [ %26, %23 ]
%25 = tail call i32 @box_apeak_xy(i32 3, i32 4, i32 0, i32 %24, i32 7, i32 7, i32 1, i32 0)
%26 = add nuw nsw i32 %24, 1
%27 = sub nsw i32 6, %24
%28 = tail call i32 @box_apeak_xy(i32 %27, i32 0, i32 0, i32 %26, i32 7, i32 7, i32 1, i32 1)
%29 = tail call i32 @delay_ms(i32 %1)
%30 = icmp eq i32 %26, 7
br i1 %30, label %49, label %23
31: ; preds = %6, %31
%32 = phi i32 [ 7, %6 ], [ %36, %31 ]
%33 = phi i32 [ 0, %6 ], [ %35, %31 ]
%34 = tail call i32 @box_apeak_xy(i32 4, i32 4, i32 0, i32 7, i32 %32, i32 7, i32 1, i32 0)
%35 = add nuw nsw i32 %33, 1
%36 = sub nsw i32 6, %33
%37 = tail call i32 @box_apeak_xy(i32 0, i32 %35, i32 0, i32 7, i32 %36, i32 7, i32 1, i32 1)
%38 = tail call i32 @delay_ms(i32 %1)
%39 = icmp eq i32 %35, 7
br i1 %39, label %49, label %31
40: ; preds = %3, %40
%41 = phi i32 [ 7, %3 ], [ %45, %40 ]
%42 = phi i32 [ 0, %3 ], [ %44, %40 ]
%43 = tail call i32 @box_apeak_xy(i32 4, i32 3, i32 0, i32 %41, i32 0, i32 7, i32 1, i32 0)
%44 = add nuw nsw i32 %42, 1
%45 = sub nsw i32 6, %42
%46 = tail call i32 @box_apeak_xy(i32 %45, i32 0, i32 0, i32 %44, i32 7, i32 7, i32 1, i32 1)
%47 = tail call i32 @delay_ms(i32 %1)
%48 = icmp eq i32 %44, 7
br i1 %48, label %49, label %40
49: ; preds = %40, %31, %23, %15, %2
ret void
}