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


x86 assembly (clang, -O0):
<effect_rand_patharound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x3e8,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rsi
xor    %edi,%edi
mov    $0x1c,%edx
call   1050 <getpath@plt>
xor    %edi,%edi
call   1030 <fill@plt>
movl   $0x4,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1220 <effect_rand_patharound+0xc0>
mov    $0x0,%al
call   1080 <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    11dc <effect_rand_patharound+0x7c>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ed <effect_rand_patharound+0x8d>
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1c,%esi
call   1060 <pathmove@plt>
mov    -0xc(%rbp),%edx
xor    %edi,%edi
mov    $0x7,%esi
call   1040 <setvoxel@plt>
mov    -0x8(%rbp),%edi
call   1070 <delay_ms@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <effect_rand_patharound+0x41>
add    $0x40,%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
imul   $0x3e8,%edi,%eax
cltd
idiv   %esi
mov    %eax,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x1c,%edx
call   1050 <getpath@plt>
xor    %edi,%edi
call   1030 <fill@plt>
test   %ebp,%ebp
jle    1201 <effect_rand_patharound+0xa1>
mov    $0x4,%ebx
mov    %rsp,%r14
jmp    11c8 <effect_rand_patharound+0x68>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x1c,%esi
call   1060 <pathmove@plt>
xor    %edi,%edi
mov    $0x7,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r15d,%edi
call   1070 <delay_ms@plt>
add    $0xffffffff,%ebp
je     1201 <effect_rand_patharound+0xa1>
xor    %eax,%eax
call   1080 <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     11f9 <effect_rand_patharound+0x99>
mov    $0x7,%ebx
test   %ebx,%ebx
jns    11a0 <effect_rand_patharound+0x40>
xor    %ebx,%ebx
jmp    11a0 <effect_rand_patharound+0x40>
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]
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = mul nsw i32 %10, 1000
%12 = load i32, i32* %4
%13 = sdiv i32 %11, %12
store i32 %13, i32* %9
%14 = getelementptr inbounds [28 x i8], [28 x i8]* %8, i64 0, i64 0
%15 = call i32 @getpath(i32 0, i8* %14, i32 28)
%16 = call i32 @fill(i32 0)
store i32 4, i32* %5
store i32 0, i32* %7
br label %17
17: ; preds = %42, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %45
21: ; preds = %17
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 3
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = add nsw i32 %26, %25
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = icmp sgt i32 %28, 7
br i1 %29, label %30, label %31
30: ; preds = %21
store i32 7, i32* %5
br label %31
31: ; preds = %30, %21
%32 = load i32, i32* %5
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 0, i32* %5
br label %35
35: ; preds = %34, %31
%36 = getelementptr inbounds [28 x i8], [28 x i8]* %8, i64 0, i64 0
%37 = call i32 @pathmove(i8* %36, i32 28)
%38 = load i32, i32* %5
%39 = call i32 @setvoxel(i32 0, i32 7, i32 %38)
%40 = load i32, i32* %4
%41 = call i32 @delay_ms(i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %17
45: ; preds = %17
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 = mul nsw i32 %0, 1000
%6 = sdiv i32 %5, %1
%7 = call i32 @getpath(i32 0, i8* %4, i32 28)
%8 = call i32 @fill(i32 0)
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %26
10: ; preds = %2, %10
%11 = phi i32 [ %20, %10 ], [ 4, %2 ]
%12 = phi i32 [ %24, %10 ], [ 0, %2 ]
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 3
%15 = add nsw i32 %11, -1
%16 = add nsw i32 %15, %14
%17 = icmp slt i32 %16, 7
%18 = select i1 %17, i32 %16, i32 7
%19 = icmp sgt i32 %18, 0
%20 = select i1 %19, i32 %18, i32 0
%21 = call i32 @pathmove(i8* %4, i32 28)
%22 = call i32 @setvoxel(i32 0, i32 7, i32 %20)
%23 = call i32 @delay_ms(i32 %1)
%24 = add nuw nsw i32 %12, 1
%25 = icmp eq i32 %24, %6
br i1 %25, label %26, label %10
26: ; preds = %10, %2
ret void
}