#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 sqrt(double);
int inunitsphere(int i, int j, int width, int height) {
  double u, v;
  double r;
  v = (height / 2.0 - j) / (height / 2.0);
  u = (i - width / 2.0) / (width / 2.0);
  r = sqrt(u * u + v * v);
  if (r > 1.0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<inunitsphere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xed7(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xebd(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe9e(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe89(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe41(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d5 <inunitsphere+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    11dc <inunitsphere+0xcc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inunitsphere>:
push   %rax
cvtsi2sd %ecx,%xmm1
movsd  0xee3(%rip),%xmm2
cvtsi2sd %esi,%xmm0
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
divsd  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1167 <inunitsphere+0x57>
sqrtsd %xmm0,%xmm0
jmp    116c <inunitsphere+0x5c>
call   1030 <sqrt@plt>
xor    %eax,%eax
ucomisd 0xe92(%rip),%xmm0
setbe  %al
pop    %rcx
ret

LLVM IR (-O0):
define i32 @inunitsphere(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %9
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 2.000000e+00
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = fsub double %15, %17
%19 = load i32, i32* %9
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 2.000000e+00
%22 = fdiv double %18, %21
store double %22, double* %11
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %8
%26 = sitofp i32 %25 to double
%27 = fdiv double %26, 2.000000e+00
%28 = fsub double %24, %27
%29 = load i32, i32* %8
%30 = sitofp i32 %29 to double
%31 = fdiv double %30, 2.000000e+00
%32 = fdiv double %28, %31
store double %32, double* %10
%33 = load double, double* %10
%34 = load double, double* %10
%35 = load double, double* %11
%36 = load double, double* %11
%37 = fmul double %35, %36
%38 = call double @llvm.fmuladd.f64(double %33, double %34, double %37)
%39 = call double @sqrt(double %38)
store double %39, double* %12
%40 = load double, double* %12
%41 = fcmp ogt double %40, 1.000000e+00
br i1 %41, label %42, label %43
42: ; preds = %4
store i32 0, i32* %5
br label %44
43: ; preds = %4
store i32 1, i32* %5
br label %44
44: ; preds = %43, %42
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
define i32 @inunitsphere(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sitofp i32 %3 to double
%6 = fmul double %5, 5.000000e-01
%7 = sitofp i32 %1 to double
%8 = fsub double %6, %7
%9 = fdiv double %8, %6
%10 = sitofp i32 %0 to double
%11 = sitofp i32 %2 to double
%12 = fmul double %11, 5.000000e-01
%13 = fsub double %10, %12
%14 = fdiv double %13, %12
%15 = fmul double %9, %9
%16 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %15)
%17 = tail call double @sqrt(double %16)
%18 = fcmp ule double %17, 1.000000e+00
%19 = zext i1 %18 to i32
ret i32 %19
}