#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__ isIntMultiple(int, int, int, int, int);
int /*<<< orphan*/ printf(char *, int);
int reverse_int(int, int);
int main(int argc, char *argv[]) {
  int i = 0, palin = 0, max = 0;
  while (palin <= 998001) {
    palin = i * 1000 + reverse_int(i, 3);
    if (isIntMultiple(1, 1000, 1, 1000, palin))
      max = palin;
    i++;
  }
  printf("Largest palindrome: %d\n", max);
  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   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf3a71,-0x18(%rbp)
jg     11be <main+0x8e>
imul   $0x3e8,-0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
call   1050 <reverse_int@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%r8d
mov    $0x1,%edx
mov    $0x3e8,%ecx
mov    %edx,%edi
mov    %ecx,%esi
call   1040 <isIntMultiple@plt>
cmp    $0x0,%rax
je     11b0 <main+0x80>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
mov    -0x1c(%rbp),%esi
lea    0xe38(%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   %rbx
push   %rax
xor    %r14d,%r14d
mov    $0xfffffc18,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    $0x3,%esi
call   1050 <reverse_int@plt>
lea    (%rax,%rbx,1),%r15d
add    $0x3e8,%r15d
mov    $0x1,%edi
mov    $0x3e8,%esi
mov    $0x1,%edx
mov    $0x3e8,%ecx
mov    %r15d,%r8d
call   1040 <isIntMultiple@plt>
test   %rax,%rax
cmovne %r15d,%r14d
add    $0x1,%ebp
add    $0x3e8,%ebx
cmp    $0xf3a72,%r15d
jl     1150 <main+0x20>
lea    0xe5d(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Largest 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 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %7
%11 = icmp sle i32 %10, 998001
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i32, i32* %6
%14 = mul nsw i32 %13, 1000
%15 = load i32, i32* %6
%16 = call i32 @reverse_int(i32 %15, i32 3)
%17 = add nsw i32 %14, %16
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = call i64 @isIntMultiple(i32 1, i32 1000, i32 1, i32 1000, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = load i32, i32* %7
store i32 %22, i32* %8
br label %23
23: ; preds = %21, %12
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %9
26: ; preds = %9
%27 = load i32, i32* %8
%28 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Largest palindrome: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %11, %3 ]
%5 = phi i32 [ 0, %2 ], [ %12, %3 ]
%6 = mul nsw i32 %5, 1000
%7 = tail call i32 @reverse_int(i32 %5, i32 3)
%8 = add nsw i32 %7, %6
%9 = tail call i64 @isIntMultiple(i32 1, i32 1000, i32 1, i32 1000, i32 %8)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 %4, i32 %8
%12 = add nuw nsw i32 %5, 1
%13 = icmp slt i32 %8, 998002
br i1 %13, label %3, label %14
14: ; preds = %3
%15 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}