#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 userint, remainder;
  printf("Enter an integer > ");
  scanf("%d", &userint);
  printf("\n");
  while (userint != 0) {
    remainder = userint % 10;
    userint = (userint - remainder) / 10;
    if (userint < 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    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ae <main+0x8e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1198 <main+0x78>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115b <main+0x3b>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%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
je     11c0 <main+0x80>
lea    0xe9a(%rip),%rbx
nopl   (%rax)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%edi
sub    %edx,%edi
mov    %ecx,0xc(%rsp)
mov    %edi,%esi
neg    %esi
cmp    $0xfffffff7,%eax
cmovge %edi,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1180 <main+0x40>
lea    0xe54(%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 = [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
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 10
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = sub nsw i32 %13, %14
%16 = sdiv i32 %15, 10
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = load i32, i32* %3
%21 = mul nsw i32 -1, %20
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %10
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %7
25: ; preds = %7
%26 = 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 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %16, %8 ], [ %6, %0 ]
%10 = srem i32 %9, 10
%11 = sdiv i32 %9, 10
store i32 %11, i32* %1
%12 = icmp slt i32 %9, -9
%13 = sub nsw i32 0, %10
%14 = select i1 %12, i32 %13, i32 %10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %8
18: ; preds = %8, %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}