#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 fabs(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int digit, input;
  printf("\nEnter an integer > ");
  scanf("%d", &input);
  printf("\n");
  while (1) {
    digit = input % 10;
    if (input == 0) {
      printf("0\n");
      break;
    } else if (fabs(digit) < 10) {
      printf("%d\n", digit);
    }
    input = input / 10;
    if (fabs(input) < 10 && input != 0) {
      printf("%d\n", input);
      break;
    }
  }
  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    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1196 <main+0x66>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <main+0xd1>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11b8 <main+0x88>
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x8d>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11fc <main+0xcc>
cmpl   $0x0,-0xc(%rbp)
je     11fc <main+0xcc>
mov    -0xc(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <main+0xd1>
jmp    116b <main+0x3b>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
lea    0xe90(%rip),%r14
nopl   0x0(%rax,%rax,1)
test   %esi,%esi
je     1209 <main+0xb9>
movslq %esi,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1060 <fabs@plt>
cmp    $0x9,%eax
jg     11ca <main+0x7a>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x22,%rdi
add    %eax,%edi
mov    %edi,0x4(%rsp)
call   1060 <fabs@plt>
mov    0x4(%rsp),%esi
cmp    $0x9,%eax
jg     1190 <main+0x40>
test   %esi,%esi
je     1190 <main+0x40>
lea    0xe18(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1215 <main+0xc5>
lea    0xe29(%rip),%rdi
call   1040 <puts@plt>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"0\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [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
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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* %3)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %0, %34
%8 = load i32, i32* %3
%9 = srem i32 %8, 10
store i32 %9, i32* %2
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %35
14: ; preds = %7
%15 = load i32, i32* %2
%16 = call i32 @fabs(i32 %15)
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %14
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 10
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = call i32 @fabs(i32 %25)
%27 = icmp slt i32 %26, 10
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %35
34: ; preds = %28, %22
br label %7
35: ; preds = %31, %12
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

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