#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 rand();
int /*<<< orphan*/ ripples(unsigned char, unsigned char, int /*<<< orphan*/,
                           int);
int /*<<< orphan*/ sendvoxel_z(unsigned char, unsigned char, int, int);
void custom_rain(int drops, int speed) {
  unsigned char loop = drops;
  unsigned char x, y;
  int last_x = 0;
  int last_y = 0;
  while (loop) {
    x = rand() % (4);
    y = rand() % (4);
    if (last_x != x || last_y != y) {
      sendvoxel_z(x, y, 3, speed);
      ripples(x, y, 0, speed * 0.5);
      last_x = x;
      last_y = y;
      loop--;
    }
  }
}


x86 assembly (clang, -O0):
<custom_rain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpb   $0x0,-0x9(%rbp)
je     1202 <custom_rain+0xd2>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xa(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xb(%rbp)
mov    -0x10(%rbp),%eax
movzbl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jne    11a2 <custom_rain+0x72>
mov    -0x14(%rbp),%eax
movzbl -0xb(%rbp),%ecx
cmp    %ecx,%eax
je     11fd <custom_rain+0xcd>
mov    -0xa(%rbp),%sil
mov    -0xb(%rbp),%al
mov    -0x8(%rbp),%ecx
mov    $0x3,%edx
movzbl %sil,%edi
movzbl %al,%esi
call   1040 <sendvoxel_z@plt>
mov    -0xa(%rbp),%sil
mov    -0xb(%rbp),%al
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
xor    %edx,%edx
movzbl %sil,%edi
movzbl %al,%esi
call   1030 <ripples@plt>
movzbl -0xa(%rbp),%eax
mov    %eax,-0x10(%rbp)
movzbl -0xb(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x9(%rbp),%al
add    $0xff,%al
mov    %al,-0x9(%rbp)
jmp    1152 <custom_rain+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<custom_rain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,(%rsp)
mov    %edi,%r12d
test   %r12b,%r12b
je     11e5 <custom_rain+0xb5>
cvtsi2sdl (%rsp),%xmm0
mulsd  0xea9(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x4(%rsp)
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11a8 <custom_rain+0x78>
nopw   0x0(%rax,%rax,1)
movzbl %bl,%ebx
movzbl %al,%r14d
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x3,%edx
mov    (%rsp),%ecx
call   1040 <sendvoxel_z@plt>
mov    %ebx,%edi
mov    %r14d,%esi
xor    %edx,%edx
mov    0x4(%rsp),%ecx
call   1030 <ripples@plt>
add    $0xff,%r12b
mov    %r13d,%r15d
mov    %ebp,%r14d
test   %r12b,%r12b
je     11e5 <custom_rain+0xb5>
xor    %eax,%eax
call   1050 <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   1050 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
movzbl %bl,%ebp
movzbl %al,%r13d
cmp    %ebp,%r14d
jne    1170 <custom_rain+0x40>
cmp    %r13d,%r15d
je     11a3 <custom_rain+0x73>
jmp    1170 <custom_rain+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @custom_rain(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = trunc i32 %10 to i8
store i8 %11, i8* %5
store i32 0, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %49, %2
%13 = load i8, i8* %5
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %50
15: ; preds = %12
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 4
%18 = trunc i32 %17 to i8
store i8 %18, i8* %6
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 4
%21 = trunc i32 %20 to i8
store i8 %21, i8* %7
%22 = load i32, i32* %8
%23 = load i8, i8* %6
%24 = zext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %31, label %26
26: ; preds = %15
%27 = load i32, i32* %9
%28 = load i8, i8* %7
%29 = zext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %49
31: ; preds = %26, %15
%32 = load i8, i8* %6
%33 = load i8, i8* %7
%34 = load i32, i32* %4
%35 = call i32 @sendvoxel_z(i8 zeroext %32, i8 zeroext %33, i32 3, i32 %34)
%36 = load i8, i8* %6
%37 = load i8, i8* %7
%38 = load i32, i32* %4
%39 = sitofp i32 %38 to double
%40 = fmul double %39, 5.000000e-01
%41 = fptosi double %40 to i32
%42 = call i32 @ripples(i8 zeroext %36, i8 zeroext %37, i32 0, i32 %41)
%43 = load i8, i8* %6
%44 = zext i8 %43 to i32
store i32 %44, i32* %8
%45 = load i8, i8* %7
%46 = zext i8 %45 to i32
store i32 %46, i32* %9
%47 = load i8, i8* %5
%48 = add i8 %47, -1
store i8 %48, i8* %5
br label %49
49: ; preds = %31, %26
br label %12
50: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @custom_rain(i32 %0, i32 %1) {
%3 = trunc i32 %0 to i8
%4 = icmp eq i8 %3, 0
br i1 %4, label %33, label %5
5: ; preds = %2
%6 = sitofp i32 %1 to double
%7 = fmul double %6, 5.000000e-01
%8 = fptosi double %7 to i32
br label %9
9: ; preds = %5, %28
%10 = phi i32 [ 0, %5 ], [ %31, %28 ]
%11 = phi i32 [ 0, %5 ], [ %30, %28 ]
%12 = phi i8 [ %3, %5 ], [ %29, %28 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 4
%15 = trunc i32 %14 to i8
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 4
%18 = trunc i32 %17 to i8
%19 = and i32 %14, 255
%20 = icmp eq i32 %11, %19
%21 = and i32 %17, 255
%22 = icmp eq i32 %10, %21
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %28, label %24
24: ; preds = %9
%25 = tail call i32 @sendvoxel_z(i8 zeroext %15, i8 zeroext %18, i32 3, i32 %1)
%26 = tail call i32 @ripples(i8 zeroext %15, i8 zeroext %18, i32 0, i32 %8)
%27 = add i8 %12, -1
br label %28
28: ; preds = %9, %24
%29 = phi i8 [ %27, %24 ], [ %12, %9 ]
%30 = phi i32 [ %19, %24 ], [ %11, %9 ]
%31 = phi i32 [ %21, %24 ], [ %10, %9 ]
%32 = icmp eq i8 %29, 0
br i1 %32, label %33, label %9
33: ; preds = %28, %2
ret void
}