#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__ palim(int);
int /*<<< orphan*/ printf(char *, int);
int task4() {
  int x = 999, y = 999;
  int r = 0;
  int max = 0;
  for (x = 999; x > 100; x--) {
    for (y = x; y > 100; y--) {
      r = x * y;
      if (palim(r)) {
        if (max < r) {
          max = r;
          printf("Palindrome found: %i ! \n", max);
        }
      }
    }
  }
  return max;
}


x86 assembly (clang, -O0):
<task4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3e7,-0x4(%rbp)
movl   $0x3e7,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x3e7,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jle    11cd <task4+0xad>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jle    11ba <task4+0x9a>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <palim@plt>
cmp    $0x0,%rax
je     11a7 <task4+0x87>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a2 <task4+0x82>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <task4+0x87>
jmp    11ac <task4+0x8c>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <task4+0x3b>
jmp    11bf <task4+0x9f>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    114b <task4+0x2b>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x3e7,%eax
xor    %ebx,%ebx
mov    $0x3e8,%r15d
mov    $0xfffff833,%ecx
mov    $0xf3a71,%r13d
mov    $0xfffffc19,%r12d
lea    0xead(%rip),%r14
jmp    1184 <task4+0x64>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%rdx
lea    -0x1(%rdx),%eax
mov    0xc(%rsp),%r15d
add    $0xffffffff,%r15d
mov    0x8(%rsp),%ecx
add    %ecx,%r13d
add    $0x2,%ecx
add    $0x1,%r12d
cmp    $0x65,%edx
jbe    11cb <task4+0xab>
mov    %rax,0x10(%rsp)
mov    %ecx,0x8(%rsp)
mov    %r13d,%ebp
mov    %r15d,0xc(%rsp)
jmp    11ad <task4+0x8d>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%r15d
add    %r12d,%ebp
cmp    $0x65,%r15d
jle    1160 <task4+0x40>
mov    %ebp,%edi
call   1040 <palim@plt>
test   %rax,%rax
je     11a0 <task4+0x80>
cmp    %ebp,%ebx
jge    11a0 <task4+0x80>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%ebx
jmp    11a0 <task4+0x80>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Palindrome found: %i ! \0A\00"
define i32 @task4() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 999, i32* %1
store i32 999, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 999, i32* %1
br label %5
5: ; preds = %34, %0
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 100
br i1 %7, label %8, label %37
8: ; preds = %5
%9 = load i32, i32* %1
store i32 %9, i32* %2
br label %10
10: ; preds = %30, %8
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 100
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i64 @palim(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* %3
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %20
br label %29
29: ; preds = %28, %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, -1
store i32 %32, i32* %2
br label %10
33: ; preds = %10
br label %34
34: ; preds = %33
%35 = load i32, i32* %1
%36 = add nsw i32 %35, -1
store i32 %36, i32* %1
br label %5
37: ; preds = %5
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [25 x i8] c"Palindrome found: %i ! \0A\00"
define i32 @task4() {
br label %1
1: ; preds = %18, %0
%2 = phi i32 [ 0, %0 ], [ %15, %18 ]
%3 = phi i32 [ 999, %0 ], [ %19, %18 ]
br label %4
4: ; preds = %1, %14
%5 = phi i32 [ %15, %14 ], [ %2, %1 ]
%6 = phi i32 [ %16, %14 ], [ %3, %1 ]
%7 = mul nsw i32 %6, %3
%8 = tail call i64 @palim(i32 %7)
%9 = icmp ne i64 %8, 0
%10 = icmp slt i32 %5, %7
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %14
14: ; preds = %4, %12
%15 = phi i32 [ %7, %12 ], [ %5, %4 ]
%16 = add nsw i32 %6, -1
%17 = icmp sgt i32 %6, 101
br i1 %17, label %4, label %18
18: ; preds = %14
%19 = add nsw i32 %3, -1
%20 = icmp ugt i32 %3, 101
br i1 %20, label %1, label %21
21: ; preds = %18
ret i32 %15
}