#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 */
int EXIT_SUCCESS;
scalar_t__ isPalindrome(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  const int digits = 1e3;
  int i, j, product, largest = -1;
  for (i = digits; i > 0; i--) {
    for (j = digits; j > 0; j--) {
      product = i * j;
      if (isPalindrome(product) && product > largest) {
        largest = product;
      }
    }
  }
  printf("Solution: %d.\n", largest);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3e8,-0x14(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0x3e8,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11ba <main+0x9a>
movl   $0x3e8,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11a7 <main+0x87>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <isPalindrome@plt>
cmp    $0x0,%rax
je     1194 <main+0x74>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    1194 <main+0x74>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1199 <main+0x79>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <main+0x3c>
jmp    11ac <main+0x8c>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    114b <main+0x2b>
mov    -0x24(%rbp),%esi
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x3e8,%eax
mov    $0xffffffff,%ebx
mov    $0xf4240,%r14d
mov    $0xfffffc18,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rsp)
mov    $0x3e9,%r13d
mov    %r14d,%ebp
nopl   (%rax)
mov    %ebx,%r12d
mov    %ebp,%edi
call   1040 <isPalindrome@plt>
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
test   %rax,%rax
cmove  %r12d,%ebx
add    $0xffffffff,%r13d
add    %r15d,%ebp
cmp    $0x1,%r13d
ja     1160 <main+0x40>
mov    (%rsp),%rcx
lea    -0x1(%rcx),%eax
add    $0xfffffc18,%r14d
add    $0x1,%r15d
cmp    $0x1,%ecx
ja     1150 <main+0x30>
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Solution: %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%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 i32 1000, i32* %6
store i32 -1, i32* %10
store i32 1000, i32* %7
br label %11
11: ; preds = %36, %2
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %11
store i32 1000, i32* %8
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %8
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = mul nsw i32 %19, %20
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = call i64 @isPalindrome(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32, i32* %9
store i32 %30, i32* %10
br label %31
31: ; preds = %29, %25, %18
br label %32
32: ; preds = %31
%33 = load i32, i32* %8
%34 = add nsw i32 %33, -1
store i32 %34, i32* %8
br label %15
35: ; preds = %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, -1
store i32 %38, i32* %7
br label %11
39: ; preds = %11
%40 = load i32, i32* %10
%41 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@.str = [15 x i8] c"Solution: %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %17
%4 = phi i32 [ -1, %2 ], [ %14, %17 ]
%5 = phi i32 [ 1000, %2 ], [ %18, %17 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ %4, %3 ], [ %14, %6 ]
%8 = phi i32 [ 1000, %3 ], [ %15, %6 ]
%9 = mul nuw nsw i32 %8, %5
%10 = tail call i64 @isPalindrome(i32 %9)
%11 = icmp ne i64 %10, 0
%12 = icmp sgt i32 %9, %7
%13 = select i1 %11, i1 %12, i1 false
%14 = select i1 %13, i32 %9, i32 %7
%15 = add nsw i32 %8, -1
%16 = icmp ugt i32 %8, 1
br i1 %16, label %6, label %17
17: ; preds = %6
%18 = add nsw i32 %5, -1
%19 = icmp ugt i32 %5, 1
br i1 %19, label %3, label %20
20: ; preds = %17
%21 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %14)
%22 = load i32, i32* @EXIT_SUCCESS
ret i32 %22
}