#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 CLOCKS_PER_SEC;
double clock();
scalar_t__ pow(unsigned int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end = 0;
  printf("Algorithm starts... Please wait.\n");
  start = clock();
  unsigned int a, b, c = 0;
  for (a = 1; a <= 1000; a++) {
    for (b = (a + 1); b <= (1000 - a); b++) {
      c = (1000 - a - b);
      if ((pow(a, 2) + pow(b, 2) == pow(c, 2))) {
        break;
      }
    }
  }
  end = clock();
  printf("Algorithm terminated\n");
  printf("Total Time: %f\n", (end - start) / CLOCKS_PER_SEC);
  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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
ja     1221 <main+0xf1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
ja     120e <main+0xde>
mov    $0x3e8,%eax
sub    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jne    11fb <main+0xcb>
jmp    120e <main+0xde>
jmp    1200 <main+0xd0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118c <main+0x5c>
jmp    1213 <main+0xe3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1176 <main+0x46>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2d9c(%rip),%rax
divsd  (%rax),%xmm0
lea    0xde1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%eax
movl   $0x3e5,0x4(%rsp)
jmp    1190 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
addl   $0xfffffffe,0x4(%rsp)
mov    0x8(%rsp),%eax
cmp    $0x3e9,%eax
je     1209 <main+0xc9>
mov    %eax,%r14d
lea    0x1(%r14),%eax
mov    %eax,0x8(%rsp)
mov    $0x3e8,%r13d
sub    %r14d,%r13d
cmp    %r14d,%r13d
jbe    1180 <main+0x40>
mov    0x4(%rsp),%ebp
mov    0x8(%rsp),%eax
mov    %eax,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %rax,%r15
mov    %r12d,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
add    %r15,%rbx
mov    %ebp,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
cmp    %rax,%rbx
je     1180 <main+0x40>
lea    0x1(%r12),%eax
add    $0xffffffff,%ebp
cmp    %r12d,%r13d
mov    %eax,%r12d
ja     11c0 <main+0x80>
jmp    1180 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x2db3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdc0(%rip),%rdi
mov    $0x1,%al
call   1050 <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 = [34 x i8] c"Algorithm starts... Please wait.\0A\00"
@.str.1 = [22 x i8] c"Algorithm terminated\0A\00"
@.str.2 = [16 x i8] c"Total Time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%12 = call double (...) @clock()
store double %12, double* %6
store i32 0, i32* %10
store i32 1, i32* %8
br label %13
13: ; preds = %43, %2
%14 = load i32, i32* %8
%15 = icmp ule i32 %14, 1000
br i1 %15, label %16, label %46
16: ; preds = %13
%17 = load i32, i32* %8
%18 = add i32 %17, 1
store i32 %18, i32* %9
br label %19
19: ; preds = %39, %16
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = sub i32 1000, %21
%23 = icmp ule i32 %20, %22
br i1 %23, label %24, label %42
24: ; preds = %19
%25 = load i32, i32* %8
%26 = sub i32 1000, %25
%27 = load i32, i32* %9
%28 = sub i32 %26, %27
store i32 %28, i32* %10
%29 = load i32, i32* %8
%30 = call i64 @pow(i32 %29, i32 2)
%31 = load i32, i32* %9
%32 = call i64 @pow(i32 %31, i32 2)
%33 = add nsw i64 %30, %32
%34 = load i32, i32* %10
%35 = call i64 @pow(i32 %34, i32 2)
%36 = icmp eq i64 %33, %35
br i1 %36, label %37, label %38
37: ; preds = %24
br label %42
38: ; preds = %24
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %19
42: ; preds = %37, %19
br label %43
43: ; preds = %42
%44 = load i32, i32* %8
%45 = add i32 %44, 1
store i32 %45, i32* %8
br label %13
46: ; preds = %13
%47 = call double (...) @clock()
store double %47, double* %7
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%49 = load double, double* %7
%50 = load double, double* %6
%51 = fsub double %49, %50
%52 = load double, double* @CLOCKS_PER_SEC
%53 = fdiv double %51, %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %53)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"Total Time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [33 x i8] c"Algorithm starts... Please wait.\00"
@str.3 = [21 x i8] c"Algorithm terminated\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
br label %5
5: ; preds = %2, %21
%6 = phi i32 [ 1, %2 ], [ %7, %21 ]
%7 = add nuw nsw i32 %6, 1
%8 = sub nuw nsw i32 1000, %6
%9 = icmp ugt i32 %8, %6
br i1 %9, label %10, label %21
10: ; preds = %5, %10
%11 = phi i32 [ %18, %10 ], [ %7, %5 ]
%12 = sub nsw i32 %8, %11
%13 = tail call i64 @pow(i32 %6, i32 2)
%14 = tail call i64 @pow(i32 %11, i32 2)
%15 = add nsw i64 %14, %13
%16 = tail call i64 @pow(i32 %12, i32 2)
%17 = icmp eq i64 %15, %16
%18 = add nuw nsw i32 %11, 1
%19 = icmp ule i32 %8, %11
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %21, label %10
21: ; preds = %10, %5
%22 = icmp eq i32 %7, 1001
br i1 %22, label %23, label %5
23: ; preds = %21
%24 = tail call double (...) @clock()
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.3, i64 0, i64 0))
%26 = fsub double %24, %4
%27 = load double, double* @CLOCKS_PER_SEC
%28 = fdiv double %26, %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %28)
ret i32 0
}