#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, unsigned char);
int totty_sin(unsigned char);
void effect_int_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, y, height);
        setvoxel(7 - x, y, height);
        setvoxel(x, 7 - y, height);
        setvoxel(7 - x, 7 - y, height);
      }
    }
    delay_ms(delay);
  }
}


x86 assembly (clang, -O0):
<effect_int_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    127d <effect_int_ripples+0x13d>
xor    %edi,%edi
call   1030 <fill@plt>
movb   $0x0,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x4,%eax
jge    1267 <effect_int_ripples+0x127>
movb   $0x0,-0x22(%rbp)
movzbl -0x22(%rbp),%eax
cmp    $0x4,%eax
jge    1255 <effect_int_ripples+0x115>
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 -0x22(%rbp),%esi
movzbl -0x23(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x22(%rbp),%esi
movzbl -0x23(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%edi
movzbl -0x22(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x23(%rbp),%edx
call   1040 <setvoxel@plt>
movzbl -0x21(%rbp),%eax
mov    $0x7,%edi
sub    %eax,%edi
movzbl -0x22(%rbp),%eax
mov    $0x7,%esi
sub    %eax,%esi
movzbl -0x23(%rbp),%edx
call   1040 <setvoxel@plt>
mov    -0x22(%rbp),%al
add    $0x1,%al
mov    %al,-0x22(%rbp)
jmp    11a6 <effect_int_ripples+0x66>
jmp    125a <effect_int_ripples+0x11a>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1195 <effect_int_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_int_ripples+0x39>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<effect_int_ripples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
imul   $0x3e8,%edi,%eax
cltd
mov    %esi,0x4(%rsp)
idiv   %esi
test   %eax,%eax
jle    1356 <effect_int_ripples+0x216>
mov    %eax,%r15d
shl    $0x2,%r15d
xor    %r13d,%r13d
lea    0xe8f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1030 <fill@plt>
mov    $0x7,%r12d
xor    %ebp,%ebp
nop
movzbl 0x0(%rbp,%r14,1),%eax
add    %r13b,%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,%ebx
mov    %ebp,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %ebp,%edi
mov    $0x7,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x7,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
movzbl 0x4(%rbp,%r14,1),%eax
add    %r13b,%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,%ebx
mov    %ebp,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %ebp,%edi
mov    $0x6,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x6,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
movzbl 0x8(%rbp,%r14,1),%eax
add    %r13b,%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,%ebx
mov    %ebp,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %ebp,%edi
mov    $0x5,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x5,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
movzbl 0xc(%rbp,%r14,1),%eax
add    %r13b,%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,%ebx
mov    %ebp,%edi
mov    $0x3,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x3,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
mov    %r12d,%edi
mov    $0x4,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
add    $0x1,%rbp
add    $0xffffffff,%r12d
cmp    $0x4,%rbp
jne    1190 <effect_int_ripples+0x50>
mov    0x4(%rsp),%edi
call   1050 <delay_ms@plt>
add    $0x4,%r13d
cmp    %r15d,%r13d
jl     1180 <effect_int_ripples+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.effect_int_ripples.sqrt_LUT = [16 x i8] c"1+&#+#\1D\1A&\1D\15\10#\19\10\07"
define void @effect_int_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 = %90, %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 %93
22: ; preds = %17
%23 = call i32 @fill(i32 0)
store i8 0, i8* %6
br label %24
24: ; preds = %84, %22
%25 = load i8, i8* %6
%26 = zext i8 %25 to i32
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %87
28: ; preds = %24
store i8 0, i8* %7
br label %29
29: ; preds = %80, %28
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %83
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* %7
%55 = zext i8 %54 to i32
%56 = load i8, i8* %8
%57 = call i32 @setvoxel(i32 %53, i32 %55, i8 zeroext %56)
%58 = load i8, i8* %6
%59 = zext i8 %58 to i32
%60 = sub nsw i32 7, %59
%61 = load i8, i8* %7
%62 = zext i8 %61 to i32
%63 = load i8, i8* %8
%64 = call i32 @setvoxel(i32 %60, i32 %62, i8 zeroext %63)
%65 = load i8, i8* %6
%66 = zext i8 %65 to i32
%67 = load i8, i8* %7
%68 = zext i8 %67 to i32
%69 = sub nsw i32 7, %68
%70 = load i8, i8* %8
%71 = call i32 @setvoxel(i32 %66, i32 %69, i8 zeroext %70)
%72 = load i8, i8* %6
%73 = zext i8 %72 to i32
%74 = sub nsw i32 7, %73
%75 = load i8, i8* %7
%76 = zext i8 %75 to i32
%77 = sub nsw i32 7, %76
%78 = load i8, i8* %8
%79 = call i32 @setvoxel(i32 %74, i32 %77, i8 zeroext %78)
br label %80
80: ; preds = %33
%81 = load i8, i8* %7
%82 = add i8 %81, 1
store i8 %82, i8* %7
br label %29
83: ; preds = %29
br label %84
84: ; preds = %83
%85 = load i8, i8* %6
%86 = add i8 %85, 1
store i8 %86, i8* %6
br label %24
87: ; preds = %24
%88 = load i32, i32* %4
%89 = call i32 @delay_ms(i32 %88)
br label %90
90: ; preds = %87
%91 = load i32, i32* %10
%92 = add nsw i32 %91, 4
store i32 %92, i32* %10
br label %17
93: ; preds = %17
ret void
}

LLVM IR (-O2):
@__const.effect_int_ripples.sqrt_LUT = [16 x i8] c"1+&#+#\1D\1A&\1D\15\10#\19\10\07"
define void @effect_int_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 %69
7: ; preds = %2, %65
%8 = phi i32 [ %67, %65 ], [ 0, %2 ]
%9 = tail call i32 @fill(i32 0)
%10 = trunc i32 %8 to i8
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %63, %11 ]
%13 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.effect_int_ripples.sqrt_LUT, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = add i8 %14, %10
%16 = tail call i32 @totty_sin(i8 zeroext %15)
%17 = add nsw i32 %16, 196
%18 = sdiv i32 %17, 49
%19 = trunc i32 %18 to i8
%20 = trunc i64 %12 to i32
%21 = tail call i32 @setvoxel(i32 %20, i32 0, i8 zeroext %19)
%22 = trunc i64 %12 to i32
%23 = sub i32 7, %22
%24 = tail call i32 @setvoxel(i32 %23, i32 0, i8 zeroext %19)
%25 = tail call i32 @setvoxel(i32 %20, i32 7, i8 zeroext %19)
%26 = tail call i32 @setvoxel(i32 %23, i32 7, i8 zeroext %19)
%27 = add nuw nsw i64 %12, 4
%28 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.effect_int_ripples.sqrt_LUT, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = add i8 %29, %10
%31 = tail call i32 @totty_sin(i8 zeroext %30)
%32 = add nsw i32 %31, 196
%33 = sdiv i32 %32, 49
%34 = trunc i32 %33 to i8
%35 = tail call i32 @setvoxel(i32 %20, i32 1, i8 zeroext %34)
%36 = tail call i32 @setvoxel(i32 %23, i32 1, i8 zeroext %34)
%37 = tail call i32 @setvoxel(i32 %20, i32 6, i8 zeroext %34)
%38 = tail call i32 @setvoxel(i32 %23, i32 6, i8 zeroext %34)
%39 = add nuw nsw i64 %12, 8
%40 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.effect_int_ripples.sqrt_LUT, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = add i8 %41, %10
%43 = tail call i32 @totty_sin(i8 zeroext %42)
%44 = add nsw i32 %43, 196
%45 = sdiv i32 %44, 49
%46 = trunc i32 %45 to i8
%47 = tail call i32 @setvoxel(i32 %20, i32 2, i8 zeroext %46)
%48 = tail call i32 @setvoxel(i32 %23, i32 2, i8 zeroext %46)
%49 = tail call i32 @setvoxel(i32 %20, i32 5, i8 zeroext %46)
%50 = tail call i32 @setvoxel(i32 %23, i32 5, i8 zeroext %46)
%51 = add nuw nsw i64 %12, 12
%52 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.effect_int_ripples.sqrt_LUT, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = add i8 %53, %10
%55 = tail call i32 @totty_sin(i8 zeroext %54)
%56 = add nsw i32 %55, 196
%57 = sdiv i32 %56, 49
%58 = trunc i32 %57 to i8
%59 = tail call i32 @setvoxel(i32 %20, i32 3, i8 zeroext %58)
%60 = tail call i32 @setvoxel(i32 %23, i32 3, i8 zeroext %58)
%61 = tail call i32 @setvoxel(i32 %20, i32 4, i8 zeroext %58)
%62 = tail call i32 @setvoxel(i32 %23, i32 4, i8 zeroext %58)
%63 = add nuw nsw i64 %12, 1
%64 = icmp eq i64 %63, 4
br i1 %64, label %65, label %11
65: ; preds = %11
%66 = tail call i32 @delay_ms(i32 %1)
%67 = add nuw nsw i32 %8, 4
%68 = icmp slt i32 %67, %5
br i1 %68, label %7, label %69
69: ; preds = %65, %2
ret void
}