#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 n, digit, neg;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  if (n < 1)
    neg = 1;
  while (n == 0) {
    printf("\n%d", n);
    break;
  }
  digit = 0;
  while (n != 0) {
    digit = n % 10;
    {
      if ((neg) && (fabs(n) < 10))
        printf("\n%d", digit);
      if ((neg) && (fabs(n) >= 10))
        printf("\n%d", digit / (-1));
      if (!neg)
        printf("\n%d", digit);
    }
    n = (n - digit) / 10;
  }
  printf("\nThat's all, have a nice day!");
  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    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jge    116e <main+0x3e>
movl   $0x1,-0x10(%rbp)
jmp    1173 <main+0x43>
cmpl   $0x0,-0x8(%rbp)
jne    118e <main+0x5e>
mov    -0x8(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1240 <main+0x110>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11d9 <main+0xa9>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11d9 <main+0xa9>
mov    -0xc(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     120f <main+0xdf>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jl     120f <main+0xdf>
mov    -0xc(%rbp),%eax
mov    $0xffffffff,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    122a <main+0xfa>
mov    -0xc(%rbp),%esi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x65>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    1176 <main+0x46>
lea    0xeb4(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11fd <main+0xcd>
lea    0xe98(%rip),%rbx
jmp    11a9 <main+0x79>
nop
mov    0x4(%rsp),%eax
sub    %ebp,%eax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x9,%ecx
cmp    $0x12,%ecx
jbe    11fd <main+0xcd>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ebp
sub    %eax,%ebp
call   1040 <fabs@plt>
cmp    $0x9,%eax
jg     11df <main+0xaf>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jl     1180 <main+0x50>
mov    %ebp,%esi
neg    %esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1180 <main+0x50>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"\0A%d\00"
@.str.3 = [30 x i8] c"\0AThat's all, have a nice day!\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 ([21 x i8], [21 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* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %4
br label %10
10: ; preds = %9, %0
br label %11
11: ; preds = %10
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %11
store i32 0, i32* %3
br label %18
18: ; preds = %50, %17
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %55
21: ; preds = %18
%22 = load i32, i32* %2
%23 = srem i32 %22, 10
store i32 %23, i32* %3
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = load i32, i32* %2
%28 = call i32 @fabs(i32 %27)
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %26, %21
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i32, i32* %2
%38 = call i32 @fabs(i32 %37)
%39 = icmp sge i32 %38, 10
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i32, i32* %3
%42 = sdiv i32 %41, -1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %40, %36, %33
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %47, %44
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = sub nsw i32 %51, %52
%54 = sdiv i32 %53, 10
store i32 %54, i32* %2
br label %18
55: ; preds = %18
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, 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.2 = [4 x i8] c"\0A%d\00"
@.str.3 = [30 x i8] c"\0AThat'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 ([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 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %33, label %11
11: ; preds = %0, %7
%12 = phi i32 [ %5, %0 ], [ %9, %7 ]
br label %13
13: ; preds = %11, %27
%14 = phi i32 [ %30, %27 ], [ %12, %11 ]
%15 = srem i32 %14, 10
%16 = call i32 @fabs(i32 %14)
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %20
20: ; preds = %13, %18
%21 = load i32, i32* %1
%22 = call i32 @fabs(i32 %21)
%23 = icmp sgt i32 %22, 9
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = sub nsw i32 0, %15
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %20, %24
%28 = load i32, i32* %1
%29 = sub nsw i32 %28, %15
%30 = sdiv i32 %29, 10
store i32 %30, i32* %1
%31 = add i32 %29, 9
%32 = icmp ult i32 %31, 19
br i1 %32, label %33, label %13
33: ; preds = %27, %7
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}