#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 pow(int, int);
int /*<<< orphan*/ printf(char *);
int reverse(int);
int main(int argc, char **argv) {
  printf("Algorithm start, please wait...\n");
  int palindrome = 0, size = (pow(10, 3) - 1), solver = 0;
  for (int i = size; i > 0; i--) {
    for (int j = size; j > 0; j--) {
      solver = i * j;
      if ((solver > palindrome) && (reverse(solver) == solver)) {
        palindrome = solver;
      }
    }
  }
  printf("Algorithm finish.");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1050 <pow@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11e8 <main+0xb8>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11d5 <main+0xa5>
mov    -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11c2 <main+0x92>
mov    -0x1c(%rbp),%edi
call   1030 <reverse@plt>
cmp    -0x1c(%rbp),%eax
jne    11c2 <main+0x92>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c7 <main+0x97>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    118b <main+0x5b>
jmp    11da <main+0xaa>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    117b <main+0x4b>
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %rax,0x10(%rsp)
cmp    $0x2,%eax
jl     11ef <main+0xaf>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r12d
mov    %r12d,%r13d
imul   %r12d,%r13d
mov    $0x1,%r15d
sub    %eax,%r15d
xor    %ebx,%ebx
mov    %r15d,0xc(%rsp)
jmp    11b7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%r12),%eax
add    0xc(%rsp),%r13d
add    $0x1,%r15d
cmp    $0x1,%r12d
mov    %eax,%r12d
jle    11ef <main+0xaf>
mov    %r13d,%ebp
mov    0x10(%rsp),%rax
mov    %eax,%r14d
jmp    11dd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%r14d
add    %r15d,%ebp
cmp    $0x1,%r14d
jle    11a0 <main+0x60>
cmp    %ebx,%ebp
jle    11d0 <main+0x90>
mov    %ebp,%edi
call   1030 <reverse@plt>
cmp    %eax,%ebp
cmove  %ebp,%ebx
jmp    11d0 <main+0x90>
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Algorithm start, please wait...\0A\00"
@.str.1 = [18 x i8] c"Algorithm finish.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
%12 = call i32 @pow(i32 10, i32 3)
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %7
store i32 0, i32* %8
%14 = load i32, i32* %7
store i32 %14, i32* %9
br label %15
15: ; preds = %42, %2
%16 = load i32, i32* %9
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %45
18: ; preds = %15
%19 = load i32, i32* %7
store i32 %19, i32* %10
br label %20
20: ; preds = %38, %18
%21 = load i32, i32* %10
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %41
23: ; preds = %20
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = mul nsw i32 %24, %25
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = load i32, i32* %6
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %23
%31 = load i32, i32* %8
%32 = call i32 @reverse(i32 %31)
%33 = load i32, i32* %8
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i32, i32* %8
store i32 %36, i32* %6
br label %37
37: ; preds = %35, %30, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %10
%40 = add nsw i32 %39, -1
store i32 %40, i32* %10
br label %20
41: ; preds = %20
br label %42
42: ; preds = %41
%43 = load i32, i32* %9
%44 = add nsw i32 %43, -1
store i32 %44, i32* %9
br label %15
45: ; preds = %15
%46 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Algorithm finish.\00"
@str = [32 x i8] c"Algorithm start, please wait...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @pow(i32 10, i32 3)
%5 = add nsw i32 %4, -1
%6 = icmp sgt i32 %4, 1
br i1 %6, label %7, label %10
7: ; preds = %2, %12
%8 = phi i32 [ %13, %12 ], [ %5, %2 ]
%9 = phi i32 [ %25, %12 ], [ 0, %2 ]
br label %15
10: ; preds = %12, %2
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
12: ; preds = %24
%13 = add nsw i32 %8, -1
%14 = icmp sgt i32 %8, 1
br i1 %14, label %7, label %10
15: ; preds = %7, %24
%16 = phi i32 [ %26, %24 ], [ %5, %7 ]
%17 = phi i32 [ %25, %24 ], [ %9, %7 ]
%18 = mul nsw i32 %16, %8
%19 = icmp sgt i32 %18, %17
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = tail call i32 @reverse(i32 %18)
%22 = icmp eq i32 %21, %18
%23 = select i1 %22, i32 %18, i32 %17
br label %24
24: ; preds = %20, %15
%25 = phi i32 [ %17, %15 ], [ %23, %20 ]
%26 = add nsw i32 %16, -1
%27 = icmp sgt i32 %16, 1
br i1 %27, label %15, label %12
}