#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 reverse_number(int);
int largest_palindrome() {
  int i;
  int largest_prod = 0;
  for (i = 999; i > 99; i--) {
    int j;
    for (j = 999; j > 99; j--) {
      int prod = i * j;
      if (prod == reverse_number(prod) && prod > largest_prod)
        largest_prod = prod;
    }
  }
  return largest_prod;
}


x86 assembly (clang, -O0):
<largest_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x3e7,-0x4(%rbp)
cmpl   $0x63,-0x4(%rbp)
jle    119e <largest_palindrome+0x8e>
movl   $0x3e7,-0xc(%rbp)
cmpl   $0x63,-0xc(%rbp)
jle    118b <largest_palindrome+0x7b>
mov    -0x4(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <reverse_number@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jne    1178 <largest_palindrome+0x68>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1178 <largest_palindrome+0x68>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    117d <largest_palindrome+0x6d>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1137 <largest_palindrome+0x27>
jmp    1190 <largest_palindrome+0x80>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1126 <largest_palindrome+0x16>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<largest_palindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0x3e7,%eax
mov    $0xf3a71,%r14d
mov    $0xfffffc19,%r15d
xchg   %ax,%ax
mov    %rax,(%rsp)
mov    $0x3e8,%r13d
mov    %r14d,%ebp
nopl   (%rax)
mov    %ebx,%r12d
mov    %ebp,%edi
call   1030 <reverse_number@plt>
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
cmp    %eax,%ebp
cmovne %r12d,%ebx
add    $0xffffffff,%r13d
add    %r15d,%ebp
cmp    $0x64,%r13d
ja     1140 <largest_palindrome+0x30>
mov    (%rsp),%rcx
lea    -0x1(%rcx),%eax
add    $0xfffffc19,%r14d
add    $0x1,%r15d
cmp    $0x64,%ecx
ja     1130 <largest_palindrome+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @largest_palindrome() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %2
store i32 999, i32* %1
br label %5
5: ; preds = %31, %0
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 99
br i1 %7, label %8, label %34
8: ; preds = %5
store i32 999, i32* %3
br label %9
9: ; preds = %27, %8
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 99
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %1
%14 = load i32, i32* %3
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = load i32, i32* %4
%18 = call i32 @reverse_number(i32 %17)
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %26
20: ; preds = %12
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* %4
store i32 %25, i32* %2
br label %26
26: ; preds = %24, %20, %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, -1
store i32 %29, i32* %3
br label %9
30: ; preds = %9
br label %31
31: ; preds = %30
%32 = load i32, i32* %1
%33 = add nsw i32 %32, -1
store i32 %33, i32* %1
br label %5
34: ; preds = %5
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @largest_palindrome() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 999, %0 ], [ %16, %15 ]
%3 = phi i32 [ 0, %0 ], [ %12, %15 ]
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 999, %1 ], [ %13, %4 ]
%6 = phi i32 [ %3, %1 ], [ %12, %4 ]
%7 = mul nuw nsw i32 %5, %2
%8 = tail call i32 @reverse_number(i32 %7)
%9 = icmp eq i32 %7, %8
%10 = icmp sgt i32 %7, %6
%11 = select i1 %9, i1 %10, i1 false
%12 = select i1 %11, i32 %7, i32 %6
%13 = add nsw i32 %5, -1
%14 = icmp ugt i32 %5, 100
br i1 %14, label %4, label %15
15: ; preds = %4
%16 = add nsw i32 %2, -1
%17 = icmp ugt i32 %2, 100
br i1 %17, label %1, label %18
18: ; preds = %15
ret i32 %12
}