#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*/ effect_pathmove(unsigned char *, int);
int /*<<< orphan*/ font_getpath(int /*<<< orphan*/, unsigned char *, int);
int rand();
int /*<<< orphan*/ setvoxel(int /*<<< orphan*/, int, int);
void effect_rand_patharound(int iterations, int delay) {
  int z, dz, i;
  z = 4;
  unsigned char path[28];
  font_getpath(0, path, 28);
  for (i = 0; i < iterations; i++) {
    dz = ((rand() % 3) - 1);
    z += dz;
    if (z > 7)
      z = 7;
    if (z < 0)
      z = 0;
    effect_pathmove(path, 28);
    setvoxel(0, 7, z);
    delay_ms(delay);
  }
}


x86 assembly (clang, -O0):
<effect_rand_patharound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
lea    -0x30(%rbp),%rsi
xor    %edi,%edi
mov    $0x1c,%edx
call   1030 <font_getpath@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fb <effect_rand_patharound+0xab>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
sub    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jle    11b7 <effect_rand_patharound+0x67>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c8 <effect_rand_patharound+0x78>
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1c,%esi
call   1050 <effect_pathmove@plt>
mov    -0xc(%rbp),%edx
xor    %edi,%edi
mov    $0x7,%esi
call   1040 <setvoxel@plt>
mov    -0x8(%rbp),%edi
call   1060 <delay_ms@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <effect_rand_patharound+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_rand_patharound>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r15d
mov    %edi,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x1c,%edx
call   1030 <font_getpath@plt>
test   %ebp,%ebp
jle    11e1 <effect_rand_patharound+0x91>
mov    $0x4,%ebx
mov    %rsp,%r14
jmp    11a8 <effect_rand_patharound+0x58>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x1c,%esi
call   1050 <effect_pathmove@plt>
xor    %edi,%edi
mov    $0x7,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r15d,%edi
call   1060 <delay_ms@plt>
add    $0xffffffff,%ebp
je     11e1 <effect_rand_patharound+0x91>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
add    %eax,%ebx
add    $0xffffffff,%ebx
cmp    $0x7,%ebx
jl     11d9 <effect_rand_patharound+0x89>
mov    $0x7,%ebx
test   %ebx,%ebx
jns    1180 <effect_rand_patharound+0x30>
xor    %ebx,%ebx
jmp    1180 <effect_rand_patharound+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @effect_rand_patharound(i32 %0, i32 %1) {
%3 = alloca [28 x i8]
%4 = getelementptr inbounds [28 x i8], [28 x i8]* %3, i64 0, i64 0
%5 = call i32 @font_getpath(i32 0, i8* %4, i32 28)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %23
7: ; preds = %2, %7
%8 = phi i32 [ %21, %7 ], [ 0, %2 ]
%9 = phi i32 [ %17, %7 ], [ 4, %2 ]
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 3
%12 = add nsw i32 %9, -1
%13 = add nsw i32 %12, %11
%14 = icmp slt i32 %13, 7
%15 = select i1 %14, i32 %13, i32 7
%16 = icmp sgt i32 %15, 0
%17 = select i1 %16, i32 %15, i32 0
%18 = call i32 @effect_pathmove(i8* %4, i32 28)
%19 = call i32 @setvoxel(i32 0, i32 7, i32 %17)
%20 = call i32 @delay_ms(i32 %1)
%21 = add nuw nsw i32 %8, 1
%22 = icmp eq i32 %21, %0
br i1 %22, label %23, label %7
23: ; preds = %7, %2
ret void
}