#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int Num, X, NewNum;
  printf("Please enter a number > ");
  scanf("%d", &Num);
  if (Num == 0) {
    printf("0\n");
  }
  while (Num > 0) {
    X = Num % 10;
    printf("%d\n", X);
    NewNum = (Num - X) / 10;
    Num = NewNum;
  }
  while (Num < 0) {
    X = Num % 10;
    NewNum = (Num - X) / 10;
    if (X < 0) {
      printf("%d\n", (X * -1));
    }
    if (Num < 0 && 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    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1165 <main+0x45>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
jle    11af <main+0x8f>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe93(%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,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x4a>
jmp    11b4 <main+0x94>
cmpl   $0x0,-0x8(%rbp)
jge    1229 <main+0x109>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11f9 <main+0xd9>
imul   $0xffffffff,-0xc(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    121e <main+0xfe>
cmpl   $0xfffffff6,-0x8(%rbp)
jle    121e <main+0xfe>
mov    -0xc(%rbp),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x94>
lea    0xdf3(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1169 <main+0x39>
test   %ebx,%ebx
jg     117d <main+0x4d>
jmp    11d2 <main+0xa2>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    11d2 <main+0xa2>
mov    $0xcccccccd,%ebp
lea    0xe93(%rip),%r14
nopl   0x0(%rax)
mov    %ebx,%eax
imul   %rbp,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %ebx,%eax
cltq
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
mov    %ebx,0xc(%rsp)
cmp    $0x9,%eax
jg     1190 <main+0x60>
test   %ebx,%ebx
js     11f1 <main+0xc1>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xcccccccd,%r15d
lea    0xe1e(%rip),%r14
jmp    120a <main+0xda>
mov    %ebx,0xc(%rsp)
cmp    $0x9,%r12d
jbe    11d6 <main+0xa6>
mov    %ebx,%eax
mov    %ebx,%r12d
neg    %r12d
mov    %r12,%rbx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %r12d,%ebp
sub    %ecx,%ebp
je     123a <main+0x10a>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
neg    %ebx
cmp    $0xfffffff7,%eax
jb     1200 <main+0xd0>
neg    %ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1200 <main+0xd0>

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