#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 is_palindrome(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int max_palin = 0;
  for (int i = 100; i < 999; i++)
    for (int j = 100; j < 999; j++)
      if (is_palindrome(i * j) == true && (i * j > max_palin))
        max_palin = i * j;
  printf("Max 3-digit palindrome: %d\n", max_palin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
cmpl   $0x3e7,-0x18(%rbp)
jge    11ba <main+0x9a>
movl   $0x64,-0x1c(%rbp)
cmpl   $0x3e7,-0x1c(%rbp)
jge    11a7 <main+0x87>
mov    -0x18(%rbp),%edi
imul   -0x1c(%rbp),%edi
call   1030 <is_palindrome@plt>
cmp    $0x1,%eax
jne    1194 <main+0x74>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1194 <main+0x74>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <main+0x79>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <main+0x38>
jmp    11ac <main+0x8c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe3c(%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
xor    %ebx,%ebx
mov    $0x64,%r14d
mov    $0x2710,%r15d
nopl   0x0(%rax)
mov    $0x383,%r12d
mov    %r15d,%ebp
nopl   0x0(%rax)
mov    %ebx,%r13d
mov    %ebp,%edi
call   1030 <is_palindrome@plt>
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
cmp    $0x1,%eax
cmovne %r13d,%ebx
add    %r14d,%ebp
add    $0xffffffff,%r12d
jne    1150 <main+0x30>
add    $0x1,%r14d
add    $0x64,%r15d
cmp    $0x3e7,%r14d
jne    1140 <main+0x20>
lea    0xe79(%rip),%rdi
mov    %ebx,%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 = [28 x i8] c"Max 3-digit palindrome: %d\0A\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 100, i32* %7
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 999
br i1 %11, label %12, label %40
12: ; preds = %9
store i32 100, i32* %8
br label %13
13: ; preds = %33, %12
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 999
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = mul nsw i32 %17, %18
%20 = call i32 @is_palindrome(i32 %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
store i32 %31, i32* %6
br label %32
32: ; preds = %28, %22, %16
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %13
36: ; preds = %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %9
40: ; preds = %9
%41 = load i32, i32* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %41)
ret i32 0
}

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