#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 */
double cos(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
double sin(int);
int main(int argc, char **argv) {
  int i, j;
  double t;
  printf("@focus off\n");
  printf("@g0 on\n");
  printf("@with g0\n");
  printf("@view 0.1, 0.1, 0.9, 0.4\n");
  printf("@g1 on\n");
  printf("@with g1\n");
  printf("@view 0.1, 0.5, 0.9, 0.9\n");
  printf("@subtitle \"Spectrum\"\n");
  for (j = 20; j > 0; j--) {
    printf("@with g0\n");
    printf("@kill s0\n");
    for (i = 0; i < 101; i++) {
      t = 8.0 * i / (1.0 * j) * 3.14;
      printf("%d %f\n", i,
             cos(t) + sin(2.0 * t) + cos(t / 2.0) + sin(4 * t) + cos(t / 4.0));
    }
    printf("&\n");
    printf("@subtitle \"Data %d\"\n", j);
    if (j == 20) {
      printf("@autoscale\n");
    }
    printf("@dft(s0, 2)\n");
    printf("@move g0.s1 to g1.s0\n");
    if (j == 20) {
      printf("@with g1\n");
      printf("@autoscale\n");
    }
    printf("@redraw\n");
    printf("@sleep 1\n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x14,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    13a9 <main+0x269>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x65,-0x14(%rbp)
jge    1306 <main+0x1c6>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe0f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm2
movsd  0xdf6(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xdde(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xdb0(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd84(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd5a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd2e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <cos@plt>
mov    -0x2c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
lea    0xdbb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fa <main+0xba>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x14,-0x18(%rbp)
jne    133d <main+0x1fd>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x14,-0x18(%rbp)
jne    137f <main+0x23f>
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11cd <main+0x8d>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xf51(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
mov    $0x14,%r13d
lea    0xe65(%rip),%rbx
lea    0xefa(%rip),%r15
lea    0xee7(%rip),%r12
jmp    1216 <main+0xc6>
nopl   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1(%r13),%eax
cmp    $0x1,%r13d
mov    %eax,%r13d
jbe    137c <main+0x22c>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm0
mulsd  0xd9e(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0xd98(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xd62(%rip),%xmm0
call   1060 <cos@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xd4b(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xd30(%rip),%xmm0
call   1060 <cos@plt>
addsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm1
addsd  0xd12(%rip),%xmm1
add    $0x1,%r14d
cmp    $0x65,%r14d
jne    1250 <main+0x100>
lea    0xd93(%rip),%rdi
call   1030 <puts@plt>
lea    0xd00(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rbp
cmp    $0x14,%r13d
jne    11e0 <main+0x90>
lea    0xda3(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xd7b(%rip),%rdi
jmp    11e0 <main+0x90>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"@focus off\0A\00"
@.str.1 = [8 x i8] c"@g0 on\0A\00"
@.str.2 = [10 x i8] c"@with g0\0A\00"
@.str.3 = [26 x i8] c"@view 0.1, 0.1, 0.9, 0.4\0A\00"
@.str.4 = [8 x i8] c"@g1 on\0A\00"
@.str.5 = [10 x i8] c"@with g1\0A\00"
@.str.6 = [26 x i8] c"@view 0.1, 0.5, 0.9, 0.9\0A\00"
@.str.7 = [22 x i8] c"@subtitle \22Spectrum\22\0A\00"
@.str.8 = [10 x i8] c"@kill s0\0A\00"
@.str.9 = [7 x i8] c"%d %f\0A\00"
@.str.10 = [3 x i8] c"&\0A\00"
@.str.11 = [21 x i8] c"@subtitle \22Data %d\22\0A\00"
@.str.12 = [12 x i8] c"@autoscale\0A\00"
@.str.13 = [13 x i8] c"@dft(s0, 2)\0A\00"
@.str.14 = [22 x i8] c"@move g0.s1 to g1.s0\0A\00"
@.str.15 = [9 x i8] c"@redraw\0A\00"
@.str.16 = [10 x i8] c"@sleep 1\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 double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
store i32 20, i32* %7
br label %17
17: ; preds = %79, %2
%18 = load i32, i32* %7
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %82
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %6
br label %23
23: ; preds = %57, %20
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 101
br i1 %25, label %26, label %60
26: ; preds = %23
%27 = load i32, i32* %6
%28 = sitofp i32 %27 to double
%29 = fmul double 8.000000e+00, %28
%30 = load i32, i32* %7
%31 = sitofp i32 %30 to double
%32 = fmul double 1.000000e+00, %31
%33 = fdiv double %29, %32
%34 = fmul double %33, 3.140000e+00
store double %34, double* %8
%35 = load i32, i32* %6
%36 = load double, double* %8
%37 = call double @cos(double %36)
%38 = load double, double* %8
%39 = fmul double 2.000000e+00, %38
%40 = fptosi double %39 to i32
%41 = call double @sin(i32 %40)
%42 = fadd double %37, %41
%43 = load double, double* %8
%44 = fdiv double %43, 2.000000e+00
%45 = call double @cos(double %44)
%46 = fadd double %42, %45
%47 = load double, double* %8
%48 = fmul double 4.000000e+00, %47
%49 = fptosi double %48 to i32
%50 = call double @sin(i32 %49)
%51 = fadd double %46, %50
%52 = load double, double* %8
%53 = fdiv double %52, 4.000000e+00
%54 = call double @cos(double %53)
%55 = fadd double %51, %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %35, double %55)
br label %57
57: ; preds = %26
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %23
60: ; preds = %23
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%62 = load i32, i32* %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %7
%65 = icmp eq i32 %64, 20
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %68
68: ; preds = %66, %60
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%71 = load i32, i32* %7
%72 = icmp eq i32 %71, 20
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %76
76: ; preds = %73, %68
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
br label %79
79: ; preds = %76
%80 = load i32, i32* %7
%81 = add nsw i32 %80, -1
store i32 %81, i32* %7
br label %17
82: ; preds = %17
%83 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.9 = [7 x i8] c"%d %f\0A\00"
@.str.11 = [21 x i8] c"@subtitle \22Data %d\22\0A\00"
@str = [11 x i8] c"@focus off\00"
@str.17 = [7 x i8] c"@g0 on\00"
@str.19 = [25 x i8] c"@view 0.1, 0.1, 0.9, 0.4\00"
@str.20 = [7 x i8] c"@g1 on\00"
@str.22 = [25 x i8] c"@view 0.1, 0.5, 0.9, 0.9\00"
@str.23 = [21 x i8] c"@subtitle \22Spectrum\22\00"
@str.24 = [9 x i8] c"@with g0\00"
@str.25 = [9 x i8] c"@kill s0\00"
@str.26 = [2 x i8] c"&\00"
@str.27 = [12 x i8] c"@dft(s0, 2)\00"
@str.28 = [21 x i8] c"@move g0.s1 to g1.s0\00"
@str.29 = [8 x i8] c"@redraw\00"
@str.30 = [9 x i8] c"@sleep 1\00"
@str.31 = [9 x i8] c"@with g1\00"
@str.33 = [11 x i8] c"@autoscale\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.17, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.24, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.19, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.20, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.31, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.22, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0))
br label %11
11: ; preds = %2, %48
%12 = phi i32 [ 20, %2 ], [ %55, %48 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.24, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.25, i64 0, i64 0))
%15 = sitofp i32 %12 to double
br label %16
16: ; preds = %11, %16
%17 = phi i32 [ 0, %11 ], [ %38, %16 ]
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 8.000000e+00
%20 = fdiv double %19, %15
%21 = fmul double %20, 3.140000e+00
%22 = tail call double @cos(double %21)
%23 = fmul double %21, 2.000000e+00
%24 = fptosi double %23 to i32
%25 = tail call double @sin(i32 %24)
%26 = fadd double %22, %25
%27 = fmul double %21, 5.000000e-01
%28 = tail call double @cos(double %27)
%29 = fadd double %26, %28
%30 = fmul double %21, 4.000000e+00
%31 = fptosi double %30 to i32
%32 = tail call double @sin(i32 %31)
%33 = fadd double %29, %32
%34 = fmul double %21, 2.500000e-01
%35 = tail call double @cos(double %34)
%36 = fadd double %33, %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %17, double %36)
%38 = add nuw nsw i32 %17, 1
%39 = icmp eq i32 %38, 101
br i1 %39, label %40, label %16
40: ; preds = %16
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.26, i64 0, i64 0))
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %12)
%43 = icmp eq i32 %12, 20
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.33, i64 0, i64 0))
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.27, i64 0, i64 0))
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.28, i64 0, i64 0))
br label %48
48: ; preds = %40, %44
%49 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.31, i64 0, i64 0), %44 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.27, i64 0, i64 0), %40 ]
%50 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.33, i64 0, i64 0), %44 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.28, i64 0, i64 0), %40 ]
%51 = tail call i32 @puts(i8* dereferenceable(1) %49)
%52 = tail call i32 @puts(i8* dereferenceable(1) %50)
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.29, i64 0, i64 0))
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.30, i64 0, i64 0))
%55 = add nsw i32 %12, -1
%56 = icmp ugt i32 %12, 1
br i1 %56, label %11, label %57
57: ; preds = %48
%58 = tail call i32 @exit(i32 0)
unreachable
}