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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x440(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     121b <main+0xeb>
lea    -0x440(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f0 <main+0xc0>
imul   $0xa,-0x28(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    -0x448(%rbp),%rax
add    %rdx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
jmp    11a6 <main+0x76>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    120e <main+0xde>
mov    -0x18(%rbp),%rsi
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2ea0(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11fe <main+0xce>
xor    %r13d,%r13d
mov    %rsp,%r15
lea    0xe91(%rip),%r14
movabs $0x6666666666666667,%rbx
66 66 66
jmp    11a1 <main+0x71>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11fe <main+0xce>
mov    %r13,%rbp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,%r13
add    %rbp,%r13
je     1180 <main+0x50>
mov    %r13,%rcx
xor    %eax,%eax
lea    (%rax,%rax,4),%rsi
mov    %rcx,%rax
imul   %rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rcx,%rdi
sub    %rax,%rdi
lea    (%rdi,%rsi,2),%rax
add    $0x9,%rcx
cmp    $0x12,%rcx
mov    %rdx,%rcx
ja     11c0 <main+0x90>
cmp    %rax,%r13
je     1180 <main+0x50>
jmp    118b <main+0x5b>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%lld\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 %30, label %8
8: ; preds = %2, %26
%9 = phi i64 [ %11, %26 ], [ 0, %2 ]
%10 = call i64 @strtoll(i8* nocapture %4, i32* null, i32 10)
%11 = add nsw i64 %10, %9
%12 = icmp eq i64 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %8, %13
%14 = phi i64 [ %19, %13 ], [ %11, %8 ]
%15 = phi i64 [ %18, %13 ], [ 0, %8 ]
%16 = mul nsw i64 %15, 10
%17 = srem i64 %14, 10
%18 = add nsw i64 %17, %16
%19 = sdiv i64 %14, 10
%20 = add i64 %14, 9
%21 = icmp ult i64 %20, 19
br i1 %21, label %22, label %13
22: ; preds = %13
%23 = icmp eq i64 %11, %18
br i1 %23, label %24, label %26
24: ; preds = %8, %22
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %11)
br label %26
26: ; preds = %24, %22
%27 = load i32, i32* @stdin
%28 = call i64 @fgets(i8* %4, i32 1024, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %8
30: ; preds = %26, %2
ret i32 0
}