#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 rand();
void random_filler(int iterations, int pixels, int delay, int state) {
  int i;
  int p;
  for (i = 0; i < iterations; i++) {
    for (p = 0; p <= pixels; p++)
      altervoxel(rand() % 4, rand() % 4, rand() % 4, state);
    delay_ms(delay);
  }
}


x86 assembly (clang, -O0):
<random_filler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cf <random_filler+0x9f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b9 <random_filler+0x89>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%ecx
call   1030 <altervoxel@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <random_filler+0x2e>
mov    -0xc(%rbp),%edi
call   1040 <delay_ms@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <random_filler+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_filler>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,0x10(%rsp)
test   %edi,%edi
jle    11e6 <random_filler+0xb6>
mov    %ecx,%r13d
mov    %edi,%r12d
mov    0x10(%rsp),%rax
add    $0x1,%eax
mov    %eax,0x8(%rsp)
xor    %r14d,%r14d
jmp    1182 <random_filler+0x52>
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
call   1040 <delay_ms@plt>
add    $0x1,%r14d
cmp    %r12d,%r14d
je     11e6 <random_filler+0xb6>
cmpl   $0x0,0x10(%rsp)
js     1170 <random_filler+0x40>
mov    0x8(%rsp),%r15d
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebp
lea    0x3(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1050 <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   1050 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
mov    %r13d,%ecx
call   1030 <altervoxel@plt>
add    $0xffffffff,%r15d
jne    1190 <random_filler+0x60>
jmp    1170 <random_filler+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @random_filler(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %35, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %38
15: ; preds = %11
store i32 0, i32* %10
br label %16
16: ; preds = %29, %15
%17 = load i32, i32* %10
%18 = load i32, i32* %6
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 4
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 4
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 4
%27 = load i32, i32* %8
%28 = call i32 @altervoxel(i32 %22, i32 %24, i32 %26, i32 %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %16
32: ; preds = %16
%33 = load i32, i32* %7
%34 = call i32 @delay_ms(i32 %33)
br label %35
35: ; preds = %32
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %11
38: ; preds = %11
ret void
}

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