#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*/ delay_ms(int);
int /*<<< orphan*/ fill(int);
int rand();
int /*<<< orphan*/ setvoxel(int, int, int);
void random_1(int iterations, int voxels, int delay) {
  int i;
  int v;
  for (i = 0; i < iterations; i++) {
    for (v = 0; v <= voxels; v++)
      setvoxel(rand() % 4, rand() % 4, rand() % 4);
    delay_ms(delay);
    fill(0x00);
  }
}


x86 assembly (clang, -O0):
<random_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e0 <random_1+0xa0>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c3 <random_1+0x83>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x4,%ecx
cltd
idiv   %ecx
call   1040 <setvoxel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <random_1+0x2b>
mov    -0xc(%rbp),%edi
call   1050 <delay_ms@plt>
xor    %edi,%edi
call   1030 <fill@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <random_1+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %edi,%edi
jle    11f6 <random_1+0xb6>
mov    %esi,%r15d
mov    %edi,%r12d
lea    0x1(%r15),%eax
mov    %eax,(%rsp)
xor    %r13d,%r13d
jmp    1189 <random_1+0x49>
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
call   1050 <delay_ms@plt>
xor    %edi,%edi
call   1030 <fill@plt>
add    $0x1,%r13d
cmp    %r12d,%r13d
je     11f6 <random_1+0xb6>
test   %r15d,%r15d
js     1170 <random_1+0x30>
mov    (%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <setvoxel@plt>
add    $0xffffffff,%r14d
jne    11a0 <random_1+0x60>
jmp    1170 <random_1+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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