#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, int);
int reverse_number(int number) {
  int original, count;
  int reverseNumber = 0;
  original = number;
  do {
    reverseNumber = reverseNumber * 10 + number % 10;
    number = number / 10;
    if (number == 0) {
      printf("%d       %d\n", original, reverseNumber);
      break;
    }
  } while (number);
  return reverseNumber;
}


x86 assembly (clang, -O0):
<reverse_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1171 <reverse_number+0x61>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    1180 <reverse_number+0x70>
jmp    1176 <reverse_number+0x66>
cmpl   $0x0,-0x4(%rbp)
jne    1128 <reverse_number+0x18>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_number>:
push   %rbx
mov    %edi,%r8d
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%ebx
sub    %ecx,%ebx
add    $0x9,%eax
cmp    $0x13,%eax
jb     1187 <reverse_number+0x77>
mov    %r8d,%eax
nop
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
lea    (%rcx,%rdx,1),%eax
lea    (%rbx,%rbx,4),%r9d
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%ebx
lea    (%rbx,%r9,2),%ebx
add    %edx,%ecx
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1140 <reverse_number+0x30>
lea    0xe72(%rip),%rdi
mov    %r8d,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"%d %d\0A\00"
define i32 @reverse_number(i32 %0) {
%2 = srem i32 %0, 10
%3 = add i32 %0, 9
%4 = icmp ult i32 %3, 19
br i1 %4, label %5, label %8
5: ; preds = %8, %1
%6 = phi i32 [ %2, %1 ], [ %14, %8 ]
%7 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %6)
ret i32 %6
8: ; preds = %1, %8
%9 = phi i32 [ %14, %8 ], [ %2, %1 ]
%10 = phi i32 [ %11, %8 ], [ %0, %1 ]
%11 = sdiv i32 %10, 10
%12 = mul nsw i32 %9, 10
%13 = srem i32 %11, 10
%14 = add nsw i32 %12, %13
%15 = add nsw i32 %11, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %5, label %8
}