#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 n, t, d;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  printf("\n");
  t = n;
  if (n == 0)
    printf("0\n");
  else
    while (n != 0) {
      d = n % 10;
      n = n / 10;
      if ((t < 0) && (n == 0))
        printf("-%d\n", abs(d));
      else
        printf("%d\n", abs(d));
    }
  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   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118e <main+0x5e>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120c <main+0xdc>
jmp    1193 <main+0x63>
cmpl   $0x0,-0x8(%rbp)
je     1207 <main+0xd7>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ea <main+0xba>
cmpl   $0x0,-0x8(%rbp)
jne    11ea <main+0xba>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1202 <main+0xd2>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1193 <main+0x63>
jmp    120c <main+0xdc>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     11df <main+0x9f>
lea    0xe97(%rip),%r14
lea    0xe91(%rip),%r15
mov    %ebx,%eax
nopw   0x0(%rax,%rax,1)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%edi
sub    %edx,%edi
add    $0x9,%eax
mov    %edi,%esi
neg    %esi
cmovs  %edi,%esi
cmp    $0x13,%eax
mov    %r15,%rdi
cmovb  %r14,%rdi
test   %ebx,%ebx
mov    %ecx,0xc(%rsp)
cmovns %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1190 <main+0x50>
jmp    11eb <main+0xab>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 = [5 x i8] c"-%d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [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 ([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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %37
13: ; preds = %0
br label %14
14: ; preds = %35, %13
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %36
17: ; preds = %14
%18 = load i32, i32* %2
%19 = srem i32 %18, 10
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 10
store i32 %21, i32* %2
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %17
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %4
%29 = call i32 @abs(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %35
31: ; preds = %24, %17
%32 = load i32, i32* %4
%33 = call i32 @abs(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %31, %27
br label %14
36: ; preds = %14
br label %37
37: ; preds = %36, %11
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, 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 = [5 x i8] c"-%d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str = [29 x i8] c"That's all, have a nice day!\00"
@str.7 = [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
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = icmp slt i32 %6, 0
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
br label %24
12: ; preds = %8, %12
%13 = phi i32 [ %6, %8 ], [ %22, %12 ]
%14 = srem i32 %13, 10
%15 = sdiv i32 %13, 10
store i32 %15, i32* %1
%16 = add i32 %13, 9
%17 = icmp ult i32 %16, 19
%18 = select i1 %9, i1 %17, i1 false
%19 = call i32 @llvm.abs.i32(i32 %14, i1 true)
%20 = select i1 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %20, i32 %19)
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %12
24: ; preds = %12, %10
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}