#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__ pow(float, int);
int /*<<< orphan*/ printf(char *, float);
float sqrt(scalar_t__);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  float a, b, c;
  float stop;
  for (a = 1, b = 2; a <= 3000; a++, b = (a + 1)) {
    for (; b < 3000; b++) {
      c = a + b + sqrt(pow(a, 2) + pow(b, 2));
      if (c == 1000) {
        c = a * b * sqrt(pow(a, 2) + pow(b, 2));
        goto found_triplet;
      } else if (c > 1000) {
        break;
      }
    }
  }
found_triplet:
  stop = timeit();
  printf("Answer: %ld\n", (long)c);
  printf("Time: %.8f\n", stop - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movss  0xe9a(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe89(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe84(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jb     12cc <main+0x18c>
jmp    1193 <main+0x53>
movss  0xe6d(%rip),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    129e <main+0x15e>
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xe0c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1262 <main+0x122>
jp     1262 <main+0x122>
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,-0x40(%rbp)
movss  -0x1c(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    12d1 <main+0x191>
movss  -0x20(%rbp),%xmm0
movss  0xd9d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    127d <main+0x13d>
jmp    129e <main+0x15e>
jmp    1282 <main+0x142>
jmp    1287 <main+0x147>
movss  0xd75(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1193 <main+0x53>
jmp    12a3 <main+0x163>
movss  0xd59(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xd47(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    117c <main+0x3c>
jmp    12d1 <main+0x191>
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x24(%rbp)
cvttss2si -0x20(%rbp),%rax
cvtsi2ss %rax,%xmm0
lea    0xd21(%rip),%rdi
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xd18(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0xc(%rsp)
movss  0xea6(%rip),%xmm1
movss  0xea2(%rip),%xmm0
movss  0xe9e(%rip),%xmm3
movss  %xmm0,0x4(%rsp)
jmp    11a0 <main+0x60>
movss  0x4(%rsp),%xmm0
movss  0xe84(%rip),%xmm2
addss  %xmm2,%xmm0
movaps %xmm0,%xmm1
addss  %xmm2,%xmm1
movss  %xmm0,0x4(%rsp)
ucomiss %xmm0,%xmm3
jb     125f <main+0x11f>
nopw   0x0(%rax,%rax,1)
ucomiss %xmm1,%xmm3
jbe    1172 <main+0x32>
movss  %xmm1,(%rsp)
movss  0x4(%rsp),%xmm0
movaps %xmm0,%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,0x8(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,%rbx
movss  (%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm4
addss  0x8(%rsp),%xmm4
movss  0xe17(%rip),%xmm0
ucomiss %xmm0,%xmm4
jne    11fc <main+0xbc>
jnp    121b <main+0xdb>
ucomiss %xmm0,%xmm4
movss  (%rsp),%xmm1
addss  0xdf8(%rip),%xmm1
movss  0xdf4(%rip),%xmm3
jbe    11a0 <main+0x60>
jmp    1172 <main+0x32>
movss  0x4(%rsp),%xmm0
movaps %xmm0,%xmm1
mulss  (%rsp),%xmm1
movss  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,%rbx
movss  (%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm4
mulss  0x8(%rsp),%xmm4
movss  %xmm4,(%rsp)
xor    %eax,%eax
call   1050 <timeit@plt>
cvttss2si (%rsp),%rax
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
lea    0xd8b(%rip),%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
subss  0xc(%rsp),%xmm0
lea    0xd81(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
br label %4
4: ; preds = %2, %30
%5 = phi float [ 1.000000e+00, %2 ], [ %32, %30 ]
%6 = phi float [ undef, %2 ], [ %31, %30 ]
%7 = phi float [ 2.000000e+00, %2 ], [ %33, %30 ]
%8 = fcmp olt float %7, 3.000000e+03
br i1 %8, label %9, label %30
9: ; preds = %4, %25
%10 = phi float [ %27, %25 ], [ %7, %4 ]
%11 = fadd float %5, %10
%12 = tail call i64 @pow(float %5, i32 2)
%13 = tail call i64 @pow(float %10, i32 2)
%14 = add nsw i64 %13, %12
%15 = tail call float @sqrt(i64 %14)
%16 = fadd float %11, %15
%17 = fcmp oeq float %16, 1.000000e+03
br i1 %17, label %18, label %25
18: ; preds = %9
%19 = fmul float %5, %10
%20 = tail call i64 @pow(float %5, i32 2)
%21 = tail call i64 @pow(float %10, i32 2)
%22 = add nsw i64 %21, %20
%23 = tail call float @sqrt(i64 %22)
%24 = fmul float %19, %23
br label %35
25: ; preds = %9
%26 = fcmp ule float %16, 1.000000e+03
%27 = fadd float %10, 1.000000e+00
%28 = fcmp olt float %27, 3.000000e+03
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %9, label %30
30: ; preds = %25, %4
%31 = phi float [ %6, %4 ], [ %16, %25 ]
%32 = fadd float %5, 1.000000e+00
%33 = fadd float %32, 1.000000e+00
%34 = fcmp ugt float %32, 3.000000e+03
br i1 %34, label %35, label %4
35: ; preds = %30, %18
%36 = phi float [ %24, %18 ], [ %31, %30 ]
%37 = tail call float (...) @timeit()
%38 = fptosi float %36 to i64
%39 = sitofp i64 %38 to float
%40 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %39)
%41 = fsub float %37, %3
%42 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %41)
ret i32 0
}