#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int test, remainder, status, n;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  status = n;
  test = status;
  printf("\n");
  if (n < 0)
    n = n * -1;
  if (n == 0) {
    printf("%d\n", n);
    printf("That's all, have a nice day!\n");
    return 0;
  }
  while (test != 0) {
    remainder = n % 10;
    n = n / 10;
    test = n;
    if ((status < 0) && (n == 0))
      remainder = -1 * remainder;
    printf("%d\n", remainder);
  }
  printf("That'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    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1178 <main+0x58>
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ad <main+0x8d>
mov    -0x14(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1227 <main+0x107>
jmp    11b2 <main+0x92>
cmpl   $0x0,-0x8(%rbp)
je     1212 <main+0xf2>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11fc <main+0xdc>
cmpl   $0x0,-0x14(%rbp)
jne    11fc <main+0xdc>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <main+0x92>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1191 <main+0x51>
jne    1197 <main+0x57>
lea    0xe92(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11fc <main+0xbc>
neg    %eax
mov    %eax,0xc(%rsp)
test   %ebp,%ebp
je     11fc <main+0xbc>
lea    0xe76(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %ebx,%edx
sub    %ecx,%edx
add    $0x9,%ebx
mov    %edx,%esi
neg    %esi
cmp    $0x13,%ebx
cmovae %edx,%esi
test   %ebp,%ebp
mov    %eax,0xc(%rsp)
cmovns %edx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x13,%ebx
jb     11fc <main+0xbc>
mov    0xc(%rsp),%eax
jmp    11b0 <main+0x70>
lea    0xe19(%rip),%rdi
call   1040 <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 = [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
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
store i32 %8, i32* %4
%9 = load i32, i32* %4
store i32 %9, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %5
%15 = mul nsw i32 %14, -1
store i32 %15, i32* %5
br label %16
16: ; preds = %13, %0
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %46
23: ; preds = %16
br label %24
24: ; preds = %41, %23
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load i32, i32* %5
%29 = srem i32 %28, 10
store i32 %29, i32* %3
%30 = load i32, i32* %5
%31 = sdiv i32 %30, 10
store i32 %31, i32* %5
%32 = load i32, i32* %5
store i32 %32, i32* %2
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %27
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %3
%40 = mul nsw i32 -1, %39
store i32 %40, i32* %3
br label %41
41: ; preds = %38, %35, %27
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %24
44: ; preds = %24
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %46
46: ; preds = %44, %19
%47 = load i32, i32* %1
ret i32 %47
}

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.5 = [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 = load i32, i32* %1
%6 = call i32 @putchar(i32 10)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = sub nsw i32 0, %7
store i32 %10, i32* %1
br label %13
11: ; preds = %0
%12 = icmp eq i32 %7, 0
br i1 %12, label %18, label %13
13: ; preds = %9, %11
%14 = phi i32 [ %10, %9 ], [ %7, %11 ]
%15 = icmp eq i32 %5, 0
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = icmp slt i32 %5, 0
br label %20
18: ; preds = %11
%19 = 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 %32
20: ; preds = %30, %16
%21 = phi i32 [ %31, %30 ], [ %14, %16 ]
%22 = srem i32 %21, 10
%23 = sdiv i32 %21, 10
store i32 %23, i32* %1
%24 = add i32 %21, 9
%25 = icmp ult i32 %24, 19
%26 = select i1 %17, i1 %25, i1 false
%27 = sub nsw i32 0, %22
%28 = select i1 %26, i32 %27, i32 %22
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br i1 %25, label %32, label %30
30: ; preds = %20
%31 = load i32, i32* %1
br label %20
32: ; preds = %20, %13, %18
%33 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0), %18 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0), %20 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
ret i32 0
}