#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*/ _putpixel(float, float);
int /*<<< orphan*/ abs(float);
unsigned int atoi(char *);
int /*<<< orphan*/ cleardevice();
int /*<<< orphan*/ closegraph();
int getmaxmode();
int getmaxx();
int getmaxy();
int /*<<< orphan*/ initgraph(int *, int *, char *);
int /*<<< orphan*/ kbhit();
int /*<<< orphan*/ mouseclick();
int /*<<< orphan*/ outtextxy(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int rand();
float scanf(char *, unsigned int *);
int /*<<< orphan*/ setbkcolor(int /*<<< orphan*/);
int /*<<< orphan*/ setcolor(int);
float sgn(float);
float sqrt(int /*<<< orphan*/);
int /*<<< orphan*/ srand(unsigned int);
int main(int argc, char **argv) {
  int gd, gm;
  int col;
  unsigned int seed;
  long int counter;
  float j, k, x, y, xx, xp, yp, r, xoffs, yoffs;
  if (argc == 2)
    seed = atoi(argv[1]);
  else {
    printf("Seed: ");
    j = scanf("%d", &seed);
  }
  srand(seed);
  gd = 11;
  gm = getmaxmode();
  initgraph(&gd, &gm, "");
  setbkcolor(0);
  cleardevice();
  setcolor(14);
  outtextxy(0, 0, "Press a key or click to exit: ");
  xoffs = getmaxx() / 2;
  yoffs = getmaxy() / 3;
  j = (rand() % (100));
  k = (rand() % (100));
  x = y = xx = xp = yp = r = 0.0;
  col = 1;
  counter = 0;
  setcolor(col);
  while (!kbhit() && !mouseclick()) {
    xx = y - sgn(x) * sqrt(abs(k * x - 1));
    y = j - x;
    x = xx;
    xp = x * 2 + xoffs;
    yp = y * 2 + yoffs;
    _putpixel(xp, yp);
    if (++counter == 20000) {
      counter = 0;
      col++;
      if (col == 16)
        col = 1;
    }
    setcolor(col);
  }
  closegraph();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1275 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1296 <main+0x56>
lea    0xd88(%rip),%rdi
call   10b0 <printf@plt>
lea    0xd83(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1100 <scanf@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
call   10d0 <srand@plt>
movl   $0xb,-0x14(%rbp)
mov    $0x0,%al
call   1070 <getmaxmode@plt>
mov    %eax,-0x18(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    0xd4c(%rip),%rdx
call   1040 <initgraph@plt>
xor    %edi,%edi
call   1080 <setbkcolor@plt>
mov    $0x0,%al
call   1060 <cleardevice@plt>
mov    $0xe,%edi
call   1140 <setcolor@plt>
xor    %esi,%esi
lea    0xd2a(%rip),%rdx
mov    %esi,%edi
call   1090 <outtextxy@plt>
mov    $0x0,%al
call   10f0 <getmaxx@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    $0x0,%al
call   10a0 <getmaxy@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1160 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    $0x0,%al
call   1160 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movl   $0x1,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1140 <setcolor@plt>
mov    $0x0,%al
call   10c0 <kbhit@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x51(%rbp)
jne    13bb <main+0x17b>
mov    $0x0,%al
call   1030 <mouseclick@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    13cb <main+0x18b>
jmp    14d3 <main+0x293>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x34(%rbp),%xmm0
call   1110 <sgn@plt>
movss  %xmm0,-0x58(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xc06(%rip),%xmm1
addss  %xmm1,%xmm0
call   1050 <abs@plt>
mov    %eax,%edi
call   1130 <sqrt@plt>
movss  -0x5c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x58(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x2c(%rbp),%xmm0
subss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x38(%rbp),%xmm0
movss  -0x50(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x40(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
call   1150 <_putpixel@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cmp    $0x4e20,%rax
jne    14c6 <main+0x286>
movq   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jne    14c1 <main+0x281>
movl   $0x1,-0x1c(%rbp)
jmp    14c6 <main+0x286>
mov    -0x1c(%rbp),%edi
call   1140 <setcolor@plt>
jmp    1392 <main+0x152>
mov    $0x0,%al
call   10e0 <closegraph@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
cmp    $0x2,%edi
jne    1262 <main+0x22>
mov    0x8(%rsi),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
mov    %eax,0x14(%rsp)
jmp    1283 <main+0x43>
lea    0xd9b(%rip),%rdi
call   10b0 <printf@plt>
lea    0xd96(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1100 <scanf@plt>
mov    0x14(%rsp),%edi
call   10d0 <srand@plt>
movl   $0xb,0x2c(%rsp)
xor    %eax,%eax
call   1070 <getmaxmode@plt>
mov    %eax,0x28(%rsp)
lea    0xd68(%rip),%rdx
lea    0x2c(%rsp),%rdi
lea    0x28(%rsp),%rsi
call   1040 <initgraph@plt>
xor    %edi,%edi
call   1080 <setbkcolor@plt>
xor    %eax,%eax
call   1060 <cleardevice@plt>
mov    $0xe,%edi
call   1140 <setcolor@plt>
lea    0xd3e(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1090 <outtextxy@plt>
xor    %eax,%eax
call   10f0 <getmaxx@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <getmaxy@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1160 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1160 <rand@plt>
mov    %eax,%r14d
mov    $0x1,%r12d
mov    $0x1,%edi
call   1140 <setcolor@plt>
xor    %eax,%eax
call   10c0 <kbhit@plt>
test   %eax,%eax
jne    149c <main+0x25c>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x24(%rsp)
movslq %ebp,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x20(%rsp)
movslq %r15d,%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x1c(%rsp)
movslq %r14d,%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
mov    $0x1,%r14d
xor    %ebp,%ebp
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <mouseclick@plt>
test   %eax,%eax
jne    149c <main+0x25c>
movss  0x8(%rsp),%xmm0
call   1110 <sgn@plt>
movss  %xmm0,0xc(%rsp)
movss  0x18(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
addss  0xbfc(%rip),%xmm0
call   1050 <abs@plt>
mov    %eax,%edi
call   1130 <sqrt@plt>
mulss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  %xmm2,0xc(%rsp)
movss  0x1c(%rsp),%xmm1
subss  0x8(%rsp),%xmm1
movaps %xmm2,%xmm0
addss  %xmm2,%xmm0
addss  0x24(%rsp),%xmm0
movss  %xmm1,0x10(%rsp)
addss  %xmm1,%xmm1
addss  0x20(%rsp),%xmm1
call   1150 <_putpixel@plt>
add    $0x1,%rbp
lea    0x1(%r14),%ebx
cmp    $0x10,%ebx
cmove  %r12d,%ebx
cmp    $0x4e20,%rbp
mov    $0x0,%eax
cmove  %rax,%rbp
cmovne %r14d,%ebx
mov    %ebx,%edi
call   1140 <setcolor@plt>
xor    %eax,%eax
call   10c0 <kbhit@plt>
mov    %ebx,%r14d
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
test   %eax,%eax
je     13d0 <main+0x190>
xor    %eax,%eax
call   10e0 <closegraph@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Seed: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [31 x i8] c"Press a key or click to exit: \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 i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %28
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
br label %31
28: ; preds = %2
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%30 = call float @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
store float %30, float* %11
br label %31
31: ; preds = %28, %23
%32 = load i32, i32* %9
%33 = call i32 @srand(i32 %32)
store i32 11, i32* %6
%34 = call i32 (...) @getmaxmode()
store i32 %34, i32* %7
%35 = call i32 @initgraph(i32* %6, i32* %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @setbkcolor(i32 0)
%37 = call i32 (...) @cleardevice()
%38 = call i32 @setcolor(i32 14)
%39 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 (...) @getmaxx()
%41 = sdiv i32 %40, 2
%42 = sitofp i32 %41 to float
store float %42, float* %19
%43 = call i32 (...) @getmaxy()
%44 = sdiv i32 %43, 3
%45 = sitofp i32 %44 to float
store float %45, float* %20
%46 = call i32 (...) @rand()
%47 = srem i32 %46, 100
%48 = sitofp i32 %47 to float
store float %48, float* %11
%49 = call i32 (...) @rand()
%50 = srem i32 %49, 100
%51 = sitofp i32 %50 to float
store float %51, float* %12
store float 0.000000e+00, float* %18
store float 0.000000e+00, float* %17
store float 0.000000e+00, float* %16
store float 0.000000e+00, float* %15
store float 0.000000e+00, float* %14
store float 0.000000e+00, float* %13
store i32 1, i32* %8
store i64 0, i64* %10
%52 = load i32, i32* %8
%53 = call i32 @setcolor(i32 %52)
br label %54
54: ; preds = %97, %31
%55 = call i32 (...) @kbhit()
%56 = icmp ne i32 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %54
%58 = call i32 (...) @mouseclick()
%59 = icmp ne i32 %58, 0
%60 = xor i1 %59, true
br label %61
61: ; preds = %57, %54
%62 = phi i1 [ false, %54 ], [ %60, %57 ]
br i1 %62, label %63, label %100
63: ; preds = %61
%64 = load float, float* %14
%65 = load float, float* %13
%66 = call float @sgn(float %65)
%67 = load float, float* %12
%68 = load float, float* %13
%69 = call float @llvm.fmuladd.f32(float %67, float %68, float -1.000000e+00)
%70 = call i32 @abs(float %69)
%71 = call float @sqrt(i32 %70)
%72 = fneg float %66
%73 = call float @llvm.fmuladd.f32(float %72, float %71, float %64)
store float %73, float* %15
%74 = load float, float* %11
%75 = load float, float* %13
%76 = fsub float %74, %75
store float %76, float* %14
%77 = load float, float* %15
store float %77, float* %13
%78 = load float, float* %13
%79 = load float, float* %19
%80 = call float @llvm.fmuladd.f32(float %78, float 2.000000e+00, float %79)
store float %80, float* %16
%81 = load float, float* %14
%82 = load float, float* %20
%83 = call float @llvm.fmuladd.f32(float %81, float 2.000000e+00, float %82)
store float %83, float* %17
%84 = load float, float* %16
%85 = load float, float* %17
%86 = call i32 @_putpixel(float %84, float %85)
%87 = load i64, i64* %10
%88 = add nsw i64 %87, 1
store i64 %88, i64* %10
%89 = icmp eq i64 %88, 20000
br i1 %89, label %90, label %97
90: ; preds = %63
store i64 0, i64* %10
%91 = load i32, i32* %8
%92 = add nsw i32 %91, 1
store i32 %92, i32* %8
%93 = load i32, i32* %8
%94 = icmp eq i32 %93, 16
br i1 %94, label %95, label %96
95: ; preds = %90
store i32 1, i32* %8
br label %96
96: ; preds = %95, %90
br label %97
97: ; preds = %96, %63
%98 = load i32, i32* %8
%99 = call i32 @setcolor(i32 %98)
br label %54
100: ; preds = %61
%101 = call i32 (...) @closegraph()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Seed: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [31 x i8] c"Press a key or click to exit: \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
store i32 %13, i32* %5
br label %18
14: ; preds = %2
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = call float @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%17 = load i32, i32* %5
br label %18
18: ; preds = %14, %10
%19 = phi i32 [ %17, %14 ], [ %13, %10 ]
%20 = call i32 @srand(i32 %19)
store i32 11, i32* %3
%21 = call i32 (...) @getmaxmode()
store i32 %21, i32* %4
%22 = call i32 @initgraph(i32* %3, i32* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @setbkcolor(i32 0)
%24 = call i32 (...) @cleardevice()
%25 = call i32 @setcolor(i32 14)
%26 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (...) @getmaxx()
%28 = sdiv i32 %27, 2
%29 = sitofp i32 %28 to float
%30 = call i32 (...) @getmaxy()
%31 = sdiv i32 %30, 3
%32 = sitofp i32 %31 to float
%33 = call i32 (...) @rand()
%34 = srem i32 %33, 100
%35 = sitofp i32 %34 to float
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 100
%38 = sitofp i32 %37 to float
%39 = call i32 @setcolor(i32 1)
%40 = call i32 (...) @kbhit()
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %70
42: ; preds = %18, %49
%43 = phi i32 [ %66, %49 ], [ 1, %18 ]
%44 = phi i64 [ %65, %49 ], [ 0, %18 ]
%45 = phi float [ %56, %49 ], [ 0.000000e+00, %18 ]
%46 = phi float [ %55, %49 ], [ 0.000000e+00, %18 ]
%47 = call i32 (...) @mouseclick()
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %70
49: ; preds = %42
%50 = call float @sgn(float %46)
%51 = call float @llvm.fmuladd.f32(float %38, float %46, float -1.000000e+00)
%52 = call i32 @abs(float %51)
%53 = call float @sqrt(i32 %52)
%54 = fneg float %50
%55 = call float @llvm.fmuladd.f32(float %54, float %53, float %45)
%56 = fsub float %35, %46
%57 = call float @llvm.fmuladd.f32(float %55, float 2.000000e+00, float %29)
%58 = call float @llvm.fmuladd.f32(float %56, float 2.000000e+00, float %32)
%59 = call i32 @_putpixel(float %57, float %58)
%60 = add nsw i64 %44, 1
%61 = icmp eq i64 %60, 20000
%62 = add nsw i32 %43, 1
%63 = icmp eq i32 %62, 16
%64 = select i1 %63, i32 1, i32 %62
%65 = select i1 %61, i64 0, i64 %60
%66 = select i1 %61, i32 %64, i32 %43
%67 = call i32 @setcolor(i32 %66)
%68 = call i32 (...) @kbhit()
%69 = icmp eq i32 %68, 0
br i1 %69, label %42, label %70
70: ; preds = %42, %49, %18
%71 = call i32 (...) @closegraph()
ret i32 0
}