#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__ is_palindrome(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int max = 0;
  for (int x = 100; x < 1000; x++) {
    for (int y = 100; y < 1000; y++) {
      if (x * y > max && is_palindrome(x * y))
        max = x * y;
    }
  }
  printf("The largest palindrome product of two three-digit numbers is %d\n",
         max);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    11b4 <main+0x94>
movl   $0x64,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11a1 <main+0x81>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    118e <main+0x6e>
mov    -0xc(%rbp),%edi
imul   -0x10(%rbp),%edi
call   1030 <is_palindrome@plt>
cmp    $0x0,%rax
je     118e <main+0x6e>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1193 <main+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <main+0x31>
jmp    11a6 <main+0x86>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
mov    -0x8(%rbp),%esi
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r12d,%r12d
mov    $0x64,%r14d
mov    $0x2710,%r15d
jmp    1151 <main+0x31>
nopl   0x0(%rax)
add    $0x1,%r14d
add    $0x64,%r15d
cmp    $0x3e8,%r14d
je     117d <main+0x5d>
mov    $0x384,%ebx
mov    %r15d,%ebp
jmp    1168 <main+0x48>
nopl   0x0(%rax,%rax,1)
add    %r14d,%ebp
add    $0xffffffff,%ebx
je     1140 <main+0x20>
cmp    %r12d,%ebp
jle    1160 <main+0x40>
mov    %ebp,%edi
call   1030 <is_palindrome@plt>
test   %rax,%rax
cmovne %ebp,%r12d
jmp    1160 <main+0x40>
lea    0xe7c(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"The largest palindrome product of two three-digit numbers is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 100, i32* %3
br label %5
5: ; preds = %33, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1000
br i1 %7, label %8, label %36
8: ; preds = %5
store i32 100, i32* %4
br label %9
9: ; preds = %29, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1000
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = load i32, i32* %2
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = mul nsw i32 %19, %20
%22 = call i64 @is_palindrome(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = mul nsw i32 %25, %26
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %18, %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %9
32: ; preds = %9
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %5
36: ; preds = %5
%37 = load i32, i32* %2
%38 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %1
ret i32 %39
}

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