#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*/ setvoxel(int, int, int);
int totty_sin(unsigned char);
void effect_side_ripples(int seconds, int delay) {
  unsigned char sqrt_LUT[] = {49, 43, 38, 35, 43, 35, 29, 26,
                              38, 29, 21, 16, 35, 25, 16, 7};
  unsigned char x, y, height, distance;
  int i;
  int iterations = seconds * 1000 / delay;
  for (i = 0; i < iterations * 4; i += 4) {
    fill(0);
    for (x = 0; x < 4; x++) {
      for (y = 0; y < 4; y++) {
        distance = sqrt_LUT[x + y * 4];
        height = (196 + totty_sin(distance + i)) / 49;
        setvoxel(x, height, y);
        setvoxel(7 - x, height, y);
        setvoxel(x, height, 7 - y);
        setvoxel(7 - x, height, 7 - y);
        setvoxel(x, 7 - height, y);
        setvoxel(7 - x, 7 - height, y);
        setvoxel(x, 7 - height, 7 - y);
        setvoxel(7 - x, 7 - height, 7 - y);
      }
    }
    delay_ms(delay);
  }
}


x86 assembly (clang, -O0):
<effect_side_ripples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
imul   $0x3e8,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    12f9 <effect_side_ripples+0x1b9>
xor    %edi,%edi
call   1030 <fill@plt>
movb   $0x0,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x4,%eax
jge    12e3 <effect_side_ripples+0x1a3>
movb   $0x0,-0x22(%rbp)
movzbl -0x22(%rbp),%eax
cmp    $0x4,%eax
jge    12d1 <effect_side_ripples+0x191>
movzbl -0x21(%rbp),%eax
movzbl -0x22(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
cltq
mov    -0x20(%rbp,%rax,1),%al
mov    %al,-0x24(%rbp)
movzbl -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
movzbl %al,%edi
call   1060 <totty_sin@plt>
add    $0xc4,%eax
mov    $0x31,%ecx
cltd
idiv   %ecx
mov    %al,-0x23(%rbp)
movzbl -0x21(%rbp),%edi
movzbl -0x23(%rbp),%esi
movzbl -0x22(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x23(%rbp),%esi
movzbl -0x22(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%edi
movzbl -0x23(%rbp),%esi
movzbl -0x22(%rbp),%eax
mov    $0x7,%edx
sub    %eax,%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x23(%rbp),%esi
movzbl -0x22(%rbp),%eax
mov    $0x7,%edx
sub    %eax,%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%edi
movzbl -0x23(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x22(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x23(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x22(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%edi
movzbl -0x23(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x22(%rbp),%eax
mov    $0x7,%edx
sub    %eax,%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x23(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x22(%rbp),%eax
mov    $0x7,%edx
sub    %eax,%edx
call   1040 <setvoxel@plt>
mov    -0x22(%rbp),%al
add    $0x1,%al
mov    %al,-0x22(%rbp)
jmp    11a6 <effect_side_ripples+0x66>
jmp    12d6 <effect_side_ripples+0x196>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1195 <effect_side_ripples+0x55>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0x28(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x28(%rbp)
jmp    1179 <effect_side_ripples+0x39>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_side_ripples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
imul   $0x3e8,%edi,%eax
cltd
mov    %esi,0x10(%rsp)
idiv   %esi
mov    %eax,0x4(%rsp)
test   %eax,%eax
jle    12b0 <effect_side_ripples+0x170>
shll   $0x2,0x4(%rsp)
xor    %r14d,%r14d
nop
xor    %edi,%edi
call   1030 <fill@plt>
lea    0xe82(%rip),%rax
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
mov    %r14,0x20(%rsp)
nopw   0x0(%rax,%rax,1)
mov    $0x7,%ebp
mov    $0x7,%ecx
sub    0x8(%rsp),%ecx
mov    %ecx,0x14(%rsp)
xor    %ebx,%ebx
mov    %rax,0x18(%rsp)
nopl   0x0(%rax)
mov    0x18(%rsp),%rax
movzbl (%rax,%rbx,4),%eax
add    %r14b,%al
movzbl %al,%edi
call   1060 <totty_sin@plt>
add    $0xc4,%eax
cltq
imul   $0x5397829d,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x24,%rax
add    %ecx,%eax
movzbl %al,%r14d
mov    0x8(%rsp),%r13
mov    %r13d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    0x14(%rsp),%r12d
mov    %r12d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r13d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <setvoxel@plt>
mov    $0x7,%r15d
sub    %r14d,%r15d
mov    0x20(%rsp),%r14
mov    %r13d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r13d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1040 <setvoxel@plt>
mov    0x18(%rsp),%rax
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    $0x4,%rbx
jne    11b0 <effect_side_ripples+0x70>
mov    0x8(%rsp),%rdx
add    $0x1,%rdx
add    $0x1,%rax
mov    %rdx,%rcx
mov    %rdx,0x8(%rsp)
cmp    $0x4,%rdx
jne    1190 <effect_side_ripples+0x50>
mov    0x10(%rsp),%edi
call   1050 <delay_ms@plt>
add    $0x4,%r14d
cmp    0x4(%rsp),%r14d
jl     1170 <effect_side_ripples+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.effect_side_ripples.sqrt_LUT = [16 x i8] c"1+&#+#\1D\1A&\1D\15\10#\19\10\07"
define void @effect_side_ripples(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = bitcast [16 x i8]* %5 to i8*
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 1000
%15 = load i32, i32* %4
%16 = sdiv i32 %14, %15
store i32 %16, i32* %11
store i32 0, i32* %10
br label %17
17: ; preds = %130, %2
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = mul nsw i32 %19, 4
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %133
22: ; preds = %17
%23 = call i32 @fill(i32 0)
store i8 0, i8* %6
br label %24
24: ; preds = %124, %22
%25 = load i8, i8* %6
%26 = zext i8 %25 to i32
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %127
28: ; preds = %24
store i8 0, i8* %7
br label %29
29: ; preds = %120, %28
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %123
33: ; preds = %29
%34 = load i8, i8* %6
%35 = zext i8 %34 to i32
%36 = load i8, i8* %7
%37 = zext i8 %36 to i32
%38 = mul nsw i32 %37, 4
%39 = add nsw i32 %35, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
store i8 %42, i8* %9
%43 = load i8, i8* %9
%44 = zext i8 %43 to i32
%45 = load i32, i32* %10
%46 = add nsw i32 %44, %45
%47 = trunc i32 %46 to i8
%48 = call i32 @totty_sin(i8 zeroext %47)
%49 = add nsw i32 196, %48
%50 = sdiv i32 %49, 49
%51 = trunc i32 %50 to i8
store i8 %51, i8* %8
%52 = load i8, i8* %6
%53 = zext i8 %52 to i32
%54 = load i8, i8* %8
%55 = zext i8 %54 to i32
%56 = load i8, i8* %7
%57 = zext i8 %56 to i32
%58 = call i32 @setvoxel(i32 %53, i32 %55, i32 %57)
%59 = load i8, i8* %6
%60 = zext i8 %59 to i32
%61 = sub nsw i32 7, %60
%62 = load i8, i8* %8
%63 = zext i8 %62 to i32
%64 = load i8, i8* %7
%65 = zext i8 %64 to i32
%66 = call i32 @setvoxel(i32 %61, i32 %63, i32 %65)
%67 = load i8, i8* %6
%68 = zext i8 %67 to i32
%69 = load i8, i8* %8
%70 = zext i8 %69 to i32
%71 = load i8, i8* %7
%72 = zext i8 %71 to i32
%73 = sub nsw i32 7, %72
%74 = call i32 @setvoxel(i32 %68, i32 %70, i32 %73)
%75 = load i8, i8* %6
%76 = zext i8 %75 to i32
%77 = sub nsw i32 7, %76
%78 = load i8, i8* %8
%79 = zext i8 %78 to i32
%80 = load i8, i8* %7
%81 = zext i8 %80 to i32
%82 = sub nsw i32 7, %81
%83 = call i32 @setvoxel(i32 %77, i32 %79, i32 %82)
%84 = load i8, i8* %6
%85 = zext i8 %84 to i32
%86 = load i8, i8* %8
%87 = zext i8 %86 to i32
%88 = sub nsw i32 7, %87
%89 = load i8, i8* %7
%90 = zext i8 %89 to i32
%91 = call i32 @setvoxel(i32 %85, i32 %88, i32 %90)
%92 = load i8, i8* %6
%93 = zext i8 %92 to i32
%94 = sub nsw i32 7, %93
%95 = load i8, i8* %8
%96 = zext i8 %95 to i32
%97 = sub nsw i32 7, %96
%98 = load i8, i8* %7
%99 = zext i8 %98 to i32
%100 = call i32 @setvoxel(i32 %94, i32 %97, i32 %99)
%101 = load i8, i8* %6
%102 = zext i8 %101 to i32
%103 = load i8, i8* %8
%104 = zext i8 %103 to i32
%105 = sub nsw i32 7, %104
%106 = load i8, i8* %7
%107 = zext i8 %106 to i32
%108 = sub nsw i32 7, %107
%109 = call i32 @setvoxel(i32 %102, i32 %105, i32 %108)
%110 = load i8, i8* %6
%111 = zext i8 %110 to i32
%112 = sub nsw i32 7, %111
%113 = load i8, i8* %8
%114 = zext i8 %113 to i32
%115 = sub nsw i32 7, %114
%116 = load i8, i8* %7
%117 = zext i8 %116 to i32
%118 = sub nsw i32 7, %117
%119 = call i32 @setvoxel(i32 %112, i32 %115, i32 %118)
br label %120
120: ; preds = %33
%121 = load i8, i8* %7
%122 = add i8 %121, 1
store i8 %122, i8* %7
br label %29
123: ; preds = %29
br label %124
124: ; preds = %123
%125 = load i8, i8* %6
%126 = add i8 %125, 1
store i8 %126, i8* %6
br label %24
127: ; preds = %24
%128 = load i32, i32* %4
%129 = call i32 @delay_ms(i32 %128)
br label %130
130: ; preds = %127
%131 = load i32, i32* %10
%132 = add nsw i32 %131, 4
store i32 %132, i32* %10
br label %17
133: ; preds = %17
ret void
}

LLVM IR (-O2):
@__const.effect_side_ripples.sqrt_LUT = [16 x i8] c"1+&#+#\1D\1A&\1D\15\10#\19\10\07"
define void @effect_side_ripples(i32 %0, i32 %1) {
%3 = mul nsw i32 %0, 1000
%4 = sdiv i32 %3, %1
%5 = shl nsw i32 %4, 2
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %48
7: ; preds = %2, %44
%8 = phi i32 [ %46, %44 ], [ 0, %2 ]
%9 = tail call i32 @fill(i32 0)
%10 = trunc i32 %8 to i8
br label %11
11: ; preds = %7, %41
%12 = phi i64 [ 0, %7 ], [ %42, %41 ]
%13 = trunc i64 %12 to i32
%14 = trunc i64 %12 to i32
%15 = sub i32 7, %14
br label %16
16: ; preds = %11, %16
%17 = phi i64 [ 0, %11 ], [ %39, %16 ]
%18 = shl nuw nsw i64 %17, 2
%19 = add nuw nsw i64 %18, %12
%20 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.effect_side_ripples.sqrt_LUT, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = add i8 %21, %10
%23 = tail call i32 @totty_sin(i8 zeroext %22)
%24 = add nsw i32 %23, 196
%25 = sdiv i32 %24, 49
%26 = and i32 %25, 255
%27 = trunc i64 %17 to i32
%28 = tail call i32 @setvoxel(i32 %13, i32 %26, i32 %27)
%29 = tail call i32 @setvoxel(i32 %15, i32 %26, i32 %27)
%30 = trunc i64 %17 to i32
%31 = sub i32 7, %30
%32 = tail call i32 @setvoxel(i32 %13, i32 %26, i32 %31)
%33 = tail call i32 @setvoxel(i32 %15, i32 %26, i32 %31)
%34 = sub nsw i32 7, %26
%35 = tail call i32 @setvoxel(i32 %13, i32 %34, i32 %27)
%36 = tail call i32 @setvoxel(i32 %15, i32 %34, i32 %27)
%37 = tail call i32 @setvoxel(i32 %13, i32 %34, i32 %31)
%38 = tail call i32 @setvoxel(i32 %15, i32 %34, i32 %31)
%39 = add nuw nsw i64 %17, 1
%40 = icmp eq i64 %39, 4
br i1 %40, label %41, label %16
41: ; preds = %16
%42 = add nuw nsw i64 %12, 1
%43 = icmp eq i64 %42, 4
br i1 %43, label %44, label %11
44: ; preds = %41
%45 = tail call i32 @delay_ms(i32 %1)
%46 = add nuw nsw i32 %8, 4
%47 = icmp slt i32 %46, %5
br i1 %47, label %7, label %48
48: ; preds = %44, %2
ret void
}