#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 negative, integer, i, digit;
  printf("\nEnter an integer > ");
  scanf("\n%d", &integer);
  negative = integer;
  for (i = 1; i <= 10; i += 1) {
    if ((i != 10) && (negative < 0)) {
      digit = (-1 * integer) % 10;
    } else {
      digit = integer % 10;
    }
    integer = integer / 10;
    printf("\n%d", digit);
  }
  printf("\nThat'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    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jg     11ca <main+0xaa>
cmpl   $0xa,-0x10(%rbp)
je     118f <main+0x6f>
cmpl   $0x0,-0x8(%rbp)
jge    118f <main+0x6f>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
jmp    119d <main+0x7d>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <main+0x3a>
lea    0xe48(%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   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    $0x9,%ebp
mov    0x4(%rsp),%r15d
mov    %r15d,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%ebx
mov    %eax,%ecx
neg    %ecx
test   %r15d,%r15d
cmovns %eax,%ecx
add    $0xffffffff,%ebp
cmovae %eax,%ecx
movslq %ecx,%rsi
imul   $0x66666667,%rsi,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     11ce <main+0x9e>
mov    0x4(%rsp),%eax
jmp    1170 <main+0x40>
lea    0xe44(%rip),%rdi
call   1030 <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 = [4 x i8] c"\0A%d\00"
@.str.2 = [31 x i8] c"\0AThat'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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
store i32 %8, i32* %2
store i32 1, i32* %4
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 10
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %3
%20 = mul nsw i32 -1, %19
%21 = srem i32 %20, 10
store i32 %21, i32* %5
br label %25
22: ; preds = %15, %12
%23 = load i32, i32* %3
%24 = srem i32 %23, 10
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %18
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 10
store i32 %27, i32* %3
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %9
33: ; preds = %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [4 x i8] c"\0A%d\00"
@str = [30 x i8] c"\0AThat'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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
br label %7
7: ; preds = %19, %0
%8 = phi i32 [ %5, %0 ], [ %20, %19 ]
%9 = phi i32 [ 1, %0 ], [ %17, %19 ]
%10 = icmp ne i32 %9, 10
%11 = select i1 %10, i1 %6, i1 false
%12 = sub nsw i32 0, %8
%13 = select i1 %11, i32 %12, i32 %8
%14 = srem i32 %13, 10
%15 = sdiv i32 %8, 10
store i32 %15, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%17 = add nuw nsw i32 %9, 1
%18 = icmp eq i32 %17, 11
br i1 %18, label %21, label %19
19: ; preds = %7
%20 = load i32, i32* %1
br label %7
21: ; preds = %7
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}