#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 value, digit;
  printf("\nEnter an integer > ");
  scanf("%d", &value);
  printf("\n");
  if (value >= 0) {
    while (value != 0) {
      digit = value % 10;
      value = value / 10;
      printf("%d\n", digit);
    }
  }
  if (value < 0) {
    while (value < -10) {
      digit = abs(value % 10);
      value = value / 10;
      printf("%d\n", digit);
    }
    digit = value % 10;
    printf("%d\n", digit);
  }
  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    0xed4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11bb <main+0x8b>
jmp    117a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
je     11b6 <main+0x86>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117a <main+0x4a>
jmp    11bb <main+0x8b>
cmpl   $0x0,-0x8(%rbp)
jge    122c <main+0xfc>
jmp    11ca <main+0x9a>
cmpl   $0xfffffff6,-0x8(%rbp)
jge    120d <main+0xdd>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ca <main+0x9a>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11b7 <main+0x77>
lea    0xe9c(%rip),%rbx
nopl   0x0(%rax)
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jne    1180 <main+0x40>
jmp    122a <main+0xea>
jns    122a <main+0xea>
cmp    $0xfffffff5,%esi
ja     11fe <main+0xbe>
mov    $0xcccccccd,%r14d
lea    0xe4d(%rip),%rbx
nopl   0x0(%rax,%rax,1)
neg    %esi
mov    %rsi,%rax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
neg    %eax
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
cmp    $0xfffffff6,%esi
jl     11d0 <main+0x90>
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
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [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
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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %0
br label %10
10: ; preds = %13, %9
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 10
store i32 %17, i32* %2
%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)
br label %10
20: ; preds = %10
br label %21
21: ; preds = %20, %0
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %21
br label %25
25: ; preds = %28, %24
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, -10
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32, i32* %2
%30 = srem i32 %29, 10
%31 = call i32 @abs(i32 %30)
store i32 %31, i32* %3
%32 = load i32, i32* %2
%33 = sdiv i32 %32, 10
store i32 %33, i32* %2
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %25
36: ; preds = %25
%37 = load i32, i32* %2
%38 = srem i32 %37, 10
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %36, %21
%42 = 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 = [21 x i8] c"\0AEnter an integer > \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"
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 sgt i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0, %8
%9 = phi i32 [ %13, %8 ], [ %6, %0 ]
%10 = srem i32 %9, 10
%11 = sdiv i32 %9, 10
store i32 %11, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %32, label %8
15: ; preds = %0
%16 = icmp slt i32 %6, 0
br i1 %16, label %17, label %32
17: ; preds = %15
%18 = icmp ult i32 %6, -10
br i1 %18, label %19, label %28
19: ; preds = %17, %19
%20 = phi i32 [ %26, %19 ], [ %6, %17 ]
%21 = sub i32 0, %20
%22 = urem i32 %21, 10
%23 = udiv i32 %21, 10
%24 = sub nsw i32 0, %23
store i32 %24, i32* %1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%26 = load i32, i32* %1
%27 = icmp slt i32 %26, -10
br i1 %27, label %19, label %28
28: ; preds = %19, %17
%29 = phi i32 [ %6, %17 ], [ %26, %19 ]
%30 = srem i32 %29, 10
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %8, %28, %15
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}