#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 /*<<< orphan*/ fill(int);
int getvoxel(int, int, int);
int rand();
void effect_random_filler(int delay, int state) {
  int x, y, z;
  int loop = 0;
  if (state == 1) {
    fill(0);
  } else {
    fill(0xff);
  }
  while (loop < 511) {
    x = rand() % 8;
    y = rand() % 8;
    z = rand() % 8;
    if ((state == 0 && getvoxel(x, y, z) == 1) ||
        (state == 1 && getvoxel(x, y, z) == 0)) {
      altervoxel(x, y, z, state);
      delay_ms(delay);
      loop++;
    }
  }
}


x86 assembly (clang, -O0):
<effect_random_filler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117b <effect_random_filler+0x2b>
xor    %edi,%edi
call   1050 <fill@plt>
jmp    1185 <effect_random_filler+0x35>
mov    $0xff,%edi
call   1050 <fill@plt>
jmp    118a <effect_random_filler+0x3a>
cmpl   $0x1ff,-0x18(%rbp)
jge    1236 <effect_random_filler+0xe6>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ee <effect_random_filler+0x9e>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getvoxel@plt>
cmp    $0x1,%eax
je     120f <effect_random_filler+0xbf>
cmpl   $0x1,-0x8(%rbp)
jne    1231 <effect_random_filler+0xe1>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getvoxel@plt>
cmp    $0x0,%eax
jne    1231 <effect_random_filler+0xe1>
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   1060 <delay_ms@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118a <effect_random_filler+0x3a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_random_filler>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
xor    %eax,%eax
cmp    $0x1,%esi
mov    $0xff,%edi
cmove  %eax,%edi
call   1050 <fill@plt>
xor    %r13d,%r13d
jmp    11a8 <effect_random_filler+0x58>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
call   1040 <altervoxel@plt>
mov    %r14d,%edi
call   1060 <delay_ms@plt>
add    $0x1,%r13d
cmp    $0x1ff,%r13d
jge    1229 <effect_random_filler+0xd9>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r12d
lea    0x7(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffff8,%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
lea    0x7(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff8,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
lea    0x7(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xfffffff8,%eax
sub    %eax,%ebp
test   %r15d,%r15d
jne    120a <effect_random_filler+0xba>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <getvoxel@plt>
cmp    $0x1,%eax
je     1180 <effect_random_filler+0x30>
cmp    $0x1,%r15d
jne    119b <effect_random_filler+0x4b>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <getvoxel@plt>
test   %eax,%eax
jne    119b <effect_random_filler+0x4b>
jmp    1180 <effect_random_filler+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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