#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(int);
int /*<<< orphan*/ printf(char *, int);
int problem004() {
  int i = 0;
  int j = 0;
  int max = 0;
  for (i = 999; i > 0; i--) {
    for (j = 999; j > 0; j--) {
      int tmp = i * j;
      if (isPalindrome(tmp) && tmp > max) {
        max = tmp;
        break;
      }
    }
  }
  printf("%d\n", max);
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x3e7,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11b8 <problem004+0x98>
movl   $0x3e7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a5 <problem004+0x85>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <isPalindrome@plt>
cmp    $0x0,%rax
je     1192 <problem004+0x72>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1192 <problem004+0x72>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11a5 <problem004+0x85>
jmp    1197 <problem004+0x77>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <problem004+0x35>
jmp    11aa <problem004+0x8a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1144 <problem004+0x24>
mov    -0xc(%rbp),%esi
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
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    %r15d,%r15d
mov    $0x3e7,%r12d
mov    $0xf3a71,%r14d
mov    $0xfffffc19,%r13d
jmp    116c <problem004+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%r15d
lea    -0x1(%r12),%eax
add    $0xfffffc19,%r14d
add    $0x1,%r13d
cmp    $0x1,%r12d
mov    %eax,%r12d
jbe    119e <problem004+0x7e>
mov    $0x3e8,%ebx
mov    %r14d,%ebp
jmp    118b <problem004+0x6b>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
add    %r13d,%ebp
cmp    $0x2,%ebx
jb     1153 <problem004+0x33>
mov    %ebp,%edi
call   1040 <isPalindrome@plt>
test   %rax,%rax
je     1180 <problem004+0x60>
cmp    %r15d,%ebp
jle    1180 <problem004+0x60>
jmp    1150 <problem004+0x30>
lea    0xe5b(%rip),%rdi
mov    %r15d,%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 = [4 x i8] c"%d\0A\00"
define i32 @problem004() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 999, i32* %1
br label %5
5: ; preds = %30, %0
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %5
store i32 999, i32* %2
br label %9
9: ; preds = %26, %8
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i64 @isPalindrome(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load i32, i32* %4
store i32 %24, i32* %3
br label %29
25: ; preds = %19, %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %2
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
br label %9
29: ; preds = %23, %9
br label %30
30: ; preds = %29
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
br label %5
33: ; preds = %5
%34 = load i32, i32* %3
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

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