#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(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int X, Num, NewNum;
  printf("Enter an integer > ");
  scanf("%d", &Num);
  printf("\n");
  while (Num) {
    X = Num % 10;
    NewNum = (Num - X) / 10.0;
    if (abs(Num) >= 10) {
      printf("%d\n", abs(X));
    }
    if (abs(Num) < 10) {
      printf("%d\n", X);
    }
    Num = NewNum;
  }
  printf("That's all, have a nice day!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11f6 <main+0xc6>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe6b(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
cmp    $0xa,%eax
jl     11c9 <main+0x99>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
cmp    $0xa,%eax
jge    11eb <main+0xbb>
mov    -0x8(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x3b>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     120d <main+0xcd>
lea    0xe9d(%rip),%rbx
jmp    11aa <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cvttsd2si 0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     120d <main+0xcd>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
divsd  0xe28(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
cmp    $0xa,%ecx
jb     1190 <main+0x50>
mov    %ebp,%esi
neg    %esi
cmovs  %ebp,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
cmp    $0x9,%ecx
jbe    1190 <main+0x50>
jmp    119c <main+0x5c>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [30 x i8] c"That's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 10
store i32 %13, i32* %2
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = sub nsw i32 %14, %15
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, 1.000000e+01
%19 = fptosi double %18 to i32
store i32 %19, i32* %4
%20 = load i32, i32* %3
%21 = call i32 @abs(i32 %20)
%22 = icmp sge i32 %21, 10
br i1 %22, label %23, label %27
23: ; preds = %11
%24 = load i32, i32* %2
%25 = call i32 @abs(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %11
%28 = load i32, i32* %3
%29 = call i32 @abs(i32 %28)
%30 = icmp slt i32 %29, 10
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %4
store i32 %35, i32* %3
br label %8
36: ; preds = %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [29 x i8] c"That's all, have a nice day!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %27, label %8
8: ; preds = %0, %25
%9 = phi i32 [ %14, %25 ], [ %6, %0 ]
%10 = srem i32 %9, 10
%11 = sub nsw i32 %9, %10
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 1.000000e+01
%14 = fptosi double %13 to i32
%15 = call i32 @llvm.abs.i32(i32 %9, i1 true)
%16 = icmp ugt i32 %15, 9
br i1 %16, label %17, label %23
17: ; preds = %8
%18 = call i32 @llvm.abs.i32(i32 %10, i1 true)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = call i32 @llvm.abs.i32(i32 %20, i1 true)
%22 = icmp ult i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %8, %17
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %25
25: ; preds = %23, %17
store i32 %14, i32* %1
%26 = icmp eq i32 %14, 0
br i1 %26, label %27, label %8
27: ; preds = %25, %0
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}