#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 */
scalar_t__ isPalindrome(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(void) {
  unsigned int n, m, max = 0;
  for (n = 100; n <= 999; n++) {
    for (m = 100; m <= 999; m++) {
      unsigned int p = n * m;
      if (isPalindrome(p) && p > max) {
        max = p;
      }
    }
  }
  printf("Largest palindrome is: %d\n", max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x64,-0x8(%rbp)
cmpl   $0x3e7,-0x8(%rbp)
ja     11b2 <main+0x92>
movl   $0x64,-0xc(%rbp)
cmpl   $0x3e7,-0xc(%rbp)
ja     119f <main+0x7f>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <isPalindrome@plt>
cmp    $0x0,%rax
je     118c <main+0x6c>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jbe    118c <main+0x6c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <main+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <main+0x31>
jmp    11a4 <main+0x84>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0x10(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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    $0x2710,%r15d
nopl   0x0(%rax)
mov    $0x384,%r12d
mov    %r15d,%ebp
nopl   0x0(%rax)
mov    %ebx,%r13d
mov    %ebp,%edi
call   1040 <isPalindrome@plt>
cmp    %ebx,%ebp
cmova  %ebp,%ebx
test   %rax,%rax
cmove  %r13d,%ebx
add    %r14d,%ebp
add    $0xffffffff,%r12d
jne    1150 <main+0x30>
add    $0x1,%r14d
add    $0x64,%r15d
cmp    $0x3e8,%r14d
jne    1140 <main+0x20>
lea    0xe79(%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 = [27 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
store i32 0, i32* %1
store i32 0, i32* %4
store i32 100, i32* %2
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %2
%8 = icmp ule i32 %7, 999
br i1 %8, label %9, label %34
9: ; preds = %6
store i32 100, i32* %3
br label %10
10: ; preds = %27, %9
%11 = load i32, i32* %3
%12 = icmp ule i32 %11, 999
br i1 %12, label %13, label %30
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = mul i32 %14, %15
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = call i64 @isPalindrome(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %13
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp ugt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* %5
store i32 %25, i32* %4
br label %26
26: ; preds = %24, %20, %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add i32 %28, 1
store i32 %29, i32* %3
br label %10
30: ; preds = %10
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add i32 %32, 1
store i32 %33, i32* %2
br label %6
34: ; preds = %6
%35 = load i32, i32* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %35)
ret i32 0
}

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