#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 /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ is_palindrome(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char **argv) {
  char buffer[7];
  int i, j, product;
  int max_palindrome = 0;
  for (i = 100; i < 1000; i++) {
    for (j = 100; j < 1000; j++) {
      product = i * j;
      sprintf(buffer, "%i", product);
      if (is_palindrome(buffer) && product > max_palindrome) {
        max_palindrome = product;
      }
    }
  }
  printf("The largest palindrome is %i.\n", max_palindrome);
  exit(EXIT_SUCCESS);
}


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)
movl   $0x0,-0x28(%rbp)
movl   $0x64,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    11ed <main+0xad>
movl   $0x64,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    11da <main+0x9a>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x17(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe63(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x17(%rbp),%rdi
call   1030 <is_palindrome@plt>
cmp    $0x0,%rax
je     11c7 <main+0x87>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    11c7 <main+0x87>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11cc <main+0x8c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1178 <main+0x38>
jmp    11df <main+0x9f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <main+0x24>
mov    -0x28(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x64,%r12d
xor    %ebx,%ebx
mov    $0x2710,%ebp
lea    0xe9e(%rip),%r14
lea    0x11(%rsp),%r15
jmp    1184 <main+0x44>
nopl   0x0(%rax)
add    $0x1,%r12d
mov    0xc(%rsp),%ebp
add    $0x64,%ebp
cmp    $0x3e8,%r12d
je     11be <main+0x7e>
mov    $0x384,%r13d
mov    %ebp,0xc(%rsp)
jmp    119f <main+0x5f>
test   %rax,%rax
cmovne %ecx,%ebx
add    %r12d,%ebp
add    $0xffffffff,%r13d
je     1170 <main+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <is_palindrome@plt>
mov    %ebp,%ecx
cmp    %ebx,%ebp
jg     1190 <main+0x50>
mov    %ebx,%ecx
jmp    1190 <main+0x50>
lea    0xe3e(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [31 x i8] c"The largest palindrome is %i.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [7 x i8]
%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
store i32 0, i32* %10
store i32 100, i32* %7
br label %11
11: ; preds = %39, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %42
14: ; preds = %11
store i32 100, i32* %8
br label %15
15: ; preds = %35, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 1000
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = mul nsw i32 %19, %20
store i32 %21, i32* %9
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %9
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%26 = call i64 @is_palindrome(i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %18
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* %9
store i32 %33, i32* %10
br label %34
34: ; preds = %32, %28, %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %15
38: ; preds = %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %11
42: ; preds = %11
%43 = load i32, i32* %10
%44 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [31 x i8] c"The largest palindrome is %i.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %2, %20
%6 = phi i32 [ 0, %2 ], [ %17, %20 ]
%7 = phi i32 [ 100, %2 ], [ %21, %20 ]
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ %6, %5 ], [ %17, %8 ]
%10 = phi i32 [ 100, %5 ], [ %18, %8 ]
%11 = mul nuw nsw i32 %10, %7
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i64 @is_palindrome(i8* %4)
%14 = icmp ne i64 %13, 0
%15 = icmp sgt i32 %11, %9
%16 = select i1 %14, i1 %15, i1 false
%17 = select i1 %16, i32 %11, i32 %9
%18 = add nuw nsw i32 %10, 1
%19 = icmp eq i32 %18, 1000
br i1 %19, label %20, label %8
20: ; preds = %8
%21 = add nuw nsw i32 %7, 1
%22 = icmp eq i32 %21, 1000
br i1 %22, label %23, label %5
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}