#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 seconds, int delay) {
  int i, ii;
  int rnd_x;
  int rnd_y;
  int rnd_num;
  int iterations = seconds * 1000 / delay;
  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(delay);
    shift(3, -1);
  }
}


x86 assembly (clang, -O0):
<effect_rain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x3e8,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11fb <effect_rain+0xbb>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d6 <effect_rain+0x96>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x7,%edx
call   1030 <setvoxel@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1188 <effect_rain+0x48>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1040 <shift@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <effect_rain+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_rain>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
imul   $0x3e8,%edi,%eax
cltd
idiv   %esi
test   %eax,%eax
jle    11ef <effect_rain+0xaf>
mov    %esi,%r14d
mov    %eax,%r15d
xor    %r12d,%r12d
jmp    1190 <effect_rain+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%edi
call   1050 <delay_ms@plt>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1040 <shift@plt>
add    $0x1,%r12d
cmp    %r15d,%r12d
je     11ef <effect_rain+0xaf>
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    1170 <effect_rain+0x30>
nopw   0x0(%rax,%rax,1)
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    11b0 <effect_rain+0x70>
jmp    1170 <effect_rain+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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