#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__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int ac, char *av[]) {
  int n, _n, n2;
  char buf[1024];
  while (fgets(buf, 1024, stdin)) {
    n = _n = strtol(buf, NULL, 10);
    n2 = 0;
    while (_n != -0) {
      n2 = n2 * 10 + _n % 10;
      _n /= 10;
    }
    if (n == n2)
      printf("%d\n", n);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11ec <main+0xbc>
lea    -0x420(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11cc <main+0x9c>
imul   $0xa,-0x1c(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x424(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x5f>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11e7 <main+0xb7>
mov    -0x14(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2ea3(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11e5 <main+0xb5>
mov    %rsp,%r12
lea    0xe98(%rip),%r14
jmp    118f <main+0x5f>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    (%r15),%edx
mov    %r12,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11e5 <main+0xb5>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
test   %eax,%eax
je     1170 <main+0x40>
xor    %edx,%edx
mov    %eax,%ecx
cs nopw 0x0(%rax,%rax,1)
lea    (%rdx,%rdx,4),%edx
movslq %ecx,%rbx
imul   $0x66666667,%rbx,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rcx
add    %edi,%ecx
lea    (%rcx,%rcx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %ebx,%esi
sub    %edi,%esi
lea    (%rsi,%rdx,2),%edx
add    $0x9,%ebx
cmp    $0x12,%ebx
ja     11b0 <main+0x80>
cmp    %edx,%eax
je     1170 <main+0x40>
jmp    117a <main+0x4a>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 1024, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %28, label %8
8: ; preds = %2, %24
%9 = call i32 @strtol(i8* nocapture %4, i32* null, i32 10)
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %8, %11
%12 = phi i32 [ %16, %11 ], [ 0, %8 ]
%13 = phi i32 [ %17, %11 ], [ %9, %8 ]
%14 = mul nsw i32 %12, 10
%15 = srem i32 %13, 10
%16 = add nsw i32 %14, %15
%17 = sdiv i32 %13, 10
%18 = add i32 %13, 9
%19 = icmp ult i32 %18, 19
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = icmp eq i32 %9, %16
br i1 %21, label %22, label %24
22: ; preds = %8, %20
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* @stdin
%26 = call i64 @fgets(i8* %4, i32 1024, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %8
28: ; preds = %24, %2
ret i32 0
}