#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 floor(double);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
double sqrt(int);
int main() {
  int a;
  int b;
  double c;
  int bot = floor(sqrt(1000));
  int asq, bsq, csq, m;
  for (a = 1; a < 1000; a++) {
    for (b = 1; b < (1000 - a); b++) {
      asq = pow(a, 2);
      printf("%d +", asq);
      bsq = pow(b, 2);
      printf(" %d = ", bsq);
      csq = asq + bsq;
      printf("%d\n", csq);
      c = sqrt(csq);
      if (floor(c) == c) {
        if (a + b + c == 1000) {
          printf("%d + %d + %f = 1000!\n", a, b, c);
          m = a * b * c;
          printf("%d*%d*%f = %d\n", a, b, c, m);
          return 0;
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3e8,%edi
call   1050 <sqrt@plt>
call   1060 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    12c1 <main+0x181>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    12ae <main+0x16e>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <floor@plt>
ucomisd -0x18(%rbp),%xmm0
jne    129b <main+0x15b>
jp     129b <main+0x15b>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1296 <main+0x156>
jp     1296 <main+0x156>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
lea    0xdc4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
mov    -0x2c(%rbp),%ecx
lea    0xda7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c1 <main+0x181>
jmp    129b <main+0x15b>
jmp    12a0 <main+0x160>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <main+0x40>
jmp    12b3 <main+0x173>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x2c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x3e8,%edi
call   1050 <sqrt@plt>
mov    $0x1,%r15d
mov    $0x3e7,%eax
mov    $0x2,%ecx
mov    %rcx,(%rsp)
jmp    1193 <main+0x53>
xchg   %ax,%ax
add    $0x1,%r15d
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    (%rsp),%rcx
add    $0x1,%ecx
mov    %rcx,(%rsp)
cmp    $0x3e8,%r15d
je     12a6 <main+0x166>
cmp    $0x3,%eax
mov    $0x2,%r12d
mov    %eax,0xc(%rsp)
cmovge %eax,%r12d
cmp    $0x3e6,%r15d
ja     1170 <main+0x30>
mov    $0x1,%ebx
mov    %r15d,%r13d
jmp    11cb <main+0x8b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    %r15d,%r13d
cmp    %ebx,%r12d
je     1170 <main+0x30>
mov    %r15d,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ebp
lea    0xe27(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%r14d
lea    0xe0d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebp,%r14d
lea    0xe22(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
call   1060 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    11c0 <main+0x80>
jp     11c0 <main+0x80>
mov    (%rsp),%rax
add    %ebx,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xda6(%rip),%xmm0
jne    11c0 <main+0x80>
jp     11c0 <main+0x80>
lea    0xda7(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ecx
lea    0xd90(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d +\00"
@.str.1 = [7 x i8] c" %d = \00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [22 x i8] c"%d + %d + %f = 1000!\0A\00"
@.str.4 = [15 x i8] c"%d*%d*%f = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call double @sqrt(i32 1000)
%11 = call double @llvm.floor.f64(double %10)
%12 = fptosi double %11 to i32
store i32 %12, i32* %5
store i32 1, i32* %2
br label %13
13: ; preds = %73, %0
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 1000
br i1 %15, label %16, label %76
16: ; preds = %13
store i32 1, i32* %3
br label %17
17: ; preds = %69, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = sub nsw i32 1000, %19
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %72
22: ; preds = %17
%23 = load i32, i32* %2
%24 = call i32 @pow(i32 %23, i32 2)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @pow(i32 %27, i32 2)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = add nsw i32 %31, %32
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %8
%37 = call double @sqrt(i32 %36)
store double %37, double* %4
%38 = load double, double* %4
%39 = call double @llvm.floor.f64(double %38)
%40 = load double, double* %4
%41 = fcmp oeq double %39, %40
br i1 %41, label %42, label %68
42: ; preds = %22
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = add nsw i32 %43, %44
%46 = sitofp i32 %45 to double
%47 = load double, double* %4
%48 = fadd double %46, %47
%49 = fcmp oeq double %48, 1.000000e+03
br i1 %49, label %50, label %67
50: ; preds = %42
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = load double, double* %4
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %52, double %53)
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = mul nsw i32 %55, %56
%58 = sitofp i32 %57 to double
%59 = load double, double* %4
%60 = fmul double %58, %59
%61 = fptosi double %60 to i32
store i32 %61, i32* %9
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = load double, double* %4
%65 = load i32, i32* %9
%66 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %62, i32 %63, double %64, i32 %65)
store i32 0, i32* %1
br label %76
67: ; preds = %42
br label %68
68: ; preds = %67, %22
br label %69
69: ; preds = %68
%70 = load i32, i32* %3
%71 = add nsw i32 %70, 1
store i32 %71, i32* %3
br label %17
72: ; preds = %17
br label %73
73: ; preds = %72
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %13
76: ; preds = %50, %13
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d +\00"
@.str.1 = [7 x i8] c" %d = \00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [22 x i8] c"%d + %d + %f = 1000!\0A\00"
@.str.4 = [15 x i8] c"%d*%d*%f = %d\0A\00"
define i32 @main() {
%1 = tail call double @sqrt(i32 1000)
br label %2
2: ; preds = %0, %33
%3 = phi i32 [ 999, %0 ], [ %35, %33 ]
%4 = phi i32 [ 1, %0 ], [ %34, %33 ]
%5 = call i32 @llvm.smax.i32(i32 %3, i32 2)
%6 = icmp ult i32 %4, 999
br i1 %6, label %7, label %33
7: ; preds = %2, %30
%8 = phi i32 [ %31, %30 ], [ 1, %2 ]
%9 = tail call i32 @pow(i32 %4, i32 2)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @pow(i32 %8, i32 2)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = add nsw i32 %11, %9
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = tail call double @sqrt(i32 %13)
%16 = tail call double @llvm.floor.f64(double %15)
%17 = fcmp oeq double %16, %15
br i1 %17, label %18, label %30
18: ; preds = %7
%19 = add nuw nsw i32 %8, %4
%20 = sitofp i32 %19 to double
%21 = fadd double %15, %20
%22 = fcmp oeq double %21, 1.000000e+03
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 %8, double %15)
%25 = mul nsw i32 %8, %4
%26 = sitofp i32 %25 to double
%27 = fmul double %15, %26
%28 = fptosi double %27 to i32
%29 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %4, i32 %8, double %15, i32 %28)
br label %37
30: ; preds = %7, %18
%31 = add nuw nsw i32 %8, 1
%32 = icmp eq i32 %31, %5
br i1 %32, label %33, label %7
33: ; preds = %30, %2
%34 = add nuw nsw i32 %4, 1
%35 = add nsw i32 %3, -1
%36 = icmp eq i32 %34, 1000
br i1 %36, label %37, label %2
37: ; preds = %33, %23
ret i32 0
}