#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  void *background;
  void *foreground;
};
typedef TYPE_1__ XGCValues;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
void *BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
scalar_t__ GCBackground;
scalar_t__ GCForeground;
void *WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XClearWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             scalar_t__, TYPE_1__ *);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ XFillRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/);
int /*<<< orphan*/ drawWave(float *, int, int /*<<< orphan*/ *,
                            int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                            int, int);
float sin(int);
int /*<<< orphan*/ sleep(int);
main() {
  Display *d = XOpenDisplay(0);
  Window w =
      XCreateWindow(d, DefaultRootWindow(d), 100, 100, 300, 300, 0,
                    CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  XMapWindow(d, w);
  XFlush(d);
  sleep(1);
  XGCValues blackgcv, whitegcv;
  blackgcv.foreground = BlackPixel(d, DefaultScreen(d));
  blackgcv.background = WhitePixel(d, DefaultScreen(d));
  whitegcv.foreground = WhitePixel(d, DefaultScreen(d));
  whitegcv.background = BlackPixel(d, DefaultScreen(d));
  GC black = XCreateGC(d, w, GCForeground + GCBackground, &blackgcv);
  GC white = XCreateGC(d, w, GCForeground + GCBackground, &whitegcv);
  XClearWindow(d, w);
  XFlush(d);
  XFillRectangle(d, w, black, 0, 0, 300, 300);
  XFillRectangle(d, w, white, 50, 50, 200, 200);
  XFlush(d);
  float davethesinewave[500];
  int k;
  for (k = 0; k < 500; k++) {
    davethesinewave[k] = sin(k);
  }
  drawWave(davethesinewave, 500, d, w, black, 50, 50, 200, 200);
  sleep(10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <DefaultRootWindow@plt>
mov    -0x840(%rbp),%rdi
mov    %eax,%esi
mov    0x2daf(%rip),%rax
mov    (%rax),%r11d
mov    0x2da5(%rip),%rax
mov    (%rax),%r10d
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    $0x64,%ecx
mov    $0x12c,%r9d
xor    %edx,%edx
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10e0 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <XFlush@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x838(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x838(%rbp),%rdi
mov    %eax,%esi
call   10c0 <BlackPixel@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x830(%rbp),%rdi
mov    %eax,%esi
call   1070 <WhitePixel@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x828(%rbp),%rdi
mov    %eax,%esi
call   1070 <WhitePixel@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x820(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x820(%rbp),%rdi
mov    %eax,%esi
call   10c0 <BlackPixel@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2cad(%rip),%rax
mov    (%rax),%rdx
mov    0x2c93(%rip),%rax
add    (%rax),%rdx
lea    -0x28(%rbp),%rcx
call   10b0 <XCreateGC@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2c86(%rip),%rax
mov    (%rax),%rdx
mov    0x2c6c(%rip),%rax
add    (%rax),%rdx
lea    -0x38(%rbp),%rcx
call   10b0 <XCreateGC@plt>
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <XClearWindow@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <XFlush@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x3c(%rbp),%edx
xor    %r8d,%r8d
mov    $0x12c,%r9d
mov    %r8d,%ecx
movl   $0x12c,(%rsp)
call   1060 <XFillRectangle@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    $0x32,%r8d
mov    $0xc8,%r9d
mov    %r8d,%ecx
movl   $0xc8,(%rsp)
call   1060 <XFillRectangle@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <XFlush@plt>
movl   $0x0,-0x814(%rbp)
cmpl   $0x1f4,-0x814(%rbp)
jge    1429 <main+0x249>
mov    -0x814(%rbp),%edi
call   1090 <sin@plt>
movslq -0x814(%rbp),%rax
movss  %xmm0,-0x810(%rbp,%rax,4)
ff ff
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    13ea <main+0x20a>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    $0x1f4,%esi
mov    $0x32,%r9d
movl   $0x32,(%rsp)
movl   $0xc8,0x8(%rsp)
movl   $0xc8,0x10(%rsp)
call   1040 <drawWave@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
xor    %eax,%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f8,%rsp
xor    %ebx,%ebx
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <DefaultRootWindow@plt>
mov    0x2dc4(%rip),%rcx
mov    (%rcx),%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x64,%edx
mov    $0x64,%ecx
mov    $0x12c,%r8d
mov    $0x12c,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0x0
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%r12d
mov    %r14,%rdi
mov    %eax,%esi
call   10e0 <XMapWindow@plt>
mov    %r14,%rdi
call   10d0 <XFlush@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    %r14,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10c0 <BlackPixel@plt>
mov    %rax,0x18(%rsp)
mov    %r14,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1070 <WhitePixel@plt>
mov    %rax,0x10(%rsp)
mov    %r14,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1070 <WhitePixel@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10c0 <BlackPixel@plt>
mov    %rax,(%rsp)
mov    0x2d2c(%rip),%r13
mov    0x2d15(%rip),%rbp
mov    0x0(%rbp),%rdx
add    0x0(%r13),%rdx
lea    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r12d,%esi
call   10b0 <XCreateGC@plt>
mov    %eax,%r15d
mov    0x0(%rbp),%rdx
add    0x0(%r13),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
mov    %r12d,%esi
call   10b0 <XCreateGC@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <XClearWindow@plt>
mov    %r14,%rdi
call   10d0 <XFlush@plt>
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0x12c,%r9d
push   $0x12c
call   1060 <XFillRectangle@plt>
add    $0x8,%rsp
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    $0x32,%ecx
mov    $0x32,%r8d
mov    $0xc8,%r9d
push   $0xc8
call   1060 <XFillRectangle@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   10d0 <XFlush@plt>
xchg   %ax,%ax
mov    %ebx,%edi
call   1090 <sin@plt>
movss  %xmm0,0x20(%rsp,%rbx,4)
lea    0x1(%rbx),%edi
call   1090 <sin@plt>
movss  %xmm0,0x24(%rsp,%rbx,4)
lea    0x2(%rbx),%edi
call   1090 <sin@plt>
movss  %xmm0,0x28(%rsp,%rbx,4)
lea    0x3(%rbx),%edi
call   1090 <sin@plt>
movss  %xmm0,0x2c(%rsp,%rbx,4)
lea    0x4(%rbx),%edi
call   1090 <sin@plt>
movss  %xmm0,0x30(%rsp,%rbx,4)
add    $0x5,%rbx
cmp    $0x1f4,%rbx
jne    1360 <main+0x180>
sub    $0x8,%rsp
lea    0x28(%rsp),%rdi
mov    $0x1f4,%esi
mov    %r14,%rdx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    $0x32,%r9d
push   $0xc8
push   $0xc8
push   $0x32
call   1040 <drawWave@plt>
add    $0x20,%rsp
mov    $0xa,%edi
call   1100 <sleep@plt>
xor    %eax,%eax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i8* }
@CopyFromParent = global i32 0
@GCForeground = global i64 0
@GCBackground = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca %struct.TYPE_3__
%5 = alloca %struct.TYPE_3__
%6 = alloca i32
%7 = alloca i32
%8 = alloca [500 x float]
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32* @XOpenDisplay(i32 0)
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 @DefaultRootWindow(i32* %12)
%14 = load i32, i32* @CopyFromParent
%15 = load i32, i32* @CopyFromParent
%16 = load i32, i32* @CopyFromParent
%17 = call i32 @XCreateWindow(i32* %11, i32 %13, i32 100, i32 100, i32 300, i32 300, i32 0, i32 %14, i32 %15, i32 %16, i32 0, i32 0)
store i32 %17, i32* %3
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = call i32 @XMapWindow(i32* %18, i32 %19)
%21 = load i32*, i32** %2
%22 = call i32 @XFlush(i32* %21)
%23 = call i32 @sleep(i32 1)
%24 = load i32*, i32** %2
%25 = load i32*, i32** %2
%26 = call i32 @DefaultScreen(i32* %25)
%27 = call i8* @BlackPixel(i32* %24, i32 %26)
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 1
store i8* %27, i8** %28
%29 = load i32*, i32** %2
%30 = load i32*, i32** %2
%31 = call i32 @DefaultScreen(i32* %30)
%32 = call i8* @WhitePixel(i32* %29, i32 %31)
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 0
store i8* %32, i8** %33
%34 = load i32*, i32** %2
%35 = load i32*, i32** %2
%36 = call i32 @DefaultScreen(i32* %35)
%37 = call i8* @WhitePixel(i32* %34, i32 %36)
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 1
store i8* %37, i8** %38
%39 = load i32*, i32** %2
%40 = load i32*, i32** %2
%41 = call i32 @DefaultScreen(i32* %40)
%42 = call i8* @BlackPixel(i32* %39, i32 %41)
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
store i8* %42, i8** %43
%44 = load i32*, i32** %2
%45 = load i32, i32* %3
%46 = load i64, i64* @GCForeground
%47 = load i64, i64* @GCBackground
%48 = add nsw i64 %46, %47
%49 = call i32 @XCreateGC(i32* %44, i32 %45, i64 %48, %struct.TYPE_3__* %4)
store i32 %49, i32* %6
%50 = load i32*, i32** %2
%51 = load i32, i32* %3
%52 = load i64, i64* @GCForeground
%53 = load i64, i64* @GCBackground
%54 = add nsw i64 %52, %53
%55 = call i32 @XCreateGC(i32* %50, i32 %51, i64 %54, %struct.TYPE_3__* %5)
store i32 %55, i32* %7
%56 = load i32*, i32** %2
%57 = load i32, i32* %3
%58 = call i32 @XClearWindow(i32* %56, i32 %57)
%59 = load i32*, i32** %2
%60 = call i32 @XFlush(i32* %59)
%61 = load i32*, i32** %2
%62 = load i32, i32* %3
%63 = load i32, i32* %6
%64 = call i32 @XFillRectangle(i32* %61, i32 %62, i32 %63, i32 0, i32 0, i32 300, i32 300)
%65 = load i32*, i32** %2
%66 = load i32, i32* %3
%67 = load i32, i32* %7
%68 = call i32 @XFillRectangle(i32* %65, i32 %66, i32 %67, i32 50, i32 50, i32 200, i32 200)
%69 = load i32*, i32** %2
%70 = call i32 @XFlush(i32* %69)
store i32 0, i32* %9
br label %71
71: ; preds = %80, %0
%72 = load i32, i32* %9
%73 = icmp slt i32 %72, 500
br i1 %73, label %74, label %83
74: ; preds = %71
%75 = load i32, i32* %9
%76 = call float @sin(i32 %75)
%77 = load i32, i32* %9
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [500 x float], [500 x float]* %8, i64 0, i64 %78
store float %76, float* %79
br label %80
80: ; preds = %74
%81 = load i32, i32* %9
%82 = add nsw i32 %81, 1
store i32 %82, i32* %9
br label %71
83: ; preds = %71
%84 = getelementptr inbounds [500 x float], [500 x float]* %8, i64 0, i64 0
%85 = load i32*, i32** %2
%86 = load i32, i32* %3
%87 = load i32, i32* %6
%88 = call i32 @drawWave(float* %84, i32 500, i32* %85, i32 %86, i32 %87, i32 50, i32 50, i32 200, i32 200)
%89 = call i32 @sleep(i32 10)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i8* }
@CopyFromParent = global i32 0
@GCForeground = global i64 0
@GCBackground = global i64 0
define i32 @main() {
%1 = alloca %struct.TYPE_3__
%2 = alloca %struct.TYPE_3__
%3 = alloca [500 x float]
%4 = tail call i32* @XOpenDisplay(i32 0)
%5 = tail call i32 @DefaultRootWindow(i32* %4)
%6 = load i32, i32* @CopyFromParent
%7 = tail call i32 @XCreateWindow(i32* %4, i32 %5, i32 100, i32 100, i32 300, i32 300, i32 0, i32 %6, i32 %6, i32 %6, i32 0, i32 0)
%8 = tail call i32 @XMapWindow(i32* %4, i32 %7)
%9 = tail call i32 @XFlush(i32* %4)
%10 = tail call i32 @sleep(i32 1)
%11 = bitcast %struct.TYPE_3__* %1 to i8*
%12 = bitcast %struct.TYPE_3__* %2 to i8*
%13 = tail call i32 @DefaultScreen(i32* %4)
%14 = tail call i8* @BlackPixel(i32* %4, i32 %13)
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
store i8* %14, i8** %15
%16 = tail call i32 @DefaultScreen(i32* %4)
%17 = tail call i8* @WhitePixel(i32* %4, i32 %16)
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
store i8* %17, i8** %18
%19 = tail call i32 @DefaultScreen(i32* %4)
%20 = tail call i8* @WhitePixel(i32* %4, i32 %19)
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
store i8* %20, i8** %21
%22 = tail call i32 @DefaultScreen(i32* %4)
%23 = tail call i8* @BlackPixel(i32* %4, i32 %22)
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
store i8* %23, i8** %24
%25 = load i64, i64* @GCForeground
%26 = load i64, i64* @GCBackground
%27 = add nsw i64 %26, %25
%28 = call i32 @XCreateGC(i32* %4, i32 %7, i64 %27, %struct.TYPE_3__* %1)
%29 = load i64, i64* @GCForeground
%30 = load i64, i64* @GCBackground
%31 = add nsw i64 %30, %29
%32 = call i32 @XCreateGC(i32* %4, i32 %7, i64 %31, %struct.TYPE_3__* %2)
%33 = call i32 @XClearWindow(i32* %4, i32 %7)
%34 = call i32 @XFlush(i32* %4)
%35 = call i32 @XFillRectangle(i32* %4, i32 %7, i32 %28, i32 0, i32 0, i32 300, i32 300)
%36 = call i32 @XFillRectangle(i32* %4, i32 %7, i32 %32, i32 50, i32 50, i32 200, i32 200)
%37 = call i32 @XFlush(i32* %4)
%38 = bitcast [500 x float]* %3 to i8*
br label %39
39: ; preds = %39, %0
%40 = phi i64 [ 0, %0 ], [ %60, %39 ]
%41 = trunc i64 %40 to i32
%42 = call float @sin(i32 %41)
%43 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 %40
store float %42, float* %43
%44 = add nuw nsw i64 %40, 1
%45 = trunc i64 %44 to i32
%46 = call float @sin(i32 %45)
%47 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 %44
store float %46, float* %47
%48 = add nuw nsw i64 %40, 2
%49 = trunc i64 %48 to i32
%50 = call float @sin(i32 %49)
%51 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 %48
store float %50, float* %51
%52 = add nuw nsw i64 %40, 3
%53 = trunc i64 %52 to i32
%54 = call float @sin(i32 %53)
%55 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 %52
store float %54, float* %55
%56 = add nuw nsw i64 %40, 4
%57 = trunc i64 %56 to i32
%58 = call float @sin(i32 %57)
%59 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 %56
store float %58, float* %59
%60 = add nuw nsw i64 %40, 5
%61 = icmp eq i64 %60, 500
br i1 %61, label %62, label %39
62: ; preds = %39
%63 = getelementptr inbounds [500 x float], [500 x float]* %3, i64 0, i64 0
%64 = call i32 @drawWave(float* %63, i32 500, i32* %4, i32 %7, i32 %28, i32 50, i32 50, i32 200, i32 200)
%65 = call i32 @sleep(i32 10)
ret i32 0
}