#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_input, num_input2, digit;
  printf("Enter an integer > ");
  scanf("%d", &num_input);
  num_input2 = num_input;
  while (num_input2 != 0) {
    digit = abs(num_input2 % 10);
    num_input2 = (num_input2 / 10);
    if ((num_input2 == 0) && (num_input < 0)) {
      digit = digit * (-1);
    }
    printf("\n%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    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11c1 <main+0x91>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <abs@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11ab <main+0x7b>
cmpl   $0x0,-0x8(%rbp)
jge    11ab <main+0x7b>
imul   $0xffffffff,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1163 <main+0x33>
lea    0xe54(%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    0xec7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1224 <main+0xf4>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
sub    %eax,%ecx
mov    %ecx,%eax
neg    %eax
cmovs  %ecx,%eax
lea    0x9(%rbx),%ebp
mov    %eax,%esi
neg    %esi
cmp    $0xfffffff7,%ebx
cmovb  %eax,%esi
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x13,%ebp
jb     1224 <main+0xf4>
lea    0xe66(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
lea    (%rax,%rcx,1),%ebx
movslq %ebx,%rdx
imul   $0x66666667,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%edx
mov    %edx,%edi
neg    %edi
cmovs  %edx,%edi
mov    %edi,%esi
neg    %esi
cmpl   $0x0,0xc(%rsp)
cmovns %edi,%esi
lea    (%rax,%rcx,1),%ebp
add    $0x9,%ebp
cmp    $0x13,%ebp
cmovae %edi,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x12,%ebp
ja     11c0 <main+0x90>
lea    0xdf1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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