#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(void) {
  int n, i, j;
  printf("\nEnter an integer > ");
  scanf("%i", &n);
  printf("\n");
  i = n;
  while (i < 0) {
    j = i % -10;
    printf("%i\n", -j);
    i = i / 10;
    if (i > -10) {
      j = i % -10;
      printf("%i\n", j);
      break;
    }
  }
  while (i > 0) {
    j = i % 10;
    printf("%i\n", j);
    i = i / 10;
  }
  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    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11cd <main+0xad>
mov    -0xc(%rbp),%eax
mov    $0xfffffff6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
xor    %esi,%esi
sub    -0x10(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0xfffffff6,-0xc(%rbp)
jle    11c8 <main+0xa8>
mov    -0xc(%rbp),%eax
mov    $0xfffffff6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <main+0xad>
jmp    1161 <main+0x41>
jmp    11d2 <main+0xb2>
cmpl   $0x0,-0xc(%rbp)
jle    120e <main+0xee>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    11d2 <main+0xb2>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%ebp
lea    0xe9d(%rip),%r14
mov    $0xcccccccd,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
jns    11e6 <main+0xa6>
mov    %ebp,%esi
neg    %esi
mov    %rsi,%rbx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
neg    %eax
cmp    $0xffffff9d,%ebp
mov    %eax,%ebp
jb     1190 <main+0x50>
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%esi
sub    %ebx,%esi
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1225 <main+0xe5>
je     1225 <main+0xe5>
lea    0xe29(%rip),%r14
mov    $0xcccccccd,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%ebx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x9,%ebp
mov    %ebx,%ebp
ja     1200 <main+0xc0>
lea    0xdf0(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%i\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
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
store i32 %8, i32* %3
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32, i32* %3
%14 = srem i32 %13, -10
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = sub nsw i32 0, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 10
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, -10
br i1 %21, label %22, label %27
22: ; preds = %12
%23 = load i32, i32* %3
%24 = srem i32 %23, -10
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %28
27: ; preds = %12
br label %9
28: ; preds = %22, %9
br label %29
29: ; preds = %32, %28
%30 = load i32, i32* %3
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %3
%34 = srem i32 %33, 10
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %3
%38 = sdiv i32 %37, 10
store i32 %38, i32* %3
br label %29
39: ; preds = %29
%40 = 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"%i\00"
@.str.3 = [4 x i8] c"%i\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
br label %7
7: ; preds = %10, %0
%8 = phi i32 [ %6, %0 ], [ %15, %10 ]
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = sub i32 0, %8
%12 = urem i32 %11, 10
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = udiv i32 %11, 10
%15 = sub nsw i32 0, %14
%16 = icmp ugt i32 %8, -100
br i1 %16, label %17, label %7
17: ; preds = %10
%18 = urem i32 %14, 10
%19 = sub nsw i32 0, %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %29
21: ; preds = %7
%22 = icmp eq i32 %8, 0
br i1 %22, label %29, label %23
23: ; preds = %21, %23
%24 = phi i32 [ %27, %23 ], [ %8, %21 ]
%25 = urem i32 %24, 10
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = udiv i32 %24, 10
%28 = icmp ult i32 %24, 10
br i1 %28, label %29, label %23
29: ; preds = %23, %17, %21
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}