#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 n, rem, digit, new, x;
  printf("\nEnter an integer > ");
  scanf("%d", &x);
  if (x == 0) {
    printf("\n0");
  }
  for (n = x; n > 0; n = n / 10) {
    digit = (n % 10);
    printf("\n%d", digit);
  }
  for (n = x; n < 0; n = n / 10) {
    new = n % 10;
    digit = abs(new);
    rem = abs(n);
    if (rem >= 10) {
      printf("\n%d", digit);
    }
    if (rem < 10) {
      printf("\n-%d", rem);
    }
  }
  printf("\nThat's all, have a nice day!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1175 <main+0x45>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11b7 <main+0x87>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    117b <main+0x4b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1239 <main+0x109>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     1206 <main+0xd6>
mov    -0x10(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xa,-0xc(%rbp)
jge    1221 <main+0xf1>
mov    -0xc(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1226 <main+0xf6>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11bd <main+0x8d>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
je     116c <main+0x3c>
test   %ebp,%ebp
jg     1182 <main+0x52>
test   %ebp,%ebp
jns    1211 <main+0xe1>
jmp    11bd <main+0x8d>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jle    1162 <main+0x32>
lea    0xe8f(%rip),%r14
mov    $0xcccccccd,%r15d
nop
mov    %ebp,%ebx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebp
mov    %ebx,%ebp
ja     1190 <main+0x60>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jns    1211 <main+0xe1>
lea    0xe54(%rip),%r14
mov    $0xcccccccd,%r15d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%ebx
neg    %ebx
cmp    $0xfffffff7,%ebp
jae    1201 <main+0xd1>
mov    %ebx,%ebp
imul   %r15,%rbp
shr    $0x23,%rbp
lea    0x0(%rbp,%rbp,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
neg    %ebp
cmp    $0x9,%ebx
ja     11d0 <main+0xa0>
jmp    1211 <main+0xe1>
lea    0xe14(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 = [3 x i8] c"\0A0\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [5 x i8] c"\0A-%d\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
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = load i32, i32* %6
%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.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i32, i32* %6
store i32 %14, i32* %2
br label %15
15: ; preds = %23, %13
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32, i32* %2
%20 = srem i32 %19, 10
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %2
%25 = sdiv i32 %24, 10
store i32 %25, i32* %2
br label %15
26: ; preds = %15
%27 = load i32, i32* %6
store i32 %27, i32* %2
br label %28
28: ; preds = %50, %26
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %53
31: ; preds = %28
%32 = load i32, i32* %2
%33 = srem i32 %32, 10
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = call i32 @abs(i32 %34)
store i32 %35, i32* %4
%36 = load i32, i32* %2
%37 = call i32 @abs(i32 %36)
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = icmp sge i32 %38, 10
br i1 %39, label %40, label %43
40: ; preds = %31
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %31
%44 = load i32, i32* %3
%45 = icmp slt i32 %44, 10
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %43
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = sdiv i32 %51, 10
store i32 %52, i32* %2
br label %28
53: ; preds = %28
%54 = 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 = [3 x i8] c"\0A0\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [5 x i8] c"\0A-%d\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 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, 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 [ %17, %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 = udiv i32 %14, 10
%18 = icmp ult i32 %14, 10
br i1 %18, label %19, label %13
19: ; preds = %13
%20 = load i32, i32* %1
br label %21
21: ; preds = %19, %10
%22 = phi i32 [ %20, %19 ], [ %11, %10 ]
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %21, %30
%25 = phi i32 [ %34, %30 ], [ %22, %21 ]
%26 = icmp ult i32 %25, -9
%27 = sub i32 0, %25
br i1 %26, label %30, label %28
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %36
30: ; preds = %24
%31 = urem i32 %27, 10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = udiv i32 %27, 10
%34 = sub nsw i32 0, %33
%35 = icmp ult i32 %27, 10
br i1 %35, label %36, label %24
36: ; preds = %30, %28, %21
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}