#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 */
scalar_t__ is_integer(float);
int /*<<< orphan*/ printf(char *, int);
float sqrt(float);
void problem_009(void) {
  float n = 1000;
  float a, b;
  for (b = 1; b <= n / 2; b++) {
    a = ((n * n) / 2 - (n * b)) / (n - b);
    if (is_integer(a)) {
      int product = a * b * sqrt(a * a + b * b);
      printf("%i", product);
      return;
    }
  }
  return;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xec4(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
movss  0xea4(%rip),%xmm2
divss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jb     1240 <problem_009+0x110>
movss  -0x4(%rbp),%xmm1
mulss  -0x4(%rbp),%xmm1
movss  0xe85(%rip),%xmm0
divss  %xmm0,%xmm1
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
subss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <is_integer@plt>
cmp    $0x0,%rax
je     1224 <problem_009+0xf4>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <problem_009+0x115>
jmp    1229 <problem_009+0xf9>
movss  0xdcf(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1152 <problem_009+0x22>
jmp    1245 <problem_009+0x115>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
movaps %xmm2,%xmm0
mulss  0xeae(%rip),%xmm0
addss  0xeaa(%rip),%xmm0
movss  0xea6(%rip),%xmm1
movss  %xmm2,0xc(%rsp)
subss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
call   1030 <is_integer@plt>
test   %rax,%rax
jne    1191 <problem_009+0x61>
add    $0x1,%ebx
cmp    $0x1f5,%ebx
jne    1140 <problem_009+0x10>
add    $0x10,%rsp
pop    %rbx
ret
movss  0x8(%rsp),%xmm0
movaps %xmm0,%xmm2
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm2
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11be <problem_009+0x8e>
sqrtss %xmm0,%xmm0
jmp    11cf <problem_009+0x9f>
movss  %xmm2,0x8(%rsp)
call   1050 <sqrt@plt>
movss  0x8(%rsp),%xmm2
mulss  %xmm0,%xmm2
cvttss2si %xmm2,%esi
lea    0xe2e(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define void @problem_009() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store float 1.000000e+03, float* %1
store float 1.000000e+00, float* %3
br label %5
5: ; preds = %42, %0
%6 = load float, float* %3
%7 = load float, float* %1
%8 = fdiv float %7, 2.000000e+00
%9 = fcmp ole float %6, %8
br i1 %9, label %10, label %45
10: ; preds = %5
%11 = load float, float* %1
%12 = load float, float* %1
%13 = fmul float %11, %12
%14 = fdiv float %13, 2.000000e+00
%15 = load float, float* %1
%16 = load float, float* %3
%17 = fneg float %15
%18 = call float @llvm.fmuladd.f32(float %17, float %16, float %14)
%19 = load float, float* %1
%20 = load float, float* %3
%21 = fsub float %19, %20
%22 = fdiv float %18, %21
store float %22, float* %2
%23 = load float, float* %2
%24 = call i64 @is_integer(float %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %41
26: ; preds = %10
%27 = load float, float* %2
%28 = load float, float* %3
%29 = fmul float %27, %28
%30 = load float, float* %2
%31 = load float, float* %2
%32 = load float, float* %3
%33 = load float, float* %3
%34 = fmul float %32, %33
%35 = call float @llvm.fmuladd.f32(float %30, float %31, float %34)
%36 = call float @sqrt(float %35)
%37 = fmul float %29, %36
%38 = fptosi float %37 to i32
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %46
41: ; preds = %10
br label %42
42: ; preds = %41
%43 = load float, float* %3
%44 = fadd float %43, 1.000000e+00
store float %44, float* %3
br label %5
45: ; preds = %5
br label %46
46: ; preds = %45, %26
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define void @problem_009() {
br label %1
1: ; preds = %0, %17
%2 = phi i32 [ 1, %0 ], [ %18, %17 ]
%3 = sitofp i32 %2 to float
%4 = tail call float @llvm.fmuladd.f32(float %3, float -1.000000e+03, float 5.000000e+05)
%5 = fsub float 1.000000e+03, %3
%6 = fdiv float %4, %5
%7 = tail call i64 @is_integer(float %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %1
%10 = fmul float %6, %3
%11 = fmul float %3, %3
%12 = tail call float @llvm.fmuladd.f32(float %6, float %6, float %11)
%13 = tail call float @sqrt(float %12)
%14 = fmul float %10, %13
%15 = fptosi float %14 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %20
17: ; preds = %1
%18 = add nuw nsw i32 %2, 1
%19 = icmp eq i32 %18, 501
br i1 %19, label %20, label %1
20: ; preds = %17, %9
ret void
}