#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*/ altervoxel(int, int, int, int);
int /*<<< orphan*/ delay_ms(int);
int getvoxel(int, int, int);
int rand();
void random_filler2(int delay, int state) {
  int x, y, z;
  int loop = 0;
  while (loop < 63) {
    x = rand() % 4;
    y = rand() % 4;
    z = rand() % 4;
    if ((state == 0 && getvoxel(x, y, z) == 0x01) ||
        (state == 1 && getvoxel(x, y, z) == 0x00)) {
      altervoxel(x, y, z, state);
      delay_ms(delay);
      loop++;
    }
  }
}


x86 assembly (clang, -O0):
<random_filler2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3f,-0x18(%rbp)
jge    11fe <random_filler2+0xbe>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b6 <random_filler2+0x76>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getvoxel@plt>
cmp    $0x1,%eax
je     11d7 <random_filler2+0x97>
cmpl   $0x1,-0x8(%rbp)
jne    11f9 <random_filler2+0xb9>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getvoxel@plt>
cmp    $0x0,%eax
jne    11f9 <random_filler2+0xb9>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1040 <altervoxel@plt>
mov    -0x4(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <random_filler2+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_filler2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
xor    %r13d,%r13d
jmp    1185 <random_filler2+0x45>
cs nopw 0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
call   1040 <altervoxel@plt>
mov    %r14d,%edi
call   1050 <delay_ms@plt>
add    $0x1,%r13d
cmp    $0x3f,%r13d
jge    1209 <random_filler2+0xc9>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r12d
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
lea    0x3(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebp
cmp    $0x1,%r15d
je     11f0 <random_filler2+0xb0>
test   %r15d,%r15d
jne    117b <random_filler2+0x3b>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <getvoxel@plt>
cmp    $0x1,%eax
je     1160 <random_filler2+0x20>
jmp    117b <random_filler2+0x3b>
nop
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <getvoxel@plt>
test   %eax,%eax
jne    117b <random_filler2+0x3b>
jmp    1160 <random_filler2+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @random_filler2(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
store i32 0, i32* %8
br label %9
9: ; preds = %46, %2
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 63
br i1 %11, label %12, label %47
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 4
store i32 %14, i32* %5
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 4
store i32 %16, i32* %6
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 4
store i32 %18, i32* %7
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %12
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 @getvoxel(i32 %22, i32 %23, i32 %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %36, label %27
27: ; preds = %21, %12
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %46
30: ; preds = %27
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @getvoxel(i32 %31, i32 %32, i32 %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %30, %21
%37 = load i32, i32* %5
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = load i32, i32* %4
%41 = call i32 @altervoxel(i32 %37, i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %3
%43 = call i32 @delay_ms(i32 %42)
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %46
46: ; preds = %36, %30, %27
br label %9
47: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @random_filler2(i32 %0, i32 %1) {
br label %3
3: ; preds = %2, %21
%4 = phi i32 [ 0, %2 ], [ %22, %21 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 4
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 4
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 4
switch i32 %1, label %21 [
i32 0, label %11
i32 1, label %14
]
11: ; preds = %3
%12 = tail call i32 @getvoxel(i32 %6, i32 %8, i32 %10)
%13 = icmp eq i32 %12, 1
br i1 %13, label %17, label %21
14: ; preds = %3
%15 = tail call i32 @getvoxel(i32 %6, i32 %8, i32 %10)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14, %11
%18 = tail call i32 @altervoxel(i32 %6, i32 %8, i32 %10, i32 %1)
%19 = tail call i32 @delay_ms(i32 %0)
%20 = add nsw i32 %4, 1
br label %21
21: ; preds = %11, %3, %17, %14
%22 = phi i32 [ %20, %17 ], [ %4, %14 ], [ %4, %3 ], [ %4, %11 ]
%23 = icmp slt i32 %22, 63
br i1 %23, label %3, label %24
24: ; preds = %21
ret void
}