#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);
    }
  } else if (value < 0) {
    while (value < -10) {
      digit = abs(value % 10);
      value = value / 10;
      printf("%d\n", digit);
    }
  } else if (value == 0) {
    digit = 0;
    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)
jle    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    123e <main+0x10e>
cmpl   $0x0,-0x8(%rbp)
jge    1212 <main+0xe2>
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>
jmp    1239 <main+0x109>
cmpl   $0x0,-0x8(%rbp)
jne    1234 <main+0x104>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1239 <main+0x109>
jmp    123e <main+0x10e>
lea    0xdd7(%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    120e <main+0xce>
js     11cb <main+0x8b>
lea    0xe58(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120e <main+0xce>
cmp    $0xfffffff5,%esi
ja     120e <main+0xce>
mov    $0xcccccccd,%r14d
lea    0xe3b(%rip),%rbx
nopl   (%rax)
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     11e0 <main+0xa0>
lea    0xe07(%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 sgt 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 %45
21: ; preds = %0
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %37
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
br label %44
37: ; preds = %21
%38 = load i32, i32* %2
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
store i32 0, i32* %3
%41 = load i32, i32* %3
%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, %37
br label %44
44: ; preds = %43, %36
br label %45
45: ; preds = %44, %20
%46 = 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 %30, label %8
15: ; preds = %0
%16 = icmp slt i32 %6, 0
br i1 %16, label %17, label %28
17: ; preds = %15
%18 = icmp ult i32 %6, -10
br i1 %18, label %19, label %30
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 %30
28: ; preds = %15
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %30
30: ; preds = %19, %8, %17, %28
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}