#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 numero, digito_derecho, negativo = 0;
  printf("Introduce tu numero.\n");
  scanf("%i", &numero);
  do {
    if (numero < 0) {
      numero = -numero;
      negativo = 1;
    }
    digito_derecho = numero % 10;
    printf("%i", digito_derecho);
    numero = numero / 10;
  } while (numero != 0);
  if (negativo == 1)
    printf("-");
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    116d <main+0x4d>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1154 <main+0x34>
cmpl   $0x1,-0x10(%rbp)
jne    11bc <main+0x9c>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    $0xcccccccd,%ebx
xor    %ebp,%ebp
jmp    11c0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0xc(%rsp)
add    $0x9,%eax
cmp    $0x12,%eax
jbe    11d1 <main+0x91>
test   %esi,%esi
jns    1180 <main+0x40>
neg    %esi
mov    %esi,0xc(%rsp)
mov    $0x1,%ebp
jmp    1180 <main+0x40>
cmp    $0x1,%ebp
jne    11e0 <main+0xa0>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%i\00"
@str = [21 x i8] c"Introduce tu numero.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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
br label %6
6: ; preds = %12, %0
%7 = phi i32 [ %18, %12 ], [ %5, %0 ]
%8 = phi i32 [ %14, %12 ], [ 0, %0 ]
%9 = icmp slt i32 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = sub nsw i32 0, %7
store i32 %11, i32* %1
br label %12
12: ; preds = %10, %6
%13 = phi i32 [ %11, %10 ], [ %7, %6 ]
%14 = phi i32 [ 1, %10 ], [ %8, %6 ]
%15 = urem i32 %13, 10
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = sdiv i32 %17, 10
store i32 %18, i32* %1
%19 = add i32 %17, 9
%20 = icmp ult i32 %19, 19
br i1 %20, label %21, label %6
21: ; preds = %12
%22 = icmp eq i32 %14, 1
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 @putchar(i32 45)
br label %25
25: ; preds = %23, %21
%26 = call i32 @putchar(i32 10)
ret i32 0
}