#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 */
char *itoa(int, char *, int);
char *malloc(int);
scalar_t__ palindromic(char *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int i;
  int j;
  int maxPalindromic = 0;
  char *number = malloc(6 * sizeof(char));
  for (i = 999; i > 0; i--) {
    for (j = 999; j > 0; j--) {
      number = itoa(i * j, number, 10);
      if (palindromic(number)) {
        if (i * j > maxPalindromic)
          maxPalindromic = i * j;
      }
    }
  }
  printf("result: %d", maxPalindromic);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x3e7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11f7 <main+0xb7>
movl   $0x3e7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11e4 <main+0xa4>
mov    -0x8(%rbp),%edi
imul   -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <itoa@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <palindromic@plt>
cmp    $0x0,%rax
je     11d1 <main+0x91>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11cc <main+0x8c>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11d1 <main+0x91>
jmp    11d6 <main+0x96>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x3c>
jmp    11e9 <main+0xa9>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116b <main+0x2b>
mov    -0x10(%rbp),%esi
lea    0xdff(%rip),%rdi
call   1030 <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
sub    $0x18,%rsp
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0x3e7,%eax
xor    %ebx,%ebx
mov    $0xf3a71,%ebp
mov    $0xfffffc19,%r12d
nopl   (%rax)
mov    %rax,0x10(%rsp)
mov    $0x3e8,%r13d
mov    %ebp,0xc(%rsp)
nop
mov    %ebx,%r15d
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1060 <itoa@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <palindromic@plt>
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
test   %rax,%rax
cmove  %r15d,%ebx
add    $0xffffffff,%r13d
add    %r12d,%ebp
cmp    $0x1,%r13d
ja     1180 <main+0x40>
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%eax
mov    0xc(%rsp),%ebp
add    $0xfffffc19,%ebp
add    $0x1,%r12d
cmp    $0x1,%ecx
ja     1170 <main+0x30>
lea    0xe28(%rip),%rdi
mov    %ebx,%esi
call   1030 <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 = [11 x i8] c"result: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i8* @malloc(i32 6)
store i8* %6, i8** %5
store i32 999, i32* %2
br label %7
7: ; preds = %39, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %42
10: ; preds = %7
store i32 999, i32* %3
br label %11
11: ; preds = %35, %10
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = mul nsw i32 %15, %16
%18 = load i8*, i8** %5
%19 = call i8* @itoa(i32 %17, i8* %18, i32 10)
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = call i64 @palindromic(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %14
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = mul nsw i32 %24, %25
%27 = load i32, i32* %4
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %4
br label %33
33: ; preds = %29, %23
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, -1
store i32 %37, i32* %3
br label %11
38: ; preds = %11
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, -1
store i32 %41, i32* %2
br label %7
42: ; preds = %7
%43 = load i32, i32* %4
%44 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %43)
ret i32 0
}

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