#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__ palindromeTest(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long);
int Problem004(void) {
  unsigned long int inner, outer, product;
  unsigned long int biggest = 0;
  for (outer = 999; outer > 0; outer--) {
    for (inner = 999; inner > outer; inner--) {
      product = inner * outer;
      if (palindromeTest(product)) {
        biggest = (product > biggest) ? product : biggest;
      }
    }
  }
  printf("%30lu", biggest);
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x20(%rbp)
movq   $0x3e7,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11d0 <Problem004+0xb0>
movq   $0x3e7,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    11ba <Problem004+0x9a>
mov    -0x8(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <palindromeTest@plt>
cmp    $0x0,%rax
je     11a4 <Problem004+0x84>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1194 <Problem004+0x74>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    119c <Problem004+0x7c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11a9 <Problem004+0x89>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
jmp    114b <Problem004+0x2b>
jmp    11bf <Problem004+0x9f>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <Problem004+0x18>
mov    -0x20(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x3e7,%r15d
mov    $0xf3a71,%r12d
mov    $0xfffffffffffffc19,%r13
xor    %r14d,%r14d
jmp    1161 <Problem004+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xfffffffffffffc19,%r12
add    $0x1,%r13
add    $0xffffffffffffffff,%r15
je     11a7 <Problem004+0x87>
cmp    $0x3e6,%r15
ja     1150 <Problem004+0x30>
mov    $0x3e7,%ebp
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <palindromeTest@plt>
cmp    %r14,%rbx
mov    %r14,%rcx
cmova  %rbx,%rcx
test   %rax,%rax
cmovne %rcx,%r14
add    $0xffffffffffffffff,%rbp
add    %r13,%rbx
cmp    %r15,%rbp
ja     1180 <Problem004+0x60>
jmp    1150 <Problem004+0x30>
lea    0xe52(%rip),%rdi
mov    %r14,%rsi
call   1040 <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 = [6 x i8] c"%30lu\00"
define i32 @Problem004() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 0, i64* %4
store i64 999, i64* %2
br label %5
5: ; preds = %35, %0
%6 = load i64, i64* %2
%7 = icmp ugt i64 %6, 0
br i1 %7, label %8, label %38
8: ; preds = %5
store i64 999, i64* %1
br label %9
9: ; preds = %31, %8
%10 = load i64, i64* %1
%11 = load i64, i64* %2
%12 = icmp ugt i64 %10, %11
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i64, i64* %1
%15 = load i64, i64* %2
%16 = mul i64 %14, %15
store i64 %16, i64* %3
%17 = load i64, i64* %3
%18 = call i64 @palindromeTest(i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %13
%21 = load i64, i64* %3
%22 = load i64, i64* %4
%23 = icmp ugt i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i64, i64* %3
br label %28
26: ; preds = %20
%27 = load i64, i64* %4
br label %28
28: ; preds = %26, %24
%29 = phi i64 [ %25, %24 ], [ %27, %26 ]
store i64 %29, i64* %4
br label %30
30: ; preds = %28, %13
br label %31
31: ; preds = %30
%32 = load i64, i64* %1
%33 = add i64 %32, -1
store i64 %33, i64* %1
br label %9
34: ; preds = %9
br label %35
35: ; preds = %34
%36 = load i64, i64* %2
%37 = add i64 %36, -1
store i64 %37, i64* %2
br label %5
38: ; preds = %5
%39 = load i64, i64* %4
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %39)
ret i32 0
}

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