#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*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
int main(void) {
  int x, y, largest = 0;
  char buffer[8];
  char *reversed;
  size_t length;
  for (x = 999; x > 99; x--)
    for (y = 999; y > 99; y--) {
      sprintf(buffer, "%d", x * y);
      length = strlen(buffer);
      reversed = malloc((length + 1) * sizeof(char));
      strncpy(reversed, buffer, length);
      reverse(reversed);
      if (strcmp(buffer, reversed) == 0) {
        largest = (((largest) > (x * y)) ? (largest) : (x * y));
      }
      strncpy(reversed, "\0", length);
      free(reversed);
    }
  printf("%d\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x3e7,-0x8(%rbp)
cmpl   $0x63,-0x8(%rbp)
jle    128d <main+0x10d>
movl   $0x3e7,-0xc(%rbp)
cmpl   $0x63,-0xc(%rbp)
jle    127a <main+0xfa>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
imul   -0xc(%rbp),%edx
lea    0xe36(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <strncpy@plt>
mov    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    124f <main+0xcf>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jle    123f <main+0xbf>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1249 <main+0xc9>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xda9(%rip),%rsi
call   1050 <strncpy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11ae <main+0x2e>
jmp    127f <main+0xff>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <main+0x1d>
mov    -0x10(%rbp),%esi
lea    0xd6c(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%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    $0x18,%rsp
xor    %ebp,%ebp
mov    $0x3e7,%eax
mov    $0xf3a71,%ebx
mov    $0xfffffc19,%ecx
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,0x8(%rsp)
mov    $0x3e8,%r15d
mov    %ebx,(%rsp)
mov    %ecx,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
lea    0xe26(%rip),%rsi
mov    %ebx,%edx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %rax,%r13
lea    0x1(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <strncpy@plt>
mov    %r14,%rdi
call   1030 <reverse@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
mov    %ebp,%ecx
cmp    %ebx,%ebp
mov    %ebx,%ebp
cmovg  %ecx,%ebp
test   %rax,%rax
cmovne %ecx,%ebp
mov    %r14,%rdi
lea    0xdd5(%rip),%rsi
mov    %r13,%rdx
call   1050 <strncpy@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    0x4(%rsp),%ecx
add    $0xffffffff,%r15d
add    %ecx,%ebx
cmp    $0x64,%r15d
ja     11d0 <main+0x50>
mov    0x8(%rsp),%rdx
lea    -0x1(%rdx),%eax
mov    (%rsp),%ebx
add    $0xfffffc19,%ebx
add    $0x1,%ecx
cmp    $0x64,%edx
ja     11b0 <main+0x30>
lea    0xd89(%rip),%rdi
mov    %ebp,%esi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x18,%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 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [8 x i8]
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %4
store i32 999, i32* %2
br label %8
8: ; preds = %61, %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 99
br i1 %10, label %11, label %64
11: ; preds = %8
store i32 999, i32* %3
br label %12
12: ; preds = %57, %11
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 99
br i1 %14, label %15, label %60
15: ; preds = %12
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = mul nsw i32 %17, %18
%20 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %7
%23 = load i64, i64* %7
%24 = add i64 %23, 1
%25 = mul i64 %24, 1
%26 = call i8* @malloc(i64 %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%29 = load i64, i64* %7
%30 = call i32 @strncpy(i8* %27, i8* %28, i64 %29)
%31 = load i8*, i8** %6
%32 = call i32 @reverse(i8* %31)
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%34 = load i8*, i8** %6
%35 = call i64 @strcmp(i8* %33, i8* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %51
37: ; preds = %15
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = mul nsw i32 %39, %40
%42 = icmp sgt i32 %38, %41
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = load i32, i32* %4
br label %49
45: ; preds = %37
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = mul nsw i32 %46, %47
br label %49
49: ; preds = %45, %43
%50 = phi i32 [ %44, %43 ], [ %48, %45 ]
store i32 %50, i32* %4
br label %51
51: ; preds = %49, %15
%52 = load i8*, i8** %6
%53 = load i64, i64* %7
%54 = call i32 @strncpy(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64 %53)
%55 = load i8*, i8** %6
%56 = call i32 @free(i8* %55)
br label %57
57: ; preds = %51
%58 = load i32, i32* %3
%59 = add nsw i32 %58, -1
store i32 %59, i32* %3
br label %12
60: ; preds = %12
br label %61
61: ; preds = %60
%62 = load i32, i32* %2
%63 = add nsw i32 %62, -1
store i32 %63, i32* %2
br label %8
64: ; preds = %8
%65 = load i32, i32* %4
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %25
%4 = phi i32 [ 999, %0 ], [ %26, %25 ]
%5 = phi i32 [ 0, %0 ], [ %20, %25 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 999, %3 ], [ %23, %6 ]
%8 = phi i32 [ %5, %3 ], [ %20, %6 ]
%9 = mul nuw nsw i32 %7, %4
%10 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i64 @strlen(i8* %2)
%12 = add i64 %11, 1
%13 = call i8* @malloc(i64 %12)
%14 = call i32 @strncpy(i8* %13, i8* %2, i64 %11)
%15 = call i32 @reverse(i8* %13)
%16 = call i64 @strcmp(i8* %2, i8* %13)
%17 = icmp eq i64 %16, 0
%18 = icmp sgt i32 %8, %9
%19 = select i1 %18, i32 %8, i32 %9
%20 = select i1 %17, i32 %19, i32 %8
%21 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%22 = call i32 @free(i8* %13)
%23 = add nsw i32 %7, -1
%24 = icmp ugt i32 %7, 100
br i1 %24, label %6, label %25
25: ; preds = %6
%26 = add nsw i32 %4, -1
%27 = icmp ugt i32 %4, 100
br i1 %27, label %3, label %28
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}