#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 number, right_digit;
  bool is_negative;
  printf("Enter your number to reverse: ");
  scanf("%i", &number);
  is_negative = 0 > number;
  do {
    right_digit = number % 10;
    if (is_negative)
      printf("%i", -right_digit);
    else
      printf("%i", right_digit);
    number /= 10;
  } while (number);
  if (is_negative)
    printf("-\n");
  else
    printf("\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    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     118d <main+0x6d>
xor    %esi,%esi
sub    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <main+0x7e>
mov    -0xc(%rbp),%esi
lea    0xe88(%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    115d <main+0x3d>
cmpl   $0x0,-0x10(%rbp)
je     11d3 <main+0xb3>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e1 <main+0xc1>
lea    0xe49(%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   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec7(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%eax
jmp    11a1 <main+0x61>
nopl   (%rax)
neg    %esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x9,%ecx
cmp    $0x13,%ecx
jb     11fe <main+0xbe>
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
test   %ebp,%ebp
js     1170 <main+0x30>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    11a1 <main+0x61>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    120a <main+0xca>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter your number to reverse: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [3 x i8] c"-\0A\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
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 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)
%7 = load i32, i32* %2
%8 = icmp sgt i32 0, %7
%9 = zext i1 %8 to i32
store i32 %9, i32* %4
br label %10
10: ; preds = %25, %0
%11 = load i32, i32* %2
%12 = srem i32 %11, 10
store i32 %12, i32* %3
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %3
%17 = sub nsw i32 0, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %22
19: ; preds = %10
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 10
store i32 %24, i32* %2
br label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 0
br i1 %27, label %10, label %28
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %35
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
ret i32 0
}

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