#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 _abs_(scalar_t__);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ reverse(int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int i, j, k, c = 0;
  scanf("%d %d %d", &i, &j, &k);
  for (int a = i; a <= j; a++) {
    if (0 == _abs_(a - reverse(a)) % k) {
      c++;
    }
  }
  printf("%d", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c6 <main+0x86>
movslq -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <reverse@plt>
mov    -0x20(%rbp),%rdi
sub    %rax,%rdi
call   1050 <_abs_@plt>
cltd
idivl  -0x10(%rbp)
xor    %eax,%eax
cmp    %edx,%eax
jne    11b3 <main+0x73>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <main+0x78>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x34>
mov    -0x14(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1060 <scanf@plt>
movslq 0x14(%rsp),%rbx
xor    %ebp,%ebp
cmp    0xc(%rsp),%ebx
jg     119e <main+0x5e>
xor    %ebp,%ebp
mov    %ebx,%edi
call   1030 <reverse@plt>
mov    %rbx,%rdi
sub    %rax,%rdi
call   1050 <_abs_@plt>
cltd
idivl  0x10(%rsp)
cmp    $0x1,%edx
adc    $0x0,%ebp
lea    0x1(%rbx),%rax
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1170 <main+0x30>
lea    0xe61(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = load i32, i32* %2
store i32 %8, i32* %6
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = load i32, i32* %6
%17 = call i64 @reverse(i32 %16)
%18 = sub nsw i64 %15, %17
%19 = call i32 @_abs_(i64 %18)
%20 = load i32, i32* %4
%21 = srem i32 %19, %20
%22 = icmp eq i32 0, %21
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %9
30: ; preds = %9
%31 = load i32, i32* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = icmp sgt i32 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = sext i32 %8 to i64
br label %16
13: ; preds = %16, %0
%14 = phi i32 [ 0, %0 ], [ %27, %16 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
16: ; preds = %11, %16
%17 = phi i64 [ %12, %11 ], [ %28, %16 ]
%18 = phi i32 [ 0, %11 ], [ %27, %16 ]
%19 = trunc i64 %17 to i32
%20 = call i64 @reverse(i32 %19)
%21 = sub nsw i64 %17, %20
%22 = call i32 @_abs_(i64 %21)
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = add nuw nsw i32 %18, %26
%28 = add nsw i64 %17, 1
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %17, %30
br i1 %31, label %16, label %13
}