#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() {
  int num, r;
  scanf("%d", &num);
  if (num < 0)
    printf("-");
  num = abs(num);
  while (num > 0) {
    r = num % 10;
    num = num / 10;
    printf("%d", r);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1167 <main+0x37>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11ae <main+0x7e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1172 <main+0x42>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jns    115b <main+0x2b>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
mov    %esi,0x4(%rsp)
jae    11a8 <main+0x78>
mov    $0xcccccccd,%r14d
lea    0xe8b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,%eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* %2
%11 = call i32 @abs(i32 %10)
store i32 %11, i32* %2
br label %12
12: ; preds = %15, %9
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %2
%17 = srem i32 %16, 10
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = sdiv i32 %18, 10
store i32 %19, i32* %2
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %12
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @putchar(i32 45)
%8 = load i32, i32* %1
br label %9
9: ; preds = %6, %0
%10 = phi i32 [ %8, %6 ], [ %4, %0 ]
%11 = call i32 @llvm.abs.i32(i32 %10, i1 true)
store i32 %11, i32* %1
%12 = icmp eq i32 %10, 0
br i1 %12, label %20, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %18, %13 ], [ %11, %9 ]
%15 = urem i32 %14, 10
%16 = udiv i32 %14, 10
store i32 %16, i32* %1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %13, label %20
20: ; preds = %13, %9
%21 = call i32 @putchar(i32 10)
ret i32 0
}