#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__ isKarprekarNumber(int);
int /*<<< orphan*/ printf(char *, ...);
void callKaprekarFunction(int p, int q) {
  int count = 0;
  for (int i = p; i <= q; i++) {
    if (isKarprekarNumber(i)) {
      count++;
      printf("%d ", i);
    }
  }
  if (count == 0) {
    printf("INVALID RANGE");
  }
}


x86 assembly (clang, -O0):
<callKaprekarFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1186 <callKaprekarFunction+0x66>
mov    -0x10(%rbp),%edi
call   1040 <isKarprekarNumber@plt>
cmp    $0x0,%rax
je     1173 <callKaprekarFunction+0x53>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1178 <callKaprekarFunction+0x58>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <callKaprekarFunction+0x1b>
cmpl   $0x0,-0xc(%rbp)
jne    119e <callKaprekarFunction+0x7e>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callKaprekarFunction>:
cmp    %esi,%edi
jg     1175 <callKaprekarFunction+0x55>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
add    $0x1,%r15d
lea    0xec5(%rip),%r14
xor    %ebx,%ebx
jmp    1148 <callKaprekarFunction+0x28>
nop
add    $0x1,%ebp
cmp    %ebp,%r15d
je     1165 <callKaprekarFunction+0x45>
mov    %ebp,%edi
call   1040 <isKarprekarNumber@plt>
test   %rax,%rax
je     1140 <callKaprekarFunction+0x20>
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1140 <callKaprekarFunction+0x20>
test   %ebx,%ebx
lea    0x8(%rsp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
je     1175 <callKaprekarFunction+0x55>
ret
lea    0xe88(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [14 x i8] c"INVALID RANGE\00"
define void @callKaprekarFunction(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
br i1 %3, label %18, label %6
4: ; preds = %14
%5 = icmp eq i32 %15, 0
br i1 %5, label %18, label %20
6: ; preds = %2, %14
%7 = phi i32 [ %16, %14 ], [ %0, %2 ]
%8 = phi i32 [ %15, %14 ], [ 0, %2 ]
%9 = tail call i64 @isKarprekarNumber(i32 %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = add nsw i32 %8, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %14
14: ; preds = %6, %11
%15 = phi i32 [ %12, %11 ], [ %8, %6 ]
%16 = add i32 %7, 1
%17 = icmp eq i32 %7, %1
br i1 %17, label %4, label %6
18: ; preds = %2, %4
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %4
ret void
}