#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*/ fflush(int /*<<< orphan*/);
double *im_getSnapshot(int);
int /*<<< orphan*/ im_start();
int /*<<< orphan*/ im_stop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main() {
  int i = 0;
  long c = 0;
  im_start();
  int iterations, inner_iterations;
  for (iterations = 0; iterations < 100; ++iterations) {
    usleep(1 * 1000000 / 30);
    for (inner_iterations = 0; inner_iterations < 100; ++inner_iterations) {
      double *array = im_getSnapshot(1);
      printf("%08lx: ", c++);
      for (i = 0; i < 256; i += 32)
        printf(" %.2f", array[i]);
      printf("\n");
      fflush(stdout);
    }
    im_stop();
    im_start();
  }
  im_stop();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <im_start@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    125f <main+0xff>
mov    $0x8235,%edi
call   1080 <usleep@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    1243 <main+0xe3>
mov    $0x1,%edi
call   1060 <im_getSnapshot@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    %rsi,%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1219 <main+0xb9>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
jmp    11e3 <main+0x83>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a7 <main+0x47>
mov    $0x0,%al
call   1070 <im_stop@plt>
mov    $0x0,%al
call   1040 <im_start@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <main+0x2c>
mov    $0x0,%al
call   1070 <im_stop@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <im_start@plt>
lea    0xe7f(%rip),%r15
mov    0x2e50(%rip),%r13
xor    %eax,%eax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,0x4(%rsp)
mov    $0x8235,%edi
call   1090 <usleep@plt>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rbp,1),%r12
mov    $0x1,%edi
call   1070 <im_getSnapshot@plt>
mov    %rax,%rbx
lea    0xe28(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  (%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x100(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x200(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x300(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x400(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x500(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x600(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x700(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
add    $0x1,%r14
cmp    $0x64,%r14d
jne    11c0 <main+0x50>
xor    %eax,%eax
call   1080 <im_stop@plt>
xor    %eax,%eax
call   1050 <im_start@plt>
mov    0x4(%rsp),%eax
add    $0x1,%eax
add    %r14,%rbp
cmp    $0x64,%eax
jne    11a0 <main+0x30>
xor    %eax,%eax
call   1080 <im_stop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%08lx: \00"
@.str.1 = [6 x i8] c" %.2f\00"
@.str.2 = [2 x i8] c"\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
store i32 0, i32* %1
store i32 0, i32* %2
store i64 0, i64* %3
%7 = call i32 (...) @im_start()
store i32 0, i32* %4
br label %8
8: ; preds = %44, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %47
11: ; preds = %8
%12 = call i32 @usleep(i32 33333)
store i32 0, i32* %5
br label %13
13: ; preds = %38, %11
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %41
16: ; preds = %13
%17 = call double* @im_getSnapshot(i32 1)
store double* %17, double** %6
%18 = load i64, i64* %3
%19 = add nsw i64 %18, 1
store i64 %19, i64* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %18)
store i32 0, i32* %2
br label %21
21: ; preds = %31, %16
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 256
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load double*, double** %6
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 32
store i32 %33, i32* %2
br label %21
34: ; preds = %21
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @stdout
%37 = call i32 @fflush(i32 %36)
br label %38
38: ; preds = %34
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %13
41: ; preds = %13
%42 = call i32 (...) @im_stop()
%43 = call i32 (...) @im_start()
br label %44
44: ; preds = %41
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %8
47: ; preds = %8
%48 = call i32 (...) @im_stop()
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%08lx: \00"
@.str.1 = [6 x i8] c" %.2f\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @im_start()
br label %2
2: ; preds = %0, %41
%3 = phi i32 [ 0, %0 ], [ %44, %41 ]
%4 = phi i64 [ 0, %0 ], [ %35, %41 ]
%5 = tail call i32 @usleep(i32 33333)
%6 = trunc i64 %4 to i32
%7 = add i32 %6, 100
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ %4, %2 ], [ %35, %8 ]
%10 = tail call double* @im_getSnapshot(i32 1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %9)
%12 = load double, double* %10
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = getelementptr inbounds double, double* %10, i64 32
%15 = load double, double* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = getelementptr inbounds double, double* %10, i64 64
%18 = load double, double* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = getelementptr inbounds double, double* %10, i64 96
%21 = load double, double* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = getelementptr inbounds double, double* %10, i64 128
%24 = load double, double* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = getelementptr inbounds double, double* %10, i64 160
%27 = load double, double* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = getelementptr inbounds double, double* %10, i64 192
%30 = load double, double* %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %30)
%32 = getelementptr inbounds double, double* %10, i64 224
%33 = load double, double* %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %33)
%35 = add i64 %9, 1
%36 = tail call i32 @putchar(i32 10)
%37 = load i32, i32* @stdout
%38 = tail call i32 @fflush(i32 %37)
%39 = trunc i64 %35 to i32
%40 = icmp eq i32 %7, %39
br i1 %40, label %41, label %8
41: ; preds = %8
%42 = tail call i32 (...) @im_stop()
%43 = tail call i32 (...) @im_start()
%44 = add nuw nsw i32 %3, 1
%45 = icmp eq i32 %44, 100
br i1 %45, label %46, label %2
46: ; preds = %41
%47 = tail call i32 (...) @im_stop()
ret i32 0
}