#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);
void problem_004(void) {
  int largest_palindrome = 0;
  int product;
  int j, k;
  for (j = 999; j >= 100; j--) {
    for (k = 999; k >= 100; k--) {
      product = j * k;
      if (product <= largest_palindrome) {
        break;
      } else if (is_palindrome(product)) {
        largest_palindrome = product;
      }
    }
  }
  printf("%i", largest_palindrome);
  return;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e7,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jl     11af <problem_004+0x8f>
movl   $0x3e7,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jl     119c <problem_004+0x7c>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     116c <problem_004+0x4c>
jmp    119c <problem_004+0x7c>
mov    -0x8(%rbp),%edi
call   1030 <is_palindrome@plt>
cmp    $0x0,%rax
je     1184 <problem_004+0x64>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <problem_004+0x69>
jmp    118e <problem_004+0x6e>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1147 <problem_004+0x27>
jmp    11a1 <problem_004+0x81>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <problem_004+0x16>
mov    -0x4(%rbp),%esi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r13d,%r13d
mov    $0x3e7,%r12d
mov    $0xf3a71,%r14d
mov    $0xfffffc19,%r15d
jmp    1169 <problem_004+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x1(%r12),%eax
add    $0xfffffc19,%r14d
add    $0x1,%r15d
cmp    $0x64,%r12d
mov    %eax,%r12d
jbe    11a0 <problem_004+0x80>
mov    $0x3e8,%ebx
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %r13d,%ebp
jle    1150 <problem_004+0x30>
mov    %ebp,%edi
call   1030 <is_palindrome@plt>
test   %rax,%rax
cmovne %ebp,%r13d
add    $0xffffffff,%ebx
add    %r15d,%ebp
cmp    $0x64,%ebx
ja     1180 <problem_004+0x60>
jmp    1150 <problem_004+0x30>
lea    0xe59(%rip),%rdi
mov    %r13d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define void @problem_004() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 999, i32* %3
br label %5
5: ; preds = %32, %0
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 100
br i1 %7, label %8, label %35
8: ; preds = %5
store i32 999, i32* %4
br label %9
9: ; preds = %28, %8
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 100
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %12
br label %31
20: ; preds = %12
%21 = load i32, i32* %2
%22 = call i64 @is_palindrome(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* %2
store i32 %25, i32* %1
br label %26
26: ; preds = %24, %20
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %9
31: ; preds = %19, %9
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %5
35: ; preds = %5
%36 = load i32, i32* %1
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define void @problem_004() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 999, %0 ], [ %17, %15 ]
%3 = phi i32 [ 0, %0 ], [ %16, %15 ]
br label %4
4: ; preds = %1, %9
%5 = phi i32 [ 999, %1 ], [ %13, %9 ]
%6 = phi i32 [ %3, %1 ], [ %12, %9 ]
%7 = mul nuw nsw i32 %5, %2
%8 = icmp sgt i32 %7, %6
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = tail call i64 @is_palindrome(i32 %7)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 %6, i32 %7
%13 = add nsw i32 %5, -1
%14 = icmp ugt i32 %5, 100
br i1 %14, label %4, label %15
15: ; preds = %9, %4
%16 = phi i32 [ %12, %9 ], [ %6, %4 ]
%17 = add nsw i32 %2, -1
%18 = icmp ugt i32 %2, 100
br i1 %18, label %1, label %19
19: ; preds = %15
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
ret void
}