#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();
int /*<<< orphan*/ printf(char *, ...);
unsigned long sqrt(unsigned long);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned long int counter = (285 + 1) / 2;
  unsigned long int square = 0, temp = 0, total = 0;
  start = clock();
  printf("Algorithm starts, please wait...\n");
  do {
    counter++;
    temp = 48 * counter * counter - 24 * counter + 1;
    square = sqrt(temp);
  } while ((square + 1) % 6 != 0 || square * square != temp);
  total = counter * (2 * counter - 1);
  end = clock();
  printf("Algorithm end.\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x8f,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
imul   $0x30,-0x28(%rbp),%rax
imul   -0x28(%rbp),%rax
imul   $0x18,-0x28(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <sqrt@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    $0x1,%al
cmp    $0x0,%rdx
mov    %al,-0x41(%rbp)
jne    11e7 <main+0xb7>
mov    -0x30(%rbp),%rax
imul   -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1180 <main+0x50>
mov    -0x28(%rbp),%rax
mov    -0x28(%rbp),%rcx
shl    $0x1,%rcx
sub    $0x1,%rcx
imul   %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2db3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdf2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    $0x90,%r14d
mov    $0x1ae8,%r15d
movabs $0xaaaaaaaaaaaaaaab,%r12
aa aa aa
movabs $0x2aaaaaaaaaaaaaaa,%r13
aa aa 2a
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rbx
imul   %r14,%rbx
or     $0x1,%rbx
mov    %rbx,%rdi
call   1060 <sqrt@plt>
mov    %rax,%rcx
imul   %r12,%rcx
add    %r12,%rcx
ror    %rcx
imul   %rax,%rax
add    $0x1,%r14
add    $0x30,%r15
cmp    %r13,%rcx
ja     1190 <main+0x50>
cmp    %rbx,%rax
jne    1190 <main+0x50>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2df8(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe05(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Algorithm starts, please wait...\0A\00"
@.str.1 = [16 x i8] c"Algorithm end.\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 i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 143, i64* %8
store i64 0, i64* %9
store i64 0, i64* %10
store i64 0, i64* %11
%12 = call double (...) @clock()
store double %12, double* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %38, %2
%15 = load i64, i64* %8
%16 = add i64 %15, 1
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = mul i64 48, %17
%19 = load i64, i64* %8
%20 = mul i64 %18, %19
%21 = load i64, i64* %8
%22 = mul i64 24, %21
%23 = sub i64 %20, %22
%24 = add i64 %23, 1
store i64 %24, i64* %10
%25 = load i64, i64* %10
%26 = call i64 @sqrt(i64 %25)
store i64 %26, i64* %9
br label %27
27: ; preds = %14
%28 = load i64, i64* %9
%29 = add i64 %28, 1
%30 = urem i64 %29, 6
%31 = icmp ne i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %27
%33 = load i64, i64* %9
%34 = load i64, i64* %9
%35 = mul i64 %33, %34
%36 = load i64, i64* %10
%37 = icmp ne i64 %35, %36
br label %38
38: ; preds = %32, %27
%39 = phi i1 [ true, %27 ], [ %37, %32 ]
br i1 %39, label %14, label %40
40: ; preds = %38
%41 = load i64, i64* %8
%42 = load i64, i64* %8
%43 = mul i64 2, %42
%44 = sub i64 %43, 1
%45 = mul i64 %41, %44
store i64 %45, i64* %11
%46 = call double (...) @clock()
store double %46, double* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%48 = load double, double* %7
%49 = load double, double* %6
%50 = fsub double %48, %49
%51 = load double, double* @CLOCKS_PER_SEC
%52 = fdiv double %50, %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %52)
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 = [15 x i8] c"Algorithm end.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call double (...) @clock()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ 143, %2 ], [ %7, %5 ]
%7 = add i64 %6, 1
%8 = mul i64 %7, 48
%9 = add i64 %8, -24
%10 = mul i64 %9, %7
%11 = or i64 %10, 1
%12 = tail call i64 @sqrt(i64 %11)
%13 = add i64 %12, 1
%14 = urem i64 %13, 6
%15 = icmp eq i64 %14, 0
%16 = mul i64 %12, %12
%17 = icmp eq i64 %16, %11
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %19, label %5
19: ; preds = %5
%20 = tail call double (...) @clock()
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%22 = fsub double %20, %3
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %24)
ret i32 0
}