#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, n1, n2, n3, n4, n5;
  scanf("%d", &num);
  n5 = num % 10;
  n4 = ((num % 100) - n5) / 10;
  n3 = ((num % 1000) - n5 - (n4 * 10)) / 100;
  n2 = ((num % 10000) - n5 - (n4 * 10) - (n3 * 100)) / 1000;
  n1 = num / 10000;
  if (num >= 10000)
    printf("Reverse of %d is %d%d%d%d%d", num, n5, n4, n3, n2, n1);
  else if ((num > 1000) && (num < 9999))
    printf("Reverse of %d is %d%d%d%d", num, n5, n4, n3, n2);
  else if ((num > 100) && (num < 999))
    printf("Reverse of %d is %d%d%d", num, n5, n4, n3);
  else if ((num > 10) && (num < 99))
    printf("Reverse of %d is %d%d", num, n5, n4);
  else if ((num == 10000) || (num == 1000) || (num == 100) || (num == 10))
    printf("Reverse of %d is 1", num);
  else
    printf("Reverse of %d is %d", num, n5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf52(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
imul   $0xa,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
imul   $0xa,-0x18(%rbp),%ecx
sub    %ecx,%eax
imul   $0x64,-0x14(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jl     11f5 <main+0xd5>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
mov    -0xc(%rbp),%eax
lea    0xe1a(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1306 <main+0x1e6>
cmpl   $0x3e8,-0x8(%rbp)
jle    1233 <main+0x113>
cmpl   $0x270f,-0x8(%rbp)
jge    1233 <main+0x113>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1301 <main+0x1e1>
cmpl   $0x64,-0x8(%rbp)
jle    126a <main+0x14a>
cmpl   $0x3e7,-0x8(%rbp)
jge    126a <main+0x14a>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fc <main+0x1dc>
cmpl   $0xa,-0x8(%rbp)
jle    129a <main+0x17a>
cmpl   $0x63,-0x8(%rbp)
jge    129a <main+0x17a>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f7 <main+0x1d7>
cmpl   $0x2710,-0x8(%rbp)
je     12c8 <main+0x1a8>
cmpl   $0x3e8,-0x8(%rbp)
je     12c8 <main+0x1a8>
cmpl   $0x64,-0x8(%rbp)
je     12c8 <main+0x1a8>
cmpl   $0xa,-0x8(%rbp)
jne    12de <main+0x1be>
mov    -0x8(%rbp),%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f2 <main+0x1d2>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f7 <main+0x1d7>
jmp    12fc <main+0x1dc>
jmp    1301 <main+0x1e1>
jmp    1306 <main+0x1e6>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf5d(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x14(%rsp),%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
mov    %esi,%edx
sub    %eax,%edx
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %esi,%ecx
sub    %eax,%ecx
sub    %edx,%ecx
movsbl %cl,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xa,%ecx
add    %al,%cl
movsbl %cl,%ecx
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rax
add    %edi,%eax
imul   $0x3e8,%eax,%eax
mov    %esi,%edi
sub    %eax,%edi
lea    (%rcx,%rcx,4),%eax
lea    (%rdx,%rax,2),%r9d
sub    %r9d,%edi
movswl %di,%edi
imul   $0x147b,%edi,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0x13,%edi
add    %eax,%edi
movswl %di,%r8d
imul   $0x68db8bad,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x2c,%rax
add    %edi,%eax
imul   $0x2710,%eax,%eax
mov    %esi,%edi
sub    %eax,%edi
sub    %r9d,%edi
imul   $0xffffff9c,%r8d,%eax
add    %edi,%eax
movswl %ax,%edi
imul   $0xffff8313,%edi,%edi
shr    $0x10,%edi
add    %eax,%edi
movzwl %di,%eax
movswl %ax,%edi
shr    $0xf,%eax
sar    $0x9,%edi
add    %eax,%edi
movswl %di,%r9d
cmp    $0x2710,%rsi
jl     1235 <main+0x115>
mov    %esi,%eax
mov    $0xd1b71759,%edi
imul   %rax,%rdi
shr    $0x2d,%rdi
mov    %edi,(%rsp)
lea    0xdcd(%rip),%rdi
jmp    124c <main+0x12c>
cmp    $0x3e9,%esi
jl     125a <main+0x13a>
cmp    $0x270f,%esi
je     125a <main+0x13a>
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    -0x65(%rsi),%eax
cmp    $0x381,%eax
ja     1274 <main+0x154>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1253 <main+0x133>
lea    -0xb(%rsi),%eax
cmp    $0x57,%eax
ja     128c <main+0x16c>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1253 <main+0x133>
cmp    $0xa,%esi
je     129e <main+0x17e>
cmp    $0x3e8,%esi
je     129e <main+0x17e>
cmp    $0x64,%esi
jne    12ae <main+0x18e>
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1253 <main+0x133>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1253 <main+0x133>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"Reverse of %d is %d%d%d%d%d\00"
@.str.2 = [26 x i8] c"Reverse of %d is %d%d%d%d\00"
@.str.3 = [24 x i8] c"Reverse of %d is %d%d%d\00"
@.str.4 = [22 x i8] c"Reverse of %d is %d%d\00"
@.str.5 = [19 x i8] c"Reverse of %d is 1\00"
@.str.6 = [20 x i8] c"Reverse of %d is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = srem i32 %9, 10
store i32 %10, i32* %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 100
%13 = load i32, i32* %7
%14 = sub nsw i32 %12, %13
%15 = sdiv i32 %14, 10
store i32 %15, i32* %6
%16 = load i32, i32* %2
%17 = srem i32 %16, 1000
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = load i32, i32* %6
%21 = mul nsw i32 %20, 10
%22 = sub nsw i32 %19, %21
%23 = sdiv i32 %22, 100
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = srem i32 %24, 10000
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 10
%30 = sub nsw i32 %27, %29
%31 = load i32, i32* %5
%32 = mul nsw i32 %31, 100
%33 = sub nsw i32 %30, %32
%34 = sdiv i32 %33, 1000
store i32 %34, i32* %4
%35 = load i32, i32* %2
%36 = sdiv i32 %35, 10000
store i32 %36, i32* %3
%37 = load i32, i32* %2
%38 = icmp sge i32 %37, 10000
br i1 %38, label %39, label %47
39: ; preds = %0
%40 = load i32, i32* %2
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = load i32, i32* %3
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45)
br label %106
47: ; preds = %0
%48 = load i32, i32* %2
%49 = icmp sgt i32 %48, 1000
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load i32, i32* %2
%52 = icmp slt i32 %51, 9999
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = load i32, i32* %2
%55 = load i32, i32* %7
%56 = load i32, i32* %6
%57 = load i32, i32* %5
%58 = load i32, i32* %4
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %54, i32 %55, i32 %56, i32 %57, i32 %58)
br label %105
60: ; preds = %50, %47
%61 = load i32, i32* %2
%62 = icmp sgt i32 %61, 100
br i1 %62, label %63, label %72
63: ; preds = %60
%64 = load i32, i32* %2
%65 = icmp slt i32 %64, 999
br i1 %65, label %66, label %72
66: ; preds = %63
%67 = load i32, i32* %2
%68 = load i32, i32* %7
%69 = load i32, i32* %6
%70 = load i32, i32* %5
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %67, i32 %68, i32 %69, i32 %70)
br label %104
72: ; preds = %63, %60
%73 = load i32, i32* %2
%74 = icmp sgt i32 %73, 10
br i1 %74, label %75, label %83
75: ; preds = %72
%76 = load i32, i32* %2
%77 = icmp slt i32 %76, 99
br i1 %77, label %78, label %83
78: ; preds = %75
%79 = load i32, i32* %2
%80 = load i32, i32* %7
%81 = load i32, i32* %6
%82 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %79, i32 %80, i32 %81)
br label %103
83: ; preds = %75, %72
%84 = load i32, i32* %2
%85 = icmp eq i32 %84, 10000
br i1 %85, label %95, label %86
86: ; preds = %83
%87 = load i32, i32* %2
%88 = icmp eq i32 %87, 1000
br i1 %88, label %95, label %89
89: ; preds = %86
%90 = load i32, i32* %2
%91 = icmp eq i32 %90, 100
br i1 %91, label %95, label %92
92: ; preds = %89
%93 = load i32, i32* %2
%94 = icmp eq i32 %93, 10
br i1 %94, label %95, label %98
95: ; preds = %92, %89, %86, %83
%96 = load i32, i32* %2
%97 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %96)
br label %102
98: ; preds = %92
%99 = load i32, i32* %2
%100 = load i32, i32* %7
%101 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %99, i32 %100)
br label %102
102: ; preds = %98, %95
br label %103
103: ; preds = %102, %78
br label %104
104: ; preds = %103, %66
br label %105
105: ; preds = %104, %53
br label %106
106: ; preds = %105, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"Reverse of %d is %d%d%d%d%d\00"
@.str.2 = [26 x i8] c"Reverse of %d is %d%d%d%d\00"
@.str.3 = [24 x i8] c"Reverse of %d is %d%d%d\00"
@.str.4 = [22 x i8] c"Reverse of %d is %d%d\00"
@.str.5 = [19 x i8] c"Reverse of %d is 1\00"
@.str.6 = [20 x i8] c"Reverse of %d is %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 = srem i32 %4, 10
%6 = srem i32 %4, 100
%7 = sub nsw i32 %6, %5
%8 = trunc i32 %7 to i8
%9 = sdiv i8 %8, 10
%10 = sext i8 %9 to i32
%11 = srem i32 %4, 1000
%12 = mul nsw i32 %10, 10
%13 = add nsw i32 %12, %5
%14 = sub nsw i32 %11, %13
%15 = trunc i32 %14 to i16
%16 = sdiv i16 %15, 100
%17 = sext i16 %16 to i32
%18 = srem i32 %4, 10000
%19 = sub nsw i32 %18, %13
%20 = mul nsw i32 %17, -100
%21 = add nsw i32 %19, %20
%22 = trunc i32 %21 to i16
%23 = sdiv i16 %22, 1000
%24 = sext i16 %23 to i32
%25 = icmp sgt i32 %4, 9999
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = udiv i32 %4, 10000
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17, i32 %24, i32 %27)
br label %50
29: ; preds = %0
%30 = icmp sgt i32 %4, 1000
%31 = icmp ne i32 %4, 9999
%32 = and i1 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17, i32 %24)
br label %50
35: ; preds = %29
%36 = add i32 %4, -101
%37 = icmp ult i32 %36, 898
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17)
br label %50
40: ; preds = %35
%41 = add i32 %4, -11
%42 = icmp ult i32 %41, 88
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %4, i32 %5, i32 %10)
br label %50
45: ; preds = %40
switch i32 %4, label %48 [
i32 1000, label %46
i32 100, label %46
i32 10, label %46
]
46: ; preds = %45, %45, %45
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %4)
br label %50
48: ; preds = %45
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %4, i32 %5)
br label %50
50: ; preds = %33, %43, %48, %46, %38, %26
ret i32 0
}