#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 num, digit;
  printf("\nEnter an integer > ");
  scanf("%d", &num);
  digit = abs(num) % 10;
  if (num < 0) {
    num = abs(num);
    while (num != digit) {
      digit = num % 10;
      if (num <= digit)
        printf("\n-%d", digit);
      else
        printf("\n%d", digit);
      num = (num - digit) / 10;
      if (num == 0)
        break;
      if (num == digit)
        printf("\n-%d", num);
    }
  } else if (num == 0) {
    printf("\n0");
  } else if (num >= 0) {
    while (num != digit) {
      digit = num % 10;
      printf("\n%d", digit);
      num = (num - digit) / 10;
      if (num == 0)
        break;
      if (num == digit)
        printf("\n%d", num);
    }
  }
  printf("\nThat'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    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1219 <main+0xe9>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1214 <main+0xe4>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c1 <main+0x91>
mov    -0xc(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d2 <main+0xa2>
mov    -0xc(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f2 <main+0xc2>
jmp    1214 <main+0xe4>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    120f <main+0xdf>
mov    -0x8(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1185 <main+0x55>
jmp    12c1 <main+0x191>
cmpl   $0x0,-0x8(%rbp)
jne    1236 <main+0x106>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bc <main+0x18c>
cmpl   $0x0,-0x8(%rbp)
jl     12b7 <main+0x187>
jmp    1245 <main+0x115>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     12b2 <main+0x182>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1290 <main+0x160>
jmp    12b2 <main+0x182>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    12ad <main+0x17d>
mov    -0x8(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <main+0x115>
jmp    12b7 <main+0x187>
jmp    12bc <main+0x18c>
jmp    12c1 <main+0x191>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%esi
mov    %ecx,%edx
sub    %esi,%edx
test   %eax,%eax
js     1215 <main+0xe5>
je     12b4 <main+0x184>
cmp    %edx,%eax
je     12c2 <main+0x192>
lea    0xe85(%rip),%r14
jmp    11a8 <main+0x78>
nopw   0x0(%rax,%rax,1)
cmp    %ebx,%eax
je     12c2 <main+0x192>
movslq %eax,%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    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %ebx,%eax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0xc(%rsp)
add    $0x9,%ecx
cmp    $0x13,%ecx
jb     12c2 <main+0x192>
cmp    %ebx,%eax
jne    11a0 <main+0x70>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
jmp    11a0 <main+0x70>
mov    %ecx,0xc(%rsp)
cmp    %edx,%ecx
je     12c2 <main+0x192>
lea    0xdf2(%rip),%r14
lea    0xde6(%rip),%rbx
jmp    1244 <main+0x114>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %ebp,%ecx
je     12c2 <main+0x192>
movslq %ecx,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
cmp    %ebp,%eax
mov    %rbx,%rdi
cmovg  %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %ebp,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
mov    %ecx,0xc(%rsp)
add    $0x9,%eax
cmp    $0x13,%eax
jb     12c2 <main+0x192>
cmp    %ebp,%ecx
jne    1240 <main+0x110>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
jmp    1240 <main+0x110>
lea    0xd63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd58(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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 = [5 x i8] c"\0A-%d\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [3 x i8] c"\0A0\00"
@.str.5 = [31 x i8] c"\0AThat'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* %2)
%6 = load i32, i32* %2
%7 = call i32 @abs(i32 %6)
%8 = srem i32 %7, 10
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @abs(i32 %12)
store i32 %13, i32* %2
br label %14
14: ; preds = %45, %11
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = load i32, i32* %2
%20 = srem i32 %19, 10
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %30
27: ; preds = %18
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = sub nsw i32 %31, %32
%34 = sdiv i32 %33, 10
store i32 %34, i32* %2
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %30
br label %46
38: ; preds = %30
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %38
br label %14
46: ; preds = %37, %14
br label %83
47: ; preds = %0
%48 = load i32, i32* %2
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %82
52: ; preds = %47
%53 = load i32, i32* %2
%54 = icmp sge i32 %53, 0
br i1 %54, label %55, label %81
55: ; preds = %52
br label %56
56: ; preds = %79, %55
%57 = load i32, i32* %2
%58 = load i32, i32* %3
%59 = icmp ne i32 %57, %58
br i1 %59, label %60, label %80
60: ; preds = %56
%61 = load i32, i32* %2
%62 = srem i32 %61, 10
store i32 %62, i32* %3
%63 = load i32, i32* %3
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = sub nsw i32 %65, %66
%68 = sdiv i32 %67, 10
store i32 %68, i32* %2
%69 = load i32, i32* %2
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %60
br label %80
72: ; preds = %60
%73 = load i32, i32* %2
%74 = load i32, i32* %3
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i32, i32* %2
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %76, %72
br label %56
80: ; preds = %71, %56
br label %81
81: ; preds = %80, %52
br label %82
82: ; preds = %81, %50
br label %83
83: ; preds = %82, %46
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 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.2 = [5 x i8] c"\0A-%d\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [3 x i8] c"\0A0\00"
@str = [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 = call i32 @llvm.abs.i32(i32 %5, i1 true)
%7 = urem i32 %6, 10
%8 = icmp slt i32 %5, 0
br i1 %8, label %9, label %30
9: ; preds = %0
store i32 %6, i32* %1
%10 = icmp eq i32 %6, %7
br i1 %10, label %53, label %11
11: ; preds = %9, %27
%12 = phi i32 [ %28, %27 ], [ %6, %9 ]
%13 = srem i32 %12, 10
%14 = icmp sgt i32 %12, %13
%15 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 %13)
%17 = load i32, i32* %1
%18 = sub nsw i32 %17, %13
%19 = sdiv i32 %18, 10
store i32 %19, i32* %1
%20 = add i32 %18, 9
%21 = icmp ult i32 %20, 19
br i1 %21, label %53, label %22
22: ; preds = %11
%23 = icmp eq i32 %19, %13
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%26 = load i32, i32* %1
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ %26, %24 ], [ %19, %22 ]
%29 = icmp eq i32 %28, %13
br i1 %29, label %53, label %11
30: ; preds = %0
%31 = icmp eq i32 %5, 0
br i1 %31, label %34, label %32
32: ; preds = %30
%33 = icmp eq i32 %5, %7
br i1 %33, label %53, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %53
36: ; preds = %32, %50
%37 = phi i32 [ %51, %50 ], [ %5, %32 ]
%38 = srem i32 %37, 10
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %1
%41 = sub nsw i32 %40, %38
%42 = sdiv i32 %41, 10
store i32 %42, i32* %1
%43 = add i32 %41, 9
%44 = icmp ult i32 %43, 19
br i1 %44, label %53, label %45
45: ; preds = %36
%46 = icmp eq i32 %42, %38
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%49 = load i32, i32* %1
br label %50
50: ; preds = %47, %45
%51 = phi i32 [ %49, %47 ], [ %42, %45 ]
%52 = icmp eq i32 %51, %38
br i1 %52, label %53, label %36
53: ; preds = %36, %50, %11, %27, %32, %9, %34
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}