#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*/ paintAxis();
int /*<<< orphan*/ paintSurroundingPixels(int, int);
int round(double);
scalar_t__ validScreenCoordinate(int, int);
void mathFunc(double a, double b, double c) {
  int x;
  int y;
  int screenX;
  int screenY;
  paintAxis();
  for (x = -1024 / 2; x < 1024 / 2; x++) {
    y = round(a * x * x + b * x + c);
    screenX = x + 1024 / 2;
    screenY = 768 / 2 - y;
    if (validScreenCoordinate(screenX, screenY)) {
      paintSurroundingPixels(screenX, screenY);
    }
  }
}


x86 assembly (clang, -O0):
<mathFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    $0x0,%al
call   1040 <paintAxis@plt>
movl   $0xfffffe00,-0x1c(%rbp)
cmpl   $0x200,-0x1c(%rbp)
jge    11f1 <mathFunc+0xb1>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x200,%eax
mov    %eax,-0x24(%rbp)
mov    $0x180,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <validScreenCoordinate@plt>
cmp    $0x0,%rax
je     11de <mathFunc+0x9e>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <paintSurroundingPixels@plt>
jmp    11e3 <mathFunc+0xa3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <mathFunc+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mathFunc>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <paintAxis@plt>
movsd  0xe97(%rip),%xmm2
jmp    1189 <mathFunc+0x49>
nopl   0x0(%rax,%rax,1)
movsd  0x20(%rsp),%xmm2
addsd  0xe8a(%rip),%xmm2
add    $0x1,%ebx
cmp    $0x400,%ebx
je     11d6 <mathFunc+0x96>
movapd %xmm2,%xmm0
mulsd  0x8(%rsp),%xmm0
movapd %xmm2,%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  %xmm2,0x20(%rsp)
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  0x18(%rsp),%xmm0
call   1050 <round@plt>
mov    $0x180,%ebp
sub    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <validScreenCoordinate@plt>
test   %rax,%rax
je     1170 <mathFunc+0x30>
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <paintSurroundingPixels@plt>
jmp    1170 <mathFunc+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @mathFunc(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%11 = call i32 (...) @paintAxis()
store i32 -512, i32* %7
br label %12
12: ; preds = %43, %3
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 512
br i1 %14, label %15, label %46
15: ; preds = %12
%16 = load double, double* %4
%17 = load i32, i32* %7
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to double
%22 = load double, double* %5
%23 = load i32, i32* %7
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = call double @llvm.fmuladd.f64(double %19, double %21, double %25)
%27 = load double, double* %6
%28 = fadd double %26, %27
%29 = call i32 @round(double %28)
store i32 %29, i32* %8
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 512
store i32 %31, i32* %9
%32 = load i32, i32* %8
%33 = sub nsw i32 384, %32
store i32 %33, i32* %10
%34 = load i32, i32* %9
%35 = load i32, i32* %10
%36 = call i64 @validScreenCoordinate(i32 %34, i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %15
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = call i32 @paintSurroundingPixels(i32 %39, i32 %40)
br label %42
42: ; preds = %38, %15
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %12
46: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @mathFunc(double %0, double %1, double %2) {
%4 = tail call i32 (...) @paintAxis()
br label %5
5: ; preds = %3, %19
%6 = phi i32 [ -512, %3 ], [ %20, %19 ]
%7 = sitofp i32 %6 to double
%8 = fmul double %7, %0
%9 = fmul double %7, %1
%10 = tail call double @llvm.fmuladd.f64(double %8, double %7, double %9)
%11 = fadd double %10, %2
%12 = tail call i32 @round(double %11)
%13 = add nsw i32 %6, 512
%14 = sub nsw i32 384, %12
%15 = tail call i64 @validScreenCoordinate(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %5
%18 = tail call i32 @paintSurroundingPixels(i32 %13, i32 %14)
br label %19
19: ; preds = %5, %17
%20 = add nsw i32 %6, 1
%21 = icmp eq i32 %20, 512
br i1 %21, label %22, label %5
22: ; preds = %19
ret void
}