#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 */
struct timeval {
  long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ isPalindrome(long);
int /*<<< orphan*/ printf(char *, long);
int main(void) {
  struct timeval stop, start;
  gettimeofday(&start, NULL);
  long result, palindrome = 0;
  int i, j;
  for (i = 100; i <= 999; i++) {
    for (j = i; j <= 999; j++) {
      result = i * j;
      if (isPalindrome(result) && result > palindrome) {
        palindrome = result;
      }
    }
  }
  printf("%lu", palindrome);
  gettimeofday(&stop, NULL);
  printf("\ntook %lu usec\n", stop.tv_usec - start.tv_usec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x64,-0x2c(%rbp)
cmpl   $0x3e7,-0x2c(%rbp)
jg     11d7 <main+0xa7>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x3e7,-0x30(%rbp)
jg     11c4 <main+0x94>
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <isPalindrome@plt>
cmp    $0x0,%rax
je     11b1 <main+0x81>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    11b1 <main+0x81>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11b6 <main+0x86>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    116e <main+0x3e>
jmp    11c9 <main+0x99>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <main+0x2b>
mov    -0x28(%rbp),%rsi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x10(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%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    $0x28,%rsp
xor    %ebx,%ebx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x64,%r14d
mov    $0xc9,%eax
mov    $0x2710,%r12d
mov    $0x384,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,0x10(%rsp)
mov    %r13,%rbp
mov    %r12,0x8(%rsp)
nopl   (%rax)
mov    %rbx,%r15
mov    %r12d,%ebx
mov    %rbx,%rdi
call   1050 <isPalindrome@plt>
cmp    %rbx,%r15
cmovge %r15,%rbx
test   %rax,%rax
cmove  %r15,%rbx
add    %r14,%r12
add    $0xffffffffffffffff,%rbp
jne    1180 <main+0x50>
add    $0x1,%r14
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%r12
add    %rax,%r12
add    $0x2,%rax
add    $0xffffffffffffffff,%r13
cmp    $0x3e8,%r14
jne    1170 <main+0x40>
lea    0xe32(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x20(%rsp),%rsi
sub    0x18(%rsp),%rsi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.str = [4 x i8] c"%lu\00"
@.str.1 = [16 x i8] c"\0Atook %lu usec\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i64 0, i64* %5
store i32 100, i32* %6
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 999
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = load i32, i32* %6
store i32 %13, i32* %7
br label %14
14: ; preds = %32, %12
%15 = load i32, i32* %7
%16 = icmp sle i32 %15, 999
br i1 %16, label %17, label %35
17: ; preds = %14
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = mul nsw i32 %18, %19
%21 = sext i32 %20 to i64
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = call i64 @isPalindrome(i64 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %17
%26 = load i64, i64* %4
%27 = load i64, i64* %5
%28 = icmp sgt i64 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i64, i64* %4
store i64 %30, i64* %5
br label %31
31: ; preds = %29, %25, %17
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %14
35: ; preds = %14
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %9
39: ; preds = %9
%40 = load i64, i64* %5
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %40)
%42 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%44 = load i64, i64* %43
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%46 = load i64, i64* %45
%47 = sub nsw i64 %44, %46
%48 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 %47)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.str = [4 x i8] c"%lu\00"
@.str.1 = [16 x i8] c"\0Atook %lu usec\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
br label %6
6: ; preds = %21, %0
%7 = phi i64 [ 100, %0 ], [ %22, %21 ]
%8 = phi i64 [ 0, %0 ], [ %18, %21 ]
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ %7, %6 ], [ %19, %9 ]
%11 = phi i64 [ %8, %6 ], [ %18, %9 ]
%12 = mul i64 %10, %7
%13 = and i64 %12, 4294967295
%14 = tail call i64 @isPalindrome(i64 %13)
%15 = icmp ne i64 %14, 0
%16 = icmp slt i64 %11, %13
%17 = select i1 %15, i1 %16, i1 false
%18 = select i1 %17, i64 %13, i64 %11
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, 1000
br i1 %20, label %21, label %9
21: ; preds = %9
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, 1000
br i1 %23, label %24, label %6
24: ; preds = %21
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %18)
%26 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%30 = load i64, i64* %29
%31 = sub nsw i64 %28, %30
%32 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 %31)
ret i32 0
}