#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);
int /*<<< orphan*/ setvoxel(int, int, unsigned char);
int totty_sin(unsigned char);
void int_ripples(int iterations, 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;
  for (i = 0; i < iterations * 4; i += 4) {
    fill(0x00);
    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):
<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)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    126f <int_ripples+0x12f>
xor    %edi,%edi
call   1030 <fill@plt>
movb   $0x0,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x4,%eax
jge    1259 <int_ripples+0x119>
movb   $0x0,-0x22(%rbp)
movzbl -0x22(%rbp),%eax
cmp    $0x4,%eax
jge    1247 <int_ripples+0x107>
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    1198 <int_ripples+0x58>
jmp    124c <int_ripples+0x10c>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1187 <int_ripples+0x47>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0x28(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x28(%rbp)
jmp    116b <int_ripples+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_ripples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    1346 <int_ripples+0x206>
mov    %edi,%r15d
shl    $0x2,%r15d
xor    %r13d,%r13d
lea    0xe98(%rip),%r14
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    1180 <int_ripples+0x40>
mov    0x4(%rsp),%edi
call   1050 <delay_ms@plt>
add    $0x4,%r13d
cmp    %r15d,%r13d
jl     1170 <int_ripples+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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