#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 */
unsigned int eval(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ isKaprekar(unsigned int, unsigned int);
int /*<<< orphan*/ numberLen(unsigned int);
int /*<<< orphan*/ pow(unsigned int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main(void) {
  unsigned number;
  unsigned sum;
  printf("Enter a number : ");
  scanf("%u", &number);
  sum = eval(pow(number, 2), numberLen(number));
  printf("Kaprekar sum = %d\n", sum);
  printf("%d Number is %s a Kaprekar number\n", number,
         isKaprekar(number, sum) ? "" : "not");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <numberLen@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1080 <eval@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <isKaprekar@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rcx
lea    0xe6a(%rip),%rdx
lea    0xe3f(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
call   1070 <numberLen@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1080 <eval@plt>
mov    %eax,%ebx
lea    0xe68(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <isKaprekar@plt>
test   %rax,%rax
lea    0xe7e(%rip),%rax
lea    0xe53(%rip),%rdx
cmove  %rax,%rdx
lea    0xe49(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [19 x i8] c"Kaprekar sum = %d\0A\00"
@.str.3 = [35 x i8] c"%d Number is %s a Kaprekar number\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [4 x i8] c"not\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = call i32 @pow(i32 %6, i32 2)
%8 = load i32, i32* %2
%9 = call i32 @numberLen(i32 %8)
%10 = call i32 @eval(i32 %7, i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i64 @isKaprekar(i32 %14, i32 %15)
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [19 x i8] c"Kaprekar sum = %d\0A\00"
@.str.3 = [35 x i8] c"%d Number is %s a Kaprekar number\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [4 x i8] c"not\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @pow(i32 %5, i32 2)
%7 = load i32, i32* %1
%8 = call i32 @numberLen(i32 %7)
%9 = call i32 @eval(i32 %6, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = call i64 @isKaprekar(i32 %11, i32 %9)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %11, i8* %14)
ret i32 0
}