#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(char *);
int /*<<< orphan*/ itoa(int, char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  char c[8];
  int i, j, solution = 0;
  for (i = 100; i <= 1000; i++)
    for (j = 100; j <= 1000; j++) {
      itoa(i * j, c);
      if (is_palindrome(c) && i * j > solution)
        solution = i * j;
    }
  printf("Solution is %i\n", solution);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x64,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jg     11d1 <main+0xa1>
movl   $0x64,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jg     11be <main+0x8e>
mov    -0x10(%rbp),%edi
imul   -0x14(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1050 <itoa@plt>
lea    -0xc(%rbp),%rdi
call   1030 <is_palindrome@plt>
cmp    $0x0,%rax
je     11ab <main+0x7b>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11ab <main+0x7b>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11b0 <main+0x80>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <main+0x31>
jmp    11c3 <main+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <main+0x1d>
mov    -0x18(%rbp),%esi
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x64,%r15d
xor    %r13d,%r13d
mov    $0x2710,%r12d
mov    %rsp,%r14
jmp    1161 <main+0x31>
nop
add    $0x1,%r15d
add    $0x64,%r12d
cmp    $0x3e9,%r15d
je     119d <main+0x6d>
mov    $0x385,%ebx
mov    %r12d,%ebp
jmp    117f <main+0x4f>
nopl   0x0(%rax,%rax,1)
test   %rax,%rax
cmovne %ecx,%r13d
add    %r15d,%ebp
add    $0xffffffff,%ebx
je     1150 <main+0x20>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <itoa@plt>
mov    %r14,%rdi
call   1030 <is_palindrome@plt>
mov    %ebp,%ecx
cmp    %r13d,%ebp
jg     1170 <main+0x40>
mov    %r13d,%ecx
jmp    1170 <main+0x40>
lea    0xe5c(%rip),%rdi
mov    %r13d,%esi
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 = [16 x i8] c"Solution is %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 100, i32* %3
br label %6
6: ; preds = %37, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 1000
br i1 %8, label %9, label %40
9: ; preds = %6
store i32 100, i32* %4
br label %10
10: ; preds = %33, %9
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1000
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = mul nsw i32 %14, %15
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%18 = call i32 @itoa(i32 %16, i8* %17)
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%20 = call i64 @is_palindrome(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %13
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %5
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = mul nsw i32 %29, %30
store i32 %31, i32* %5
br label %32
32: ; preds = %28, %22, %13
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %10
36: ; preds = %10
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %6
40: ; preds = %6
%41 = load i32, i32* %5
%42 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %41)
ret i32 0
}

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