#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 narcissisticNumbers(int, int);
int numPlaces(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int userInput = 0;
  int digit = 0;
  int isItNarcissisticNumber = 0;
  do {
    printf("\nNote: To Exit Program type 0 ");
    printf("\nEnter number: ");
    scanf("%d", &userInput);
    if (userInput != 0) {
      digit = numPlaces(userInput);
      isItNarcissisticNumber = narcissisticNumbers(userInput, digit);
      if (isItNarcissisticNumber == 1)
        printf("%d is Narcissistic\n", userInput);
      else
        printf("%d is Not Narcissistic\n", userInput);
    }
  } while (userInput != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11e2 <main+0xa2>
mov    -0x4(%rbp),%edi
call   1040 <numPlaces@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <narcissisticNumbers@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11cc <main+0x8c>
mov    -0x4(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dd <main+0x9d>
mov    -0x4(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <main+0xa2>
jmp    11e7 <main+0xa7>
cmpl   $0x0,-0x4(%rbp)
jne    115d <main+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea6(%rip),%r14
lea    0xebe(%rip),%r15
lea    0xec7(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xebe(%rip),%r13
lea    0xecb(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     11d3 <main+0x93>
call   1040 <numPlaces@plt>
mov    0x4(%rsp),%edi
mov    %eax,%esi
call   1060 <narcissisticNumbers@plt>
cmp    $0x1,%eax
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
cmove  %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jne    1180 <main+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0ANote: To Exit Program type 0 \00"
@.str.1 = [16 x i8] c"\0AEnter number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"%d is Narcissistic\0A\00"
@.str.4 = [24 x i8] c"%d is Not Narcissistic\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %26, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %4
%11 = load i32, i32* %1
%12 = call i32 @numPlaces(i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @narcissisticNumbers(i32 %13, i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %24
21: ; preds = %10
%22 = load i32, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %4
br label %26
26: ; preds = %25
%27 = load i32, i32* %1
%28 = icmp ne i32 %27, 0
br i1 %28, label %4, label %29
29: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0ANote: To Exit Program type 0 \00"
@.str.1 = [16 x i8] c"\0AEnter number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"%d is Narcissistic\0A\00"
@.str.4 = [24 x i8] c"%d is Not Narcissistic\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %9, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = call i32 @numPlaces(i32 %7)
%11 = load i32, i32* %1
%12 = call i32 @narcissisticNumbers(i32 %11, i32 %10)
%13 = icmp eq i32 %12, 1
%14 = load i32, i32* %1
%15 = select i1 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 %14)
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %3
19: ; preds = %3, %9
ret void
}