#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() {
  int n, i, a, b;
  printf("Enter the number");
  scanf("%d", &n);
  for (i = 1; i <= 5; i++) {
    a = n % 10;
    b = n / 10;
    if (a == 0) {
      break;
    }
    n = b;
  }
  if (i == 1) {
    printf("The numbr is in Ten's");
  } else if (i == 2) {
    printf("The numbr is in Hundred's");
  } else if (i == 3) {
    printf("The number is in Thousand's");
  } else if (i == 4) {
    printf("The number is in Ten thousand's");
  } else if (i == 5) {
    printf("The numbr is in lakh's ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     119b <main+0x7b>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1187 <main+0x67>
jmp    119b <main+0x7b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
cmpl   $0x1,-0xc(%rbp)
jne    11b6 <main+0x96>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
jmp    1231 <main+0x111>
cmpl   $0x2,-0xc(%rbp)
jne    11d1 <main+0xb1>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0x10c>
cmpl   $0x3,-0xc(%rbp)
jne    11ec <main+0xcc>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0x107>
cmpl   $0x4,-0xc(%rbp)
jne    1207 <main+0xe7>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <main+0x102>
cmpl   $0x5,-0xc(%rbp)
jne    121d <main+0xfd>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <main+0x102>
jmp    1227 <main+0x107>
jmp    122c <main+0x10c>
jmp    1231 <main+0x111>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
imul   $0xcccccccd,%eax,%ecx
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
jb     1222 <main+0x102>
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
mov    %ecx,0x4(%rsp)
imul   $0xcccccccd,%ecx,%ecx
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
jb     122b <main+0x10b>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
mov    %ecx,0x4(%rsp)
imul   $0xcccccccd,%ecx,%ecx
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
jb     1234 <main+0x114>
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,0x4(%rsp)
imul   $0xcccccccd,%ecx,%ecx
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
jb     123d <main+0x11d>
imul   $0x68db8bad,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
mov    %eax,0x4(%rsp)
imul   $0xcccccccd,%eax,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     1249 <main+0x129>
lea    0xe60(%rip),%rdi
jmp    1244 <main+0x124>
lea    0xdeb(%rip),%rdi
jmp    1244 <main+0x124>
lea    0xdf8(%rip),%rdi
jmp    1244 <main+0x124>
lea    0xe09(%rip),%rdi
jmp    1244 <main+0x124>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter the number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"The numbr is in Ten's\00"
@.str.3 = [26 x i8] c"The numbr is in Hundred's\00"
@.str.4 = [28 x i8] c"The number is in Thousand's\00"
@.str.5 = [32 x i8] c"The number is in Ten thousand's\00"
@.str.6 = [24 x i8] c"The numbr is in lakh's \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 5
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i32, i32* %2
%13 = srem i32 %12, 10
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 10
store i32 %15, i32* %5
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
br label %24
19: ; preds = %11
%20 = load i32, i32* %5
store i32 %20, i32* %2
br label %21
21: ; preds = %19
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %8
24: ; preds = %18, %8
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %53
29: ; preds = %24
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %52
34: ; preds = %29
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %51
39: ; preds = %34
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 4
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %50
44: ; preds = %39
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 5
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
br label %50
50: ; preds = %49, %42
br label %51
51: ; preds = %50, %37
br label %52
52: ; preds = %51, %32
br label %53
53: ; preds = %52, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter the number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"The numbr is in Ten's\00"
@.str.3 = [26 x i8] c"The numbr is in Hundred's\00"
@.str.4 = [28 x i8] c"The number is in Thousand's\00"
@.str.5 = [32 x i8] c"The number is in Ten thousand's\00"
@.str.6 = [24 x i8] c"The numbr is in lakh's \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 = srem i32 %5, 10
%7 = sdiv i32 %5, 10
%8 = icmp eq i32 %6, 0
br i1 %8, label %24, label %9
9: ; preds = %0
store i32 %7, i32* %1
%10 = srem i32 %7, 10
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = sdiv i32 %5, 100
store i32 %13, i32* %1
%14 = srem i32 %13, 10
%15 = icmp eq i32 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = sdiv i32 %5, 1000
store i32 %17, i32* %1
%18 = srem i32 %17, 10
%19 = icmp eq i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = sdiv i32 %5, 10000
store i32 %21, i32* %1
%22 = srem i32 %21, 10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20, %16, %12, %9, %0
%25 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), %20 ]
%26 = call i32 @printf(i8* dereferenceable(1) %25)
br label %27
27: ; preds = %24, %20
ret i32 0
}