#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 n, rem, digit, new, x;
  printf("Please enter an integer ");
  scanf("%d", &x);
  for (n = x; n > 0; n = n / 10) {
    digit = (n % 10);
    printf("%d\n", digit);
  }
  for (n = x; n < 0; n = n / 10) {
    new = n % 10;
    digit = abs(new);
    rem = abs(n);
    if (rem >= 10) {
      printf("%d\n", digit);
    }
    if (rem < 10) {
      printf("-%d\n", rem);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119f <main+0x6f>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1163 <main+0x33>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1221 <main+0xf1>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     11ee <main+0xbe>
mov    -0x10(%rbp),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xa,-0xc(%rbp)
jge    1209 <main+0xd9>
mov    -0xc(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120e <main+0xde>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11a5 <main+0x75>
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    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jle    1189 <main+0x69>
lea    0xec8(%rip),%r14
mov    $0xcccccccd,%r15d
nopl   0x0(%rax,%rax,1)
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   1030 <printf@plt>
cmp    $0x9,%ebp
mov    %ebx,%ebp
ja     1160 <main+0x40>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jns    11e1 <main+0xc1>
lea    0xe89(%rip),%r14
mov    $0xcccccccd,%r15d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%ebx
neg    %ebx
cmp    $0xfffffff7,%ebp
jae    11d1 <main+0xb1>
mov    %ebx,%ebp
imul   %r15,%rbp
shr    $0x23,%rbp
lea    0x0(%rbp,%rbp,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
neg    %ebp
cmp    $0x9,%ebx
ja     11a0 <main+0x80>
jmp    11e1 <main+0xc1>
lea    0xe44(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please enter an integer \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"-%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = load i32, i32* %6
store i32 %9, i32* %2
br label %10
10: ; preds = %18, %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
store i32 %20, i32* %2
br label %10
21: ; preds = %10
%22 = load i32, i32* %6
store i32 %22, i32* %2
br label %23
23: ; preds = %45, %21
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load i32, i32* %2
%28 = srem i32 %27, 10
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = call i32 @abs(i32 %29)
store i32 %30, i32* %4
%31 = load i32, i32* %2
%32 = call i32 @abs(i32 %31)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp sge i32 %33, 10
br i1 %34, label %35, label %38
35: ; preds = %26
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %26
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 10
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %38
br label %45
45: ; preds = %44
%46 = load i32, i32* %2
%47 = sdiv i32 %46, 10
store i32 %47, i32* %2
br label %23
48: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please enter an integer \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"-%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 sgt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ %5, %0 ]
%9 = urem i32 %8, 10
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = udiv i32 %8, 10
%12 = icmp ult i32 %8, 10
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = load i32, i32* %1
br label %15
15: ; preds = %13, %0
%16 = phi i32 [ %14, %13 ], [ %5, %0 ]
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15, %24
%19 = phi i32 [ %28, %24 ], [ %16, %15 ]
%20 = icmp ult i32 %19, -9
%21 = sub i32 0, %19
br i1 %20, label %24, label %22
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %30
24: ; preds = %18
%25 = urem i32 %21, 10
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = udiv i32 %21, 10
%28 = sub nsw i32 0, %27
%29 = icmp ult i32 %21, 10
br i1 %29, label %30, label %18
30: ; preds = %24, %22, %15
ret i32 0
}