#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 *);
void main() {
  int n, reversed = 0, zeros = 0;
  printf("%s", "Enter the number: ");
  scanf("%d", &n);
  while (n != 0) {
    if (n % 10 == 0)
      zeros++;
    reversed = reversed * 10 + (n % 10);
    n /= 10;
  }
  while (zeros--) {
    printf("0");
  }
  printf("%d\n", reversed);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11af <main+0x8f>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1182 <main+0x62>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    115b <main+0x3b>
jmp    11b4 <main+0x94>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11db <main+0xbb>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <main+0x94>
mov    -0x8(%rbp),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xec2(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11bf <main+0x8f>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
cmp    $0x1,%esi
adc    $0x0,%ebp
lea    (%rbx,%rbx,4),%edx
lea    (%rsi,%rdx,2),%ebx
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1170 <main+0x40>
mov    %eax,0x4(%rsp)
test   %ebp,%ebp
je     11bf <main+0x8f>
nopl   (%rax)
mov    $0x30,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x80>
lea    0xe53(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [19 x i8] c"Enter the number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %27, label %9
7: ; preds = %9
store i32 %19, i32* %1
%8 = icmp eq i32 %16, 0
br i1 %8, label %27, label %22
9: ; preds = %0, %9
%10 = phi i32 [ %16, %9 ], [ 0, %0 ]
%11 = phi i32 [ %18, %9 ], [ 0, %0 ]
%12 = phi i32 [ %19, %9 ], [ %5, %0 ]
%13 = srem i32 %12, 10
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %10, %15
%17 = mul nsw i32 %11, 10
%18 = add nsw i32 %17, %13
%19 = sdiv i32 %12, 10
%20 = add i32 %12, 9
%21 = icmp ult i32 %20, 19
br i1 %21, label %7, label %9
22: ; preds = %7, %22
%23 = phi i32 [ %24, %22 ], [ %16, %7 ]
%24 = add nsw i32 %23, -1
%25 = call i32 @putchar(i32 48)
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %22
27: ; preds = %22, %0, %7
%28 = phi i32 [ %18, %7 ], [ 0, %0 ], [ %18, %22 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
ret void
}