#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *convert(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ ispal(char *);
scalar_t__ malloc(int);
int square(int);
void main() {
  char *a = (char *)malloc(sizeof(char) * 128);
  int b, i;
  FILE *in = fopen("palsquare.in", "r");
  fscanf(in, "%d", &b);
  fclose(in);
  FILE *out = fopen("palsquare.out", "w");
  for (i = 1; i <= 300; i++)
    if (ispal(convert(square(i), b)))
      fprintf(out, "%s %s\n", convert(i, b), convert(square(i), b));
  fclose(out);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x80,%edi
call   1080 <malloc@plt>
mov    %rax,-0x8(%rbp)
lea    0xe53(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe31(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x12c,-0x10(%rbp)
jg     127c <main+0xec>
mov    -0x10(%rbp),%edi
call   1050 <square@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1030 <convert@plt>
mov    %rax,%rdi
call   10b0 <ispal@plt>
cmp    $0x0,%rax
je     1269 <main+0xd9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <convert@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <square@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1030 <convert@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xdbe(%rip),%rsi
call   1070 <fprintf@plt>
jmp    126e <main+0xde>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f8 <main+0x68>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x80,%edi
call   1080 <malloc@plt>
lea    0xe58(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe51(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe38(%rip),%rdi
lea    0xe3f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    $0x1,%ebp
lea    0xe2d(%rip),%r14
jmp    120b <main+0x7b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x12d,%ebp
je     125d <main+0xcd>
mov    %ebp,%edi
call   1050 <square@plt>
mov    0x4(%rsp),%esi
mov    %eax,%edi
call   1030 <convert@plt>
mov    %rax,%rdi
call   10b0 <ispal@plt>
test   %rax,%rax
je     1200 <main+0x70>
mov    0x4(%rsp),%esi
mov    %ebp,%edi
call   1030 <convert@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1050 <square@plt>
mov    0x4(%rsp),%esi
mov    %eax,%edi
call   1030 <convert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
jmp    1200 <main+0x70>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"palsquare.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"palsquare.out\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [7 x i8] c"%s %s\0A\00"
define void @main() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = call i64 @malloc(i32 128)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = load i32*, i32** %4
%12 = call i32 @fclose(i32* %11)
%13 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %13, i32** %5
store i32 1, i32* %3
br label %14
14: ; preds = %35, %0
%15 = load i32, i32* %3
%16 = icmp sle i32 %15, 300
br i1 %16, label %17, label %38
17: ; preds = %14
%18 = load i32, i32* %3
%19 = call i32 @square(i32 %18)
%20 = load i32, i32* %2
%21 = call i8* @convert(i32 %19, i32 %20)
%22 = call i64 @ispal(i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %17
%25 = load i32*, i32** %5
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = call i8* @convert(i32 %26, i32 %27)
%29 = load i32, i32* %3
%30 = call i32 @square(i32 %29)
%31 = load i32, i32* %2
%32 = call i8* @convert(i32 %30, i32 %31)
%33 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %28, i8* %32)
br label %34
34: ; preds = %24, %17
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %14
38: ; preds = %14
%39 = load i32*, i32** %5
%40 = call i32 @fclose(i32* %39)
%41 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"palsquare.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"palsquare.out\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [7 x i8] c"%s %s\0A\00"
define void @main() {
%1 = alloca i32
%2 = tail call i64 @malloc(i32 128)
%3 = bitcast i32* %1 to i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = call i32 @fclose(i32* %4)
%7 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %8
8: ; preds = %0, %22
%9 = phi i32 [ 1, %0 ], [ %23, %22 ]
%10 = call i32 @square(i32 %9)
%11 = load i32, i32* %1
%12 = call i8* @convert(i32 %10, i32 %11)
%13 = call i64 @ispal(i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %8
%16 = load i32, i32* %1
%17 = call i8* @convert(i32 %9, i32 %16)
%18 = call i32 @square(i32 %9)
%19 = load i32, i32* %1
%20 = call i8* @convert(i32 %18, i32 %19)
%21 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %17, i8* %20)
br label %22
22: ; preds = %8, %15
%23 = add nuw nsw i32 %9, 1
%24 = icmp eq i32 %23, 301
br i1 %24, label %25, label %8
25: ; preds = %22
%26 = call i32 @fclose(i32* %7)
%27 = call i32 @exit(i32 0)
unreachable
}