#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ get_limits(int, int *, int *);
scalar_t__ is_reversible(scalar_t__);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ reverse(int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <N>\n", argv[0]);
    return 1;
  }
  int N = atoi(argv[1]);
  int count = 0;
  int start_at = 1;
  get_limits(N, &count, &start_at);
  for (int i = start_at; i < N; i++) {
    if (i % 10 == 0)
      continue;
    else if (is_reversible(i + reverse(i, 10)))
      count++;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a8 <main+0x48>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1263 <main+0x103>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <get_limits@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    124d <main+0xed>
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1201 <main+0xa1>
jmp    123f <main+0xdf>
movslq -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    $0xa,%esi
call   1030 <reverse@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
call   1070 <is_reversible@plt>
cmp    $0x0,%rax
je     1235 <main+0xd5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123a <main+0xda>
jmp    123f <main+0xdf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dc <main+0x7c>
mov    -0x18(%rbp),%esi
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11fc <main+0x9c>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
movl   $0x0,(%rsp)
movl   $0x1,0x4(%rsp)
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
mov    %eax,%edi
call   1040 <get_limits@plt>
movslq 0x4(%rsp),%rbx
cmp    %ebp,%ebx
jl     11c8 <main+0x68>
mov    (%rsp),%esi
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
jmp    1219 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %ebx,%ebp
je     119e <main+0x3e>
imul   $0xcccccccd,%ebx,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999999,%eax
jb     11c0 <main+0x60>
mov    %ebx,%edi
mov    $0xa,%esi
call   1030 <reverse@plt>
lea    (%rax,%rbx,1),%rdi
call   1070 <is_reversible@plt>
test   %rax,%rax
je     11c0 <main+0x60>
addl   $0x1,(%rsp)
jmp    11c0 <main+0x60>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdf1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %54
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
%23 = load i32, i32* %6
%24 = call i32 @get_limits(i32 %23, i32* %7, i32* %8)
%25 = load i32, i32* %8
store i32 %25, i32* %9
br label %26
26: ; preds = %48, %18
%27 = load i32, i32* %9
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %51
30: ; preds = %26
%31 = load i32, i32* %9
%32 = srem i32 %31, 10
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
br label %48
35: ; preds = %30
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = load i32, i32* %9
%39 = call i64 @reverse(i32 %38, i32 10)
%40 = add nsw i64 %37, %39
%41 = call i64 @is_reversible(i64 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %46
46: ; preds = %43, %35
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47, %34
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %26
51: ; preds = %26
%52 = load i32, i32* %7
%53 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
store i32 0, i32* %3
br label %54
54: ; preds = %51, %12
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %41
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%15 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%16 = call i32 @get_limits(i32 %13, i32* %3, i32* %4)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, %13
br i1 %18, label %19, label %21
19: ; preds = %10
%20 = sext i32 %17 to i64
br label %24
21: ; preds = %37, %10
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %41
24: ; preds = %19, %37
%25 = phi i64 [ %20, %19 ], [ %38, %37 ]
%26 = trunc i64 %25 to i32
%27 = srem i32 %26, 10
%28 = icmp eq i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %24
%30 = call i64 @reverse(i32 %26, i32 10)
%31 = add nsw i64 %30, %25
%32 = call i64 @is_reversible(i64 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %29
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %37
37: ; preds = %34, %29, %24
%38 = add nsw i64 %25, 1
%39 = trunc i64 %38 to i32
%40 = icmp eq i32 %13, %39
br i1 %40, label %21, label %24
41: ; preds = %21, %6
%42 = phi i32 [ 1, %6 ], [ 0, %21 ]
ret i32 %42
}