#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__ palindrome(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  int i, j;
  int result;
  for (i = 1; i < 999; i++) {
    for (j = 1; j < 999; j++) {
      if (palindrome(result = i * j)) {
        printf("%d * %d = %d\n", i, j, result);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e7,-0x8(%rbp)
jge    11ab <main+0x8b>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3e7,-0xc(%rbp)
jge    1198 <main+0x78>
mov    -0x8(%rbp),%edi
imul   -0xc(%rbp),%edi
mov    %edi,-0x10(%rbp)
call   1040 <palindrome@plt>
cmp    $0x0,%rax
je     1185 <main+0x65>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    118a <main+0x6a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114a <main+0x2a>
jmp    119d <main+0x7d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r15d
lea    0xecc(%rip),%r14
jmp    114d <main+0x2d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x3e7,%r15d
je     118b <main+0x6b>
mov    %r15d,%ebp
mov    $0x1,%ebx
jmp    116e <main+0x4e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    %r15d,%ebp
cmp    $0x3e7,%ebx
je     1140 <main+0x20>
mov    %ebp,%edi
call   1040 <palindrome@plt>
test   %rax,%rax
je     1160 <main+0x40>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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