#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("Enter an integer > ");
  scanf("%d", &n);
  status = n;
  test = status;
  printf("\n");
  if (n < 0)
    n = n * -1;
  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    0xed0(%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    0xed7(%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)
jmp    117d <main+0x5d>
cmpl   $0x0,-0x8(%rbp)
je     11dd <main+0xbd>
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    11c7 <main+0xa7>
cmpl   $0x0,-0x14(%rbp)
jne    11c7 <main+0xa7>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117d <main+0x5d>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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    0xeb7(%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     1183 <main+0x43>
test   %ebp,%ebp
jne    118d <main+0x4d>
jmp    11ec <main+0xac>
neg    %eax
mov    %eax,0xc(%rsp)
test   %ebp,%ebp
je     11ec <main+0xac>
lea    0xe83(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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     11ec <main+0xac>
mov    0xc(%rsp),%eax
jmp    11a0 <main+0x60>
lea    0xe28(%rip),%rdi
call   1040 <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 = [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 ([20 x i8], [20 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
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %37
20: ; preds = %17
%21 = load i32, i32* %5
%22 = srem i32 %21, 10
store i32 %22, i32* %3
%23 = load i32, i32* %5
%24 = sdiv i32 %23, 10
store i32 %24, i32* %5
%25 = load i32, i32* %5
store i32 %25, i32* %2
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %20
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %3
%33 = mul nsw i32 -1, %32
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %28, %20
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %17
37: ; preds = %17
%38 = 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 = [20 x i8] c"Enter 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 ([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 = 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 %11
11: ; preds = %9, %0
%12 = phi i32 [ %10, %9 ], [ %7, %0 ]
%13 = icmp eq i32 %5, 0
br i1 %13, label %28, label %14
14: ; preds = %11
%15 = icmp slt i32 %5, 0
br label %16
16: ; preds = %26, %14
%17 = phi i32 [ %27, %26 ], [ %12, %14 ]
%18 = srem i32 %17, 10
%19 = sdiv i32 %17, 10
store i32 %19, i32* %1
%20 = add i32 %17, 9
%21 = icmp ult i32 %20, 19
%22 = select i1 %15, i1 %21, i1 false
%23 = sub nsw i32 0, %18
%24 = select i1 %22, i32 %23, i32 %18
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br i1 %21, label %28, label %26
26: ; preds = %16
%27 = load i32, i32* %1
br label %16
28: ; preds = %16, %11
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}