#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) {
      digit = fabs(digit);
      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    120c <main+0xdc>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11c3 <main+0x93>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <main+0x98>
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    1207 <main+0xd7>
cmpl   $0x0,-0xc(%rbp)
je     1207 <main+0xd7>
mov    -0xc(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <main+0xdc>
jmp    116b <main+0x3b>
lea    0xe0c(%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     1210 <main+0xc0>
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     11d1 <main+0x81>
mov    %ebx,%edi
call   1060 <fabs@plt>
mov    %r14,%rdi
mov    %eax,%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    0xe11(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    121c <main+0xcc>
lea    0xe22(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf9(%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, %36
%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 %37
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 %23
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 @fabs(i32 %19)
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18, %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = sdiv i32 %25, 10
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = call i32 @fabs(i32 %27)
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i32, i32* %3
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %37
36: ; preds = %30, %24
br label %7
37: ; preds = %33, %12
%38 = 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 = %19, %0
%8 = phi i32 [ %24, %19 ], [ %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 %29
13: ; preds = %7
%14 = call i32 @fabs(i32 %9)
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 @fabs(i32 %9)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13, %16
%20 = load i32, i32* %1
%21 = sdiv i32 %20, 10
store i32 %21, i32* %1
%22 = call i32 @fabs(i32 %21)
%23 = icmp slt i32 %22, 10
%24 = load i32, i32* %1
%25 = icmp ne i32 %24, 0
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %27, label %7
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %29
29: ; preds = %27, %11
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}