#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 /*<<< orphan*/ isPalindrome(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  const int kMin = 100;
  const int kMax = 999;
  int a, b, max;
  a = b = kMin;
  max = 0;
  for (int a = kMin; a <= kMax; ++a) {
    for (int b = a; b <= kMax; ++b) {
      int n = a * b;
      if (!isPalindrome(n))
        continue;
      max = max < n ? n : max;
    }
  }
  printf("Largest palindrome is %d\n", max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movl   $0x3e7,-0xc(%rbp)
movl   $0x64,-0x14(%rbp)
movl   $0x64,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x64,-0x1c(%rbp)
cmpl   $0x3e7,-0x1c(%rbp)
jg     11dd <main+0xbd>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x3e7,-0x20(%rbp)
jg     11ca <main+0xaa>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <isPalindrome@plt>
cmp    $0x0,%eax
jne    1199 <main+0x79>
jmp    11bc <main+0x9c>
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b0 <main+0x90>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11b6 <main+0x96>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116c <main+0x4c>
jmp    11cf <main+0xaf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <main+0x39>
mov    -0x18(%rbp),%esi
lea    0xe19(%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
push   %rax
xor    %ebx,%ebx
mov    $0x64,%r14d
mov    $0x384,%r15d
mov    $0xc9,%eax
mov    $0x2710,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,(%rsp)
mov    %r13d,%ebp
mov    %r15d,0x4(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r12d
mov    %ebp,%edi
call   1040 <isPalindrome@plt>
cmp    %ebp,%ebx
cmovl  %ebp,%ebx
test   %eax,%eax
cmove  %r12d,%ebx
add    %r14d,%ebp
add    $0xffffffff,%r15d
jne    1160 <main+0x40>
add    $0x1,%r14d
mov    0x4(%rsp),%r15d
add    $0xffffffff,%r15d
mov    (%rsp),%eax
add    %eax,%r13d
add    $0x2,%eax
cmp    $0x3e8,%r14d
jne    1150 <main+0x30>
lea    0xe5c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"Largest palindrome is %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %6, %0
%2 = phi i32 [ 100, %0 ], [ %7, %6 ]
%3 = phi i32 [ 0, %0 ], [ %17, %6 ]
br label %9
4: ; preds = %6
%5 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
6: ; preds = %9
%7 = add nuw nsw i32 %2, 1
%8 = icmp eq i32 %7, 1000
br i1 %8, label %4, label %1
9: ; preds = %1, %9
%10 = phi i32 [ %18, %9 ], [ %2, %1 ]
%11 = phi i32 [ %17, %9 ], [ %3, %1 ]
%12 = mul nsw i32 %10, %2
%13 = tail call i32 @isPalindrome(i32 %12)
%14 = icmp eq i32 %13, 0
%15 = icmp slt i32 %11, %12
%16 = select i1 %15, i32 %12, i32 %11
%17 = select i1 %14, i32 %11, i32 %16
%18 = add nuw nsw i32 %10, 1
%19 = icmp eq i32 %18, 1000
br i1 %19, label %6, label %9
}