#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sagevis_deinit();
int /*<<< orphan*/ sagevis_init(int);
int /*<<< orphan*/ sagevis_loadpreset(char *);
int /*<<< orphan*/ sagevis_update(short *, int *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i;
  int decay;
  int coords[17 * 17 * 2];
  short pcmdata[1024];
  sagevis_init(100);
  sagevis_loadpreset("test.milk");
  fprintf(stderr, "loaded, starting 200 frames test\n");
  for (i = 0; i < 200; i++) {
    sagevis_update(pcmdata, &decay, &coords[0]);
  }
  fprintf(stderr, "done test, doing deinit\n");
  sagevis_deinit();
  fprintf(stderr, "finished test\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x64,%edi
call   1030 <sagevis_init@plt>
lea    0xe86(%rip),%rdi
call   1040 <sagevis_loadpreset@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jge    11cd <main+0x7d>
lea    -0x1120(%rbp),%rdi
lea    -0x920(%rbp),%rdx
lea    -0x18(%rbp),%rsi
call   1070 <sagevis_update@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <main+0x4b>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1050 <sagevis_deinit@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x1120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1120,%rsp
mov    $0x64,%edi
call   1030 <sagevis_init@plt>
lea    0xe90(%rip),%rdi
call   1040 <sagevis_loadpreset@plt>
mov    0x2e64(%rip),%r12
mov    (%r12),%edi
lea    0xe83(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xc8,%ebp
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x810(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <sagevis_update@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x60>
mov    (%r12),%edi
lea    0xe5e(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1050 <sagevis_deinit@plt>
mov    (%r12),%edi
lea    0xe60(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x1120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"test.milk\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"loaded, starting 200 frames test\0A\00"
@.str.2 = [25 x i8] c"done test, doing deinit\0A\00"
@.str.3 = [15 x i8] c"finished test\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [578 x i32]
%9 = alloca [1024 x i16]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @sagevis_init(i32 100)
%11 = call i32 @sagevis_loadpreset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %14
14: ; preds = %21, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 200
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = getelementptr inbounds [1024 x i16], [1024 x i16]* %9, i64 0, i64 0
%19 = getelementptr inbounds [578 x i32], [578 x i32]* %8, i64 0, i64 0
%20 = call i32 @sagevis_update(i16* %18, i32* %7, i32* %19)
br label %21
21: ; preds = %17
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %14
24: ; preds = %14
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @sagevis_deinit()
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"test.milk\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"loaded, starting 200 frames test\0A\00"
@.str.2 = [25 x i8] c"done test, doing deinit\0A\00"
@.str.3 = [15 x i8] c"finished test\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [578 x i32]
%5 = alloca [1024 x i16]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [578 x i32]* %4 to i8*
%8 = bitcast [1024 x i16]* %5 to i8*
%9 = tail call i32 @sagevis_init(i32 100)
%10 = tail call i32 @sagevis_loadpreset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [1024 x i16], [1024 x i16]* %5, i64 0, i64 0
%14 = getelementptr inbounds [578 x i32], [578 x i32]* %4, i64 0, i64 0
br label %15
15: ; preds = %2, %15
%16 = phi i32 [ 0, %2 ], [ %18, %15 ]
%17 = call i32 @sagevis_update(i16* %13, i32* %3, i32* %14)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, 200
br i1 %19, label %20, label %15
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (...) @sagevis_deinit()
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}