#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ check_palindrome(unsigned long);
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double);
int main() {
  clock_t begin, end;
  double time_spent;
  begin = clock();
  unsigned long int m, n, flag = 0, largest;
  for (m = 999; m > 99; m--) {
    for (n = 999; n > 99; n--) {
      if (check_palindrome(m * n)) {
        if (!flag) {
          largest = m * n;
          flag = 1;
        } else
          largest = (largest > m * n) ? largest : m * n;
      }
    }
  }
  if (flag)
    printf("\nLargest Palindrome is %u", largest);
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("\n%G", time_spent);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x3e7,-0x28(%rbp)
cmpq   $0x63,-0x28(%rbp)
jbe    121e <main+0xee>
movq   $0x3e7,-0x30(%rbp)
cmpq   $0x63,-0x30(%rbp)
jbe    1208 <main+0xd8>
mov    -0x28(%rbp),%rdi
imul   -0x30(%rbp),%rdi
call   1050 <check_palindrome@plt>
cmp    $0x0,%rax
je     11f2 <main+0xc2>
cmpq   $0x0,-0x38(%rbp)
jne    11b5 <main+0x85>
mov    -0x28(%rbp),%rax
imul   -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x1,-0x38(%rbp)
jmp    11ed <main+0xbd>
mov    -0x40(%rbp),%rax
mov    -0x28(%rbp),%rcx
imul   -0x30(%rbp),%rcx
cmp    %rcx,%rax
jbe    11d8 <main+0xa8>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    11e5 <main+0xb5>
mov    -0x28(%rbp),%rax
imul   -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    11f2 <main+0xc2>
jmp    11f7 <main+0xc7>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    116d <main+0x3d>
jmp    120d <main+0xdd>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    115a <main+0x2a>
cmpq   $0x0,-0x38(%rbp)
je     125c <main+0x12c>
movaps 0xdd0(%rip),%xmm1
movq   -0x40(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdcf(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d6d(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xdaa(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,0x8(%rsp)
mov    $0x3e7,%eax
mov    $0xf3a71,%r13d
mov    $0xfffffffffffffc19,%rbp
jmp    118a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
add    $0xffffffffffffffff,%rax
add    $0xfffffffffffffc19,%r13
add    $0x1,%rbp
cmp    $0x63,%rax
jbe    11d7 <main+0xa7>
mov    %rax,0x10(%rsp)
mov    %r13,%rbx
mov    $0x3e7,%r15d
jmp    11ba <main+0x8a>
nopw   0x0(%rax,%rax,1)
cmp    %rbx,%r14
cmovbe %rbx,%r14
mov    $0x1,%r12d
add    $0xffffffffffffffff,%r15
add    %rbp,%rbx
cmp    $0x63,%r15
jbe    1170 <main+0x40>
mov    %rbx,%rdi
call   1050 <check_palindrome@plt>
test   %rax,%rax
je     11ad <main+0x7d>
test   %r12,%r12
jne    11a0 <main+0x70>
mov    $0x1,%r12d
mov    %rbx,%r14
jmp    11ad <main+0x7d>
test   %r12,%r12
je     1209 <main+0xd9>
movq   %r14,%xmm1
punpckldq 0xe17(%rip),%xmm1
subpd  0xe1f(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    0x8(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2dc4(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe0b(%rip),%rdi
call   1040 <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 = [26 x i8] c"\0ALargest Palindrome is %u\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [4 x i8] c"\0A%G\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i64 (...) @clock()
store i64 %9, i64* %2
store i64 0, i64* %7
store i64 999, i64* %5
br label %10
10: ; preds = %50, %0
%11 = load i64, i64* %5
%12 = icmp ugt i64 %11, 99
br i1 %12, label %13, label %53
13: ; preds = %10
store i64 999, i64* %6
br label %14
14: ; preds = %46, %13
%15 = load i64, i64* %6
%16 = icmp ugt i64 %15, 99
br i1 %16, label %17, label %49
17: ; preds = %14
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = mul i64 %18, %19
%21 = call i64 @check_palindrome(i64 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %45
23: ; preds = %17
%24 = load i64, i64* %7
%25 = icmp ne i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = load i64, i64* %5
%28 = load i64, i64* %6
%29 = mul i64 %27, %28
store i64 %29, i64* %8
store i64 1, i64* %7
br label %44
30: ; preds = %23
%31 = load i64, i64* %8
%32 = load i64, i64* %5
%33 = load i64, i64* %6
%34 = mul i64 %32, %33
%35 = icmp ugt i64 %31, %34
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = load i64, i64* %8
br label %42
38: ; preds = %30
%39 = load i64, i64* %5
%40 = load i64, i64* %6
%41 = mul i64 %39, %40
br label %42
42: ; preds = %38, %36
%43 = phi i64 [ %37, %36 ], [ %41, %38 ]
store i64 %43, i64* %8
br label %44
44: ; preds = %42, %26
br label %45
45: ; preds = %44, %17
br label %46
46: ; preds = %45
%47 = load i64, i64* %6
%48 = add i64 %47, -1
store i64 %48, i64* %6
br label %14
49: ; preds = %14
br label %50
50: ; preds = %49
%51 = load i64, i64* %5
%52 = add i64 %51, -1
store i64 %52, i64* %5
br label %10
53: ; preds = %10
%54 = load i64, i64* %7
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load i64, i64* %8
%58 = uitofp i64 %57 to double
%59 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %58)
br label %60
60: ; preds = %56, %53
%61 = call i64 (...) @clock()
store i64 %61, i64* %3
%62 = load i64, i64* %3
%63 = load i64, i64* %2
%64 = sub nsw i64 %62, %63
%65 = sitofp i64 %64 to double
%66 = load double, double* @CLOCKS_PER_SEC
%67 = fdiv double %65, %66
store double %67, double* %4
%68 = load double, double* %4
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0ALargest Palindrome is %u\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [4 x i8] c"\0A%G\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
br label %2
2: ; preds = %0, %23
%3 = phi i64 [ undef, %0 ], [ %20, %23 ]
%4 = phi i64 [ 0, %0 ], [ %19, %23 ]
%5 = phi i64 [ 999, %0 ], [ %24, %23 ]
br label %6
6: ; preds = %2, %18
%7 = phi i64 [ %3, %2 ], [ %20, %18 ]
%8 = phi i64 [ %4, %2 ], [ %19, %18 ]
%9 = phi i64 [ 999, %2 ], [ %21, %18 ]
%10 = mul nuw nsw i64 %9, %5
%11 = tail call i64 @check_palindrome(i64 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %6
%14 = icmp eq i64 %8, 0
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = icmp ugt i64 %7, %10
%17 = select i1 %16, i64 %7, i64 %10
br label %18
18: ; preds = %13, %6, %15
%19 = phi i64 [ 1, %15 ], [ %8, %6 ], [ 1, %13 ]
%20 = phi i64 [ %17, %15 ], [ %7, %6 ], [ %10, %13 ]
%21 = add nsw i64 %9, -1
%22 = icmp ugt i64 %21, 99
br i1 %22, label %6, label %23
23: ; preds = %18
%24 = add nsw i64 %5, -1
%25 = icmp ugt i64 %24, 99
br i1 %25, label %2, label %26
26: ; preds = %23
%27 = icmp eq i64 %19, 0
br i1 %27, label %31, label %28
28: ; preds = %26
%29 = uitofp i64 %20 to double
%30 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %29)
br label %31
31: ; preds = %28, %26
%32 = tail call i64 (...) @clock()
%33 = sub nsw i64 %32, %1
%34 = sitofp i64 %33 to double
%35 = load double, double* @CLOCKS_PER_SEC
%36 = fdiv double %34, %35
%37 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %36)
ret i32 0
}