#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 number, digit, j, digit1;
  printf("Enter an integer > ");
  scanf("%d", &number);
  printf("\n");
  j = 10;
  if (number == 0) {
    printf("0\n");
  }
  while (number != 0) {
    digit = number % j;
    if (digit < 0 && abs(number * 10) < 100) {
      printf("%d\n", digit);
      break;
    } else
      digit1 = abs(digit);
    printf("%d\n", digit1);
    number = number / 10;
  }
  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    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xa,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118a <main+0x5a>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118f <main+0x5f>
cmpl   $0x0,-0x8(%rbp)
je     1204 <main+0xd4>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11d5 <main+0xa5>
imul   $0xa,-0x8(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x64,%eax
jge    11d5 <main+0xa5>
mov    -0xc(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1204 <main+0xd4>
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    118f <main+0x5f>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    118e <main+0x4e>
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1217 <main+0xd7>
lea    0xe82(%rip),%rbx
jmp    11d8 <main+0x98>
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
neg    %eax
cmovs  %esi,%eax
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0xc(%rsp)
add    $0x9,%ecx
cmp    $0x12,%ecx
jbe    1217 <main+0xd7>
movslq %eax,%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
jns    11a0 <main+0x60>
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
cmp    $0x63,%ecx
ja     11a0 <main+0x60>
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdfd(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 = [3 x i8] c"0\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [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* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 10, i32* %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
br label %14
14: ; preds = %34, %13
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = load i32, i32* %2
%25 = mul nsw i32 %24, 10
%26 = call i32 @abs(i32 %25)
%27 = icmp slt i32 %26, 100
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %39
31: ; preds = %23, %17
%32 = load i32, i32* %3
%33 = call i32 @abs(i32 %32)
store i32 %33, i32* %5
br label %34
34: ; preds = %31
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %2
%38 = sdiv i32 %37, 10
store i32 %38, i32* %2
br label %14
39: ; preds = %28, %14
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, 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.4 = [4 x i8] c"%d\0A\00"
@str = [29 x i8] c"That's all, have a nice day!\00"
@str.6 = [2 x i8] c"0\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 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %0, %8
%13 = phi i32 [ %6, %0 ], [ %10, %8 ]
br label %14
14: ; preds = %12, %24
%15 = phi i32 [ %28, %24 ], [ %13, %12 ]
%16 = srem i32 %15, 10
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = mul nsw i32 %15, 10
%20 = call i32 @llvm.abs.i32(i32 %19, i1 true)
%21 = icmp ult i32 %20, 100
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %31
24: ; preds = %18, %14
%25 = call i32 @llvm.abs.i32(i32 %16, i1 true)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
%28 = sdiv i32 %27, 10
store i32 %28, i32* %1
%29 = add i32 %27, 9
%30 = icmp ult i32 %29, 19
br i1 %30, label %31, label %14
31: ; preds = %24, %8, %22
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}