#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 rand();
int /*<<< orphan*/ setvoxel(int, int, int);
int /*<<< orphan*/ shift(int, int);
void effect_rain(int iterations) {
  int i, ii;
  int rnd_x;
  int rnd_y;
  int rnd_num;
  for (ii = 0; ii < iterations; ii++) {
    rnd_num = rand() % 4;
    for (i = 0; i < rnd_num; i++) {
      rnd_x = rand() % 8;
      rnd_y = rand() % 8;
      setvoxel(rnd_x, rnd_y, 7);
    }
    delay_ms(500);
    shift(3, -1);
  }
}


x86 assembly (clang, -O0):
<effect_rain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ec <effect_rain+0xac>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c5 <effect_rain+0x85>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x7,%edx
call   1030 <setvoxel@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <effect_rain+0x37>
mov    $0x1f4,%edi
call   1050 <delay_ms@plt>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1040 <shift@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <effect_rain+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_rain>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    11df <effect_rain+0x9f>
mov    %edi,%r14d
xor    %r15d,%r15d
jmp    1182 <effect_rain+0x42>
nopw   0x0(%rax,%rax,1)
mov    $0x1f4,%edi
call   1050 <delay_ms@plt>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1040 <shift@plt>
add    $0x1,%r15d
cmp    %r14d,%r15d
je     11df <effect_rain+0x9f>
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
test   %ebx,%ebx
jle    1160 <effect_rain+0x20>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
lea    0x7(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xfffffff8,%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
mov    %ebp,%edi
mov    %eax,%esi
mov    $0x7,%edx
call   1030 <setvoxel@plt>
add    $0xffffffff,%ebx
jne    11a0 <effect_rain+0x60>
jmp    1160 <effect_rain+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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