#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(void) {
  int input, digits;
  printf("Enter an integer > ");
  scanf("%d", &input);
  if (input < 0) {
    input = abs(input);
    while (input / 10 != 0) {
      digits = input % 10;
      printf("\n%d", digits);
      input = input / 10;
      if (input <= 9) {
        input = (-1) * input;
      }
    }
  } else {
    while (input / 10 != 0) {
      digits = input % 10;
      printf("\n%d", digits);
      input = input / 10;
    }
  }
  printf("\n%d\nThat's all, have a nice day!", input);
  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>
cmpl   $0x0,-0x8(%rbp)
jge    11d1 <main+0xa1>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     11cc <main+0x9c>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jg     11c7 <main+0x97>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1172 <main+0x42>
jmp    1221 <main+0xf1>
jmp    11d6 <main+0xa6>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     121c <main+0xec>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11d6 <main+0xa6>
jmp    1221 <main+0xf1>
mov    -0x8(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
js     11b2 <main+0x92>
cmp    $0xa,%esi
jb     1228 <main+0x108>
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax)
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
lea    (%rax,%rcx,1),%esi
mov    %esi,0xc(%rsp)
add    %ecx,%eax
add    $0x9,%eax
cmp    $0x12,%eax
ja     1160 <main+0x40>
jmp    1228 <main+0x108>
mov    %esi,%eax
neg    %eax
mov    %eax,0xc(%rsp)
add    $0x9,%esi
cmp    $0x13,%esi
jae    11c6 <main+0xa6>
mov    %eax,%esi
jmp    1228 <main+0x108>
lea    0xe47(%rip),%rbx
mov    %eax,%esi
nop
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
mov    %ecx,%esi
neg    %esi
cmp    $0x64,%rax
cmovge %ecx,%esi
mov    %esi,0xc(%rsp)
lea    0x9(%rsi),%eax
cmp    $0x13,%eax
jae    11d0 <main+0xb0>
lea    0xde9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"\0A%d\00"
@.str.3 = [33 x i8] c"\0A%d\0AThat's all, have a nice day!\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 ([20 x i8], [20 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* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %0
%9 = load i32, i32* %2
%10 = call i32 @abs(i32 %9)
store i32 %10, i32* %2
br label %11
11: ; preds = %27, %8
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 10
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %11
%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.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 10
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp sle i32 %22, 9
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = load i32, i32* %2
%26 = mul nsw i32 -1, %25
store i32 %26, i32* %2
br label %27
27: ; preds = %24, %15
br label %11
28: ; preds = %11
br label %42
29: ; preds = %0
br label %30
30: ; preds = %34, %29
%31 = load i32, i32* %2
%32 = sdiv i32 %31, 10
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i32, i32* %2
%36 = srem i32 %35, 10
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %2
%40 = sdiv i32 %39, 10
store i32 %40, i32* %2
br label %30
41: ; preds = %30
br label %42
42: ; preds = %41, %28
%43 = load i32, i32* %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %43)
ret i32 0
}

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