#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__ isPalindrome(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main() {
  char str[20];
  int x;
  int i;
  int max = 0;
  int produkt;
  for (i = 999; i >= 1; i--) {
    for (x = 999; x >= 1; x--) {
      produkt = i * x;
      if (produkt > max) {
        sprintf(str, "%d", produkt);
        if (isPalindrome(str)) {
          max = produkt;
        }
      }
    }
  }
  printf(
      "Largest palindrome number from the product of two 3-digit numbers:\n");
  printf("%d\n", max);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x3e7,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jl     11d5 <main+0xa5>
movl   $0x3e7,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jl     11c2 <main+0x92>
mov    -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    11af <main+0x7f>
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xe74(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <isPalindrome@plt>
cmp    $0x0,%rax
je     11aa <main+0x7a>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    11af <main+0x7f>
jmp    11b4 <main+0x84>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <main+0x2e>
jmp    11c7 <main+0x97>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    114d <main+0x1d>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x3e7,%eax
xor    %ebx,%ebx
mov    $0xf3a71,%ebp
mov    $0xfffffc19,%r13d
lea    0xe99(%rip),%r14
lea    0x10(%rsp),%r15
jmp    118b <main+0x4b>
xchg   %ax,%ax
mov    0x8(%rsp),%rcx
lea    -0x1(%rcx),%eax
mov    0x4(%rsp),%ebp
add    $0xfffffc19,%ebp
add    $0x1,%r13d
cmp    $0x1,%ecx
jbe    11ce <main+0x8e>
mov    %rax,0x8(%rsp)
mov    $0x3e8,%r12d
mov    %ebp,0x4(%rsp)
jmp    11ad <main+0x6d>
nopl   0x0(%rax)
add    $0xffffffff,%r12d
add    %r13d,%ebp
cmp    $0x1,%r12d
jbe    1170 <main+0x30>
cmp    %ebx,%ebp
jle    11a0 <main+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1050 <isPalindrome@plt>
test   %rax,%rax
cmovne %ebp,%ebx
jmp    11a0 <main+0x60>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
lea    0xe22(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [68 x i8] c"Largest palindrome number from the product of two 3-digit numbers:\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 999, i32* %4
br label %7
7: ; preds = %36, %0
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %39
10: ; preds = %7
store i32 999, i32* %3
br label %11
11: ; preds = %32, %10
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 1
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = mul nsw i32 %15, %16
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %14
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %6
%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 [20 x i8], [20 x i8]* %2, i64 0, i64 0
%26 = call i64 @isPalindrome(i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = load i32, i32* %6
store i32 %29, i32* %5
br label %30
30: ; preds = %28, %21
br label %31
31: ; preds = %30, %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %11
35: ; preds = %11
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, -1
store i32 %38, i32* %4
br label %7
39: ; preds = %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %5
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [67 x i8] c"Largest palindrome number from the product of two 3-digit numbers:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %20
%4 = phi i32 [ 0, %0 ], [ %17, %20 ]
%5 = phi i32 [ 999, %0 ], [ %21, %20 ]
br label %6
6: ; preds = %3, %16
%7 = phi i32 [ 999, %3 ], [ %18, %16 ]
%8 = phi i32 [ %4, %3 ], [ %17, %16 ]
%9 = mul nuw nsw i32 %7, %5
%10 = icmp sgt i32 %9, %8
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%13 = call i64 @isPalindrome(i8* %2)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i32 %8, i32 %9
br label %16
16: ; preds = %11, %6
%17 = phi i32 [ %8, %6 ], [ %15, %11 ]
%18 = add nsw i32 %7, -1
%19 = icmp ugt i32 %7, 1
br i1 %19, label %6, label %20
20: ; preds = %16
%21 = add nsw i32 %5, -1
%22 = icmp ugt i32 %5, 1
br i1 %22, label %3, label %23
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}