#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 getchar();
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  static int a, b, c, d, e, f, arr[25], i = 0, ch, base, cur_base;
  static int decimal = 0, j, decimal_temp, arr_base[25], check = 1,
             possible = 0;
  printf("##THIS PROGRAM WORKS FINE FOR \nPOSITIVE INTEGERS ONLY##\n\n");
  printf("Enter The No.:\n");
  while ((ch = getchar()) != '\n') {
    arr[i] = ch;
    if (arr[i] >= 'a' && arr[i] <= 'f' && possible < arr[i])
      possible = arr[i];
    i++;
  }
  if (possible >= 'a' && possible <= 'f') {
    printf("Enter The current base:(> %d) \n", (possible - 87));
  } else {
    printf("Enter The current base:(eg. 10 )\n");
  }
  scanf("%d", &cur_base);
  printf("Convert to Base?\n");
  scanf("%d", &base);
  for (j = 0; j < i; j++) {
    if (arr[j] >= '0' && arr[j] <= '9' && (arr[j] - 48) < cur_base)
      decimal += (arr[j] - 48) * pow(cur_base, i - j - 1);
    else if (arr[j] >= 'a' && arr[j] <= (86 + cur_base))
      decimal += (arr[j] - 87) * pow(cur_base, i - j - 1);
    else {
      printf("Invalid Operation! program exiting..");
      check = 0;
    }
  }
  decimal_temp = (int)decimal;
  if (check == 0)
    check = 1;
  else if (base == 10)
    printf("The No in base %d is : %d", base, decimal);
  else {
    printf("The No in the base %d is : ", base);
    for (i = 0; decimal_temp != 0; i++) {
      arr_base[i] = decimal_temp % base;
      decimal_temp /= base;
      if (arr_base[i] >= 10 && arr_base[i] <= 15) {
        switch (arr_base[i]) {
        case 10:
          arr_base[i] = 97;
          break;
        case 11:
          arr_base[i] = 98;
          break;
        case 12:
          arr_base[i] = 99;
          break;
        case 13:
          arr_base[i] = 100;
          break;
        case 14:
          arr_base[i] = 101;
          break;
        case 15:
          arr_base[i] = 102;
          break;
        }
      }
    }
    for (j = i; j >= 0; j--) {
      if (arr_base[j] < 'a')
        printf("%d", arr_base[j]);
      else
        printf("%c", arr_base[j]);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,0x2f70(%rip)
cmp    $0xa,%eax
je     1210 <main+0xd0>
mov    0x2f61(%rip),%edx
movslq 0x2f56(%rip),%rcx
lea    0x2eeb(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq 0x2f45(%rip),%rcx
lea    0x2eda(%rip),%rax
cmpl   $0x61,(%rax,%rcx,4)
jl     11fc <main+0xbc>
movslq 0x2f2d(%rip),%rcx
lea    0x2ec2(%rip),%rax
cmpl   $0x66,(%rax,%rcx,4)
jg     11fc <main+0xbc>
mov    0x2f96(%rip),%eax
movslq 0x2f0f(%rip),%rdx
lea    0x2ea4(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jge    11fc <main+0xbc>
movslq 0x2ef8(%rip),%rcx
lea    0x2e8d(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,0x2f68(%rip)
mov    0x2ee2(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed9(%rip)
jmp    116b <main+0x2b>
cmpl   $0x61,0x2f4d(%rip)
jl     1246 <main+0x106>
cmpl   $0x66,0x2f40(%rip)
jg     1246 <main+0x106>
mov    0x2f34(%rip),%esi
sub    $0x57,%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <main+0x114>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0x2e8e(%rip),%rsi
call   1050 <scanf@plt>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    0x2e69(%rip),%rsi
call   1050 <scanf@plt>
movl   $0x0,0x2e66(%rip)
mov    0x2e60(%rip),%eax
cmp    0x2e46(%rip),%eax
jge    13f8 <main+0x2b8>
movslq 0x2e4d(%rip),%rcx
lea    0x2dce(%rip),%rax
cmpl   $0x30,(%rax,%rcx,4)
jl     133e <main+0x1fe>
movslq 0x2e35(%rip),%rcx
lea    0x2db6(%rip),%rax
cmpl   $0x39,(%rax,%rcx,4)
jg     133e <main+0x1fe>
movslq 0x2e1d(%rip),%rcx
lea    0x2d9e(%rip),%rax
mov    (%rax,%rcx,4),%eax
sub    $0x30,%eax
cmp    0x2e02(%rip),%eax
jge    133e <main+0x1fe>
movslq 0x2dfd(%rip),%rcx
lea    0x2d7e(%rip),%rax
mov    (%rax,%rcx,4),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    0x2ddf(%rip),%edi
mov    0x2dcd(%rip),%esi
sub    0x2ddb(%rip),%esi
sub    $0x1,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
imul   %ecx,%eax
add    0x2dc1(%rip),%eax
mov    %eax,0x2dbb(%rip)
jmp    13df <main+0x29f>
movslq 0x2db3(%rip),%rcx
lea    0x2d34(%rip),%rax
cmpl   $0x61,(%rax,%rcx,4)
jl     13c2 <main+0x282>
movslq 0x2d9b(%rip),%rcx
lea    0x2d1c(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    0x2d83(%rip),%ecx
add    $0x56,%ecx
cmp    %ecx,%eax
jg     13c2 <main+0x282>
movslq 0x2d79(%rip),%rcx
lea    0x2cfa(%rip),%rax
mov    (%rax,%rcx,4),%eax
sub    $0x57,%eax
mov    %eax,-0xc(%rbp)
mov    0x2d5b(%rip),%edi
mov    0x2d49(%rip),%esi
sub    0x2d57(%rip),%esi
sub    $0x1,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
imul   %ecx,%eax
add    0x2d3d(%rip),%eax
mov    %eax,0x2d37(%rip)
jmp    13da <main+0x29a>
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,0x2c66(%rip)
jmp    13df <main+0x29f>
jmp    13e4 <main+0x2a4>
mov    0x2d0e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d05(%rip)
jmp    1292 <main+0x152>
mov    0x2cf6(%rip),%eax
mov    %eax,0x2cf8(%rip)
cmpl   $0x0,0x2c35(%rip)
jne    1420 <main+0x2e0>
movl   $0x1,0x2c25(%rip)
jmp    165d <main+0x51d>
cmpl   $0xa,0x2cc5(%rip)
jne    144c <main+0x30c>
mov    0x2cb9(%rip),%esi
mov    0x2cbb(%rip),%edx
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1658 <main+0x518>
mov    0x2c9a(%rip),%esi
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,0x2c7a(%rip)
cmpl   $0x0,0x2c8b(%rip)
je     15c6 <main+0x486>
mov    0x2c7f(%rip),%eax
cltd
idivl  0x2c68(%rip)
movslq 0x2c59(%rip),%rcx
lea    0x2c6e(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    0x2c51(%rip),%ecx
mov    0x2c5b(%rip),%eax
cltd
idiv   %ecx
mov    %eax,0x2c52(%rip)
movslq 0x2c33(%rip),%rcx
lea    0x2c48(%rip),%rax
cmpl   $0xa,(%rax,%rcx,4)
jl     15ad <main+0x46d>
movslq 0x2c1b(%rip),%rcx
lea    0x2c30(%rip),%rax
cmpl   $0xf,(%rax,%rcx,4)
jg     15ad <main+0x46d>
movslq 0x2c03(%rip),%rcx
lea    0x2c18(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     15a8 <main+0x468>
mov    -0x18(%rbp),%rax
lea    0xaf8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq 0x2bcc(%rip),%rcx
lea    0x2be1(%rip),%rax
movl   $0x61,(%rax,%rcx,4)
jmp    15a8 <main+0x468>
movslq 0x2bb2(%rip),%rcx
lea    0x2bc7(%rip),%rax
movl   $0x62,(%rax,%rcx,4)
jmp    15a8 <main+0x468>
movslq 0x2b98(%rip),%rcx
lea    0x2bad(%rip),%rax
movl   $0x63,(%rax,%rcx,4)
jmp    15a8 <main+0x468>
movslq 0x2b7e(%rip),%rcx
lea    0x2b93(%rip),%rax
movl   $0x64,(%rax,%rcx,4)
jmp    15a8 <main+0x468>
movslq 0x2b64(%rip),%rcx
lea    0x2b79(%rip),%rax
movl   $0x65,(%rax,%rcx,4)
jmp    15a8 <main+0x468>
movslq 0x2b4a(%rip),%rcx
lea    0x2b5f(%rip),%rax
movl   $0x66,(%rax,%rcx,4)
jmp    15ad <main+0x46d>
jmp    15b2 <main+0x472>
mov    0x2b2c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2b23(%rip)
jmp    146a <main+0x32a>
mov    0x2b18(%rip),%eax
mov    %eax,0x2b26(%rip)
cmpl   $0x0,0x2b1f(%rip)
jl     1653 <main+0x513>
movslq 0x2b12(%rip),%rcx
lea    0x2b13(%rip),%rax
cmpl   $0x61,(%rax,%rcx,4)
jge    161b <main+0x4db>
movslq 0x2afa(%rip),%rcx
lea    0x2afb(%rip),%rax
mov    (%rax,%rcx,4),%esi
lea    0xae3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    163a <main+0x4fa>
movslq 0x2ad6(%rip),%rcx
lea    0x2ad7(%rip),%rax
mov    (%rax,%rcx,4),%esi
lea    0xade(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    163f <main+0x4ff>
mov    0x2ab3(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2aaa(%rip)
jmp    15d2 <main+0x492>
jmp    1658 <main+0x518>
jmp    165d <main+0x51d>
lea    0x9ec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xf0d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf3a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
jne    11a9 <main+0x49>
mov    0x2fb7(%rip),%esi
cmp    $0x61,%esi
jl     11f7 <main+0x97>
add    $0xffffffa9,%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1203 <main+0xa3>
lea    0x2eb0(%rip),%rbx
jmp    11d5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ecx
mov    %ecx,0x2efb(%rip)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     118b <main+0x2b>
movslq 0x2ee8(%rip),%rcx
mov    %eax,(%rbx,%rcx,4)
lea    -0x61(%rax),%edx
cmp    $0x5,%edx
ja     11c0 <main+0x60>
cmp    %eax,0x2f5b(%rip)
jge    11c0 <main+0x60>
mov    %eax,0x2f53(%rip)
jmp    11c0 <main+0x60>
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%rbx
lea    0x2ebb(%rip),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0x2e9c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
movl   $0x0,0x2e96(%rip)
mov    0x2e80(%rip),%esi
test   %esi,%esi
jle    12e9 <main+0x189>
lea    0x2e0d(%rip),%r15
lea    0xdc6(%rip),%r14
xor    %eax,%eax
jmp    128a <main+0x12a>
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x1,0x2ed3(%rip)
mov    0x2e5d(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e54(%rip)
mov    0x2e3e(%rip),%esi
cmp    %eax,%esi
jle    12e9 <main+0x189>
movslq %eax,%rcx
mov    (%r15,%rcx,4),%ebp
lea    -0x30(%rbp),%ebx
cmp    $0x9,%ebx
ja     12c0 <main+0x160>
mov    0x2e2d(%rip),%edi
cmp    %edi,%ebx
jge    1260 <main+0x100>
not    %eax
add    %eax,%esi
call   1080 <pow@plt>
imul   %ebx,%eax
add    %eax,0x2e1b(%rip)
jmp    1271 <main+0x111>
nopw   0x0(%rax,%rax,1)
cmp    $0x61,%ebp
jl     1260 <main+0x100>
mov    0x2e01(%rip),%edi
lea    0x56(%rdi),%ecx
cmp    %ecx,%ebp
jg     1260 <main+0x100>
add    $0xffffffa9,%ebp
not    %eax
add    %eax,%esi
call   1080 <pow@plt>
imul   %ebp,%eax
add    %eax,0x2de9(%rip)
jmp    1271 <main+0x111>
mov    0x2de1(%rip),%edx
mov    %edx,0x2de3(%rip)
cmpb   $0x1,0x2e48(%rip)
jne    1307 <main+0x1a7>
movb   $0x0,0x2e3f(%rip)
jmp    1325 <main+0x1c5>
mov    0x2dbb(%rip),%esi
cmp    $0xa,%esi
jne    133c <main+0x1dc>
lea    0xd2c(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1c(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d86(%rip),%eax
test   %eax,%eax
je     13b0 <main+0x250>
lea    0x2d83(%rip),%rcx
mov    0x2d65(%rip),%esi
jmp    137b <main+0x21b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x4,%rcx
add    $0x1,%ebp
test   %eax,%eax
je     1391 <main+0x231>
cltd
idiv   %esi
mov    %edx,(%rcx)
lea    -0xa(%rdx),%edi
cmp    $0x5,%edi
ja     1370 <main+0x210>
ja     1370 <main+0x210>
add    $0x57,%edx
mov    %edx,(%rcx)
jmp    1370 <main+0x210>
movl   $0x0,0x2d3d(%rip)
mov    %ebp,0x2d23(%rip)
mov    %ebp,0x2d2d(%rip)
test   %ebp,%ebp
jns    13c6 <main+0x266>
jmp    1325 <main+0x1c5>
movl   $0x0,0x2d0a(%rip)
movl   $0x0,0x2d10(%rip)
xor    %ebp,%ebp
lea    0x2d13(%rip),%rbx
lea    0xc88(%rip),%r14
jmp    13fe <main+0x29e>
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%edi
call   1030 <putchar@plt>
mov    0x2ce7(%rip),%eax
lea    -0x1(%rax),%ebp
mov    %ebp,0x2cde(%rip)
test   %eax,%eax
jle    1325 <main+0x1c5>
mov    %ebp,%eax
mov    (%rbx,%rax,4),%esi
cmp    $0x60,%esi
jg     13e0 <main+0x280>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13e7 <main+0x287>

LLVM IR (-O0):
@main.a = internal global i32 0
@main.b = internal global i32 0
@main.c = internal global i32 0
@main.d = internal global i32 0
@main.e = internal global i32 0
@main.f = internal global i32 0
@main.arr = internal global [25 x i32] zeroinitializer
@main.i = internal global i32 0
@main.ch = internal global i32 0
@main.base = internal global i32 0
@main.cur_base = internal global i32 0
@main.decimal = internal global i32 0
@main.j = internal global i32 0
@main.decimal_temp = internal global i32 0
@main.arr_base = internal global [25 x i32] zeroinitializer
@main.check = internal global i32 1
@main.possible = internal global i32 0
@.str = [58 x i8] c"##THIS PROGRAM WORKS FINE FOR \0APOSITIVE INTEGERS ONLY##\0A\0A\00"
@.str.1 = [16 x i8] c"Enter The No.:\0A\00"
@.str.2 = [32 x i8] c"Enter The current base:(> %d) \0A\00"
@.str.3 = [34 x i8] c"Enter The current base:(eg. 10 )\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"Convert to Base?\0A\00"
@.str.6 = [37 x i8] c"Invalid Operation! program exiting..\00"
@.str.7 = [26 x i8] c"The No in base %d is : %d\00"
@.str.8 = [28 x i8] c"The No in the base %d is : \00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %35, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* @main.ch
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %38
7: ; preds = %4
%8 = load i32, i32* @main.ch
%9 = load i32, i32* @main.i
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %10
store i32 %8, i32* %11
%12 = load i32, i32* @main.i
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = icmp sge i32 %15, 97
br i1 %16, label %17, label %35
17: ; preds = %7
%18 = load i32, i32* @main.i
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp sle i32 %21, 102
br i1 %22, label %23, label %35
23: ; preds = %17
%24 = load i32, i32* @main.possible
%25 = load i32, i32* @main.i
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %24, %28
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i32, i32* @main.i
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %32
%34 = load i32, i32* %33
store i32 %34, i32* @main.possible
br label %35
35: ; preds = %30, %23, %17, %7
%36 = load i32, i32* @main.i
%37 = add nsw i32 %36, 1
store i32 %37, i32* @main.i
br label %4
38: ; preds = %4
%39 = load i32, i32* @main.possible
%40 = icmp sge i32 %39, 97
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* @main.possible
%43 = icmp sle i32 %42, 102
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* @main.possible
%46 = sub nsw i32 %45, 87
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %50
48: ; preds = %41, %38
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* @main.cur_base)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* @main.base)
store i32 0, i32* @main.j
br label %54
54: ; preds = %126, %50
%55 = load i32, i32* @main.j
%56 = load i32, i32* @main.i
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %129
58: ; preds = %54
%59 = load i32, i32* @main.j
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = icmp sge i32 %62, 48
br i1 %63, label %64, label %93
64: ; preds = %58
%65 = load i32, i32* @main.j
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = icmp sle i32 %68, 57
br i1 %69, label %70, label %93
70: ; preds = %64
%71 = load i32, i32* @main.j
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = sub nsw i32 %74, 48
%76 = load i32, i32* @main.cur_base
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %93
78: ; preds = %70
%79 = load i32, i32* @main.j
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %80
%82 = load i32, i32* %81
%83 = sub nsw i32 %82, 48
%84 = load i32, i32* @main.cur_base
%85 = load i32, i32* @main.i
%86 = load i32, i32* @main.j
%87 = sub nsw i32 %85, %86
%88 = sub nsw i32 %87, 1
%89 = call i32 @pow(i32 %84, i32 %88)
%90 = mul nsw i32 %83, %89
%91 = load i32, i32* @main.decimal
%92 = add nsw i32 %91, %90
store i32 %92, i32* @main.decimal
br label %125
93: ; preds = %70, %64, %58
%94 = load i32, i32* @main.j
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = icmp sge i32 %97, 97
br i1 %98, label %99, label %122
99: ; preds = %93
%100 = load i32, i32* @main.j
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = load i32, i32* @main.cur_base
%105 = add nsw i32 86, %104
%106 = icmp sle i32 %103, %105
br i1 %106, label %107, label %122
107: ; preds = %99
%108 = load i32, i32* @main.j
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = sub nsw i32 %111, 87
%113 = load i32, i32* @main.cur_base
%114 = load i32, i32* @main.i
%115 = load i32, i32* @main.j
%116 = sub nsw i32 %114, %115
%117 = sub nsw i32 %116, 1
%118 = call i32 @pow(i32 %113, i32 %117)
%119 = mul nsw i32 %112, %118
%120 = load i32, i32* @main.decimal
%121 = add nsw i32 %120, %119
store i32 %121, i32* @main.decimal
br label %124
122: ; preds = %99, %93
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* @main.check
br label %124
124: ; preds = %122, %107
br label %125
125: ; preds = %124, %78
br label %126
126: ; preds = %125
%127 = load i32, i32* @main.j
%128 = add nsw i32 %127, 1
store i32 %128, i32* @main.j
br label %54
129: ; preds = %54
%130 = load i32, i32* @main.decimal
store i32 %130, i32* @main.decimal_temp
%131 = load i32, i32* @main.check
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %134
133: ; preds = %129
store i32 1, i32* @main.check
br label %231
134: ; preds = %129
%135 = load i32, i32* @main.base
%136 = icmp eq i32 %135, 10
br i1 %136, label %137, label %141
137: ; preds = %134
%138 = load i32, i32* @main.base
%139 = load i32, i32* @main.decimal
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %138, i32 %139)
br label %230
141: ; preds = %134
%142 = load i32, i32* @main.base
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %142)
store i32 0, i32* @main.i
br label %144
144: ; preds = %199, %141
%145 = load i32, i32* @main.decimal_temp
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %202
147: ; preds = %144
%148 = load i32, i32* @main.decimal_temp
%149 = load i32, i32* @main.base
%150 = srem i32 %148, %149
%151 = load i32, i32* @main.i
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %152
store i32 %150, i32* %153
%154 = load i32, i32* @main.base
%155 = load i32, i32* @main.decimal_temp
%156 = sdiv i32 %155, %154
store i32 %156, i32* @main.decimal_temp
%157 = load i32, i32* @main.i
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %158
%160 = load i32, i32* %159
%161 = icmp sge i32 %160, 10
br i1 %161, label %162, label %198
162: ; preds = %147
%163 = load i32, i32* @main.i
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %164
%166 = load i32, i32* %165
%167 = icmp sle i32 %166, 15
br i1 %167, label %168, label %198
168: ; preds = %162
%169 = load i32, i32* @main.i
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %170
%172 = load i32, i32* %171
switch i32 %172, label %197 [
i32 10, label %173
i32 11, label %177
i32 12, label %181
i32 13, label %185
i32 14, label %189
i32 15, label %193
]
173: ; preds = %168
%174 = load i32, i32* @main.i
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %175
store i32 97, i32* %176
br label %197
177: ; preds = %168
%178 = load i32, i32* @main.i
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %179
store i32 98, i32* %180
br label %197
181: ; preds = %168
%182 = load i32, i32* @main.i
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %183
store i32 99, i32* %184
br label %197
185: ; preds = %168
%186 = load i32, i32* @main.i
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %187
store i32 100, i32* %188
br label %197
189: ; preds = %168
%190 = load i32, i32* @main.i
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %191
store i32 101, i32* %192
br label %197
193: ; preds = %168
%194 = load i32, i32* @main.i
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %195
store i32 102, i32* %196
br label %197
197: ; preds = %168, %193, %189, %185, %181, %177, %173
br label %198
198: ; preds = %197, %162, %147
br label %199
199: ; preds = %198
%200 = load i32, i32* @main.i
%201 = add nsw i32 %200, 1
store i32 %201, i32* @main.i
br label %144
202: ; preds = %144
%203 = load i32, i32* @main.i
store i32 %203, i32* @main.j
br label %204
204: ; preds = %226, %202
%205 = load i32, i32* @main.j
%206 = icmp sge i32 %205, 0
br i1 %206, label %207, label %229
207: ; preds = %204
%208 = load i32, i32* @main.j
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %209
%211 = load i32, i32* %210
%212 = icmp slt i32 %211, 97
br i1 %212, label %213, label %219
213: ; preds = %207
%214 = load i32, i32* @main.j
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %215
%217 = load i32, i32* %216
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %217)
br label %225
219: ; preds = %207
%220 = load i32, i32* @main.j
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %221
%223 = load i32, i32* %222
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %223)
br label %225
225: ; preds = %219, %213
br label %226
226: ; preds = %225
%227 = load i32, i32* @main.j
%228 = add nsw i32 %227, -1
store i32 %228, i32* @main.j
br label %204
229: ; preds = %204
br label %230
230: ; preds = %229, %137
br label %231
231: ; preds = %230, %133
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%233 = load i32, i32* %1
ret i32 %233
}

LLVM IR (-O2):
@main.arr = internal unnamed_addr global [25 x i32] zeroinitializer
@main.i = internal unnamed_addr global i32 0
@main.base = internal global i32 0
@main.cur_base = internal global i32 0
@main.decimal = internal unnamed_addr global i32 0
@main.j = internal unnamed_addr global i32 0
@main.decimal_temp = internal unnamed_addr global i32 0
@main.arr_base = internal unnamed_addr global [25 x i32] zeroinitializer
@main.check = internal unnamed_addr global i1 false
@main.possible = internal unnamed_addr global i32 0
@.str.2 = [32 x i8] c"Enter The current base:(> %d) \0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [37 x i8] c"Invalid Operation! program exiting..\00"
@.str.7 = [26 x i8] c"The No in base %d is : %d\00"
@.str.8 = [28 x i8] c"The No in the base %d is : \00"
@str = [57 x i8] c"##THIS PROGRAM WORKS FINE FOR \0APOSITIVE INTEGERS ONLY##\0A\00"
@str.11 = [15 x i8] c"Enter The No.:\00"
@str.12 = [33 x i8] c"Enter The current base:(eg. 10 )\00"
@str.13 = [17 x i8] c"Convert to Base?\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, 10
br i1 %4, label %20, label %5
5: ; preds = %0, %16
%6 = phi i32 [ %18, %16 ], [ %3, %0 ]
%7 = load i32, i32* @main.i
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %8
store i32 %6, i32* %9
%10 = add i32 %6, -97
%11 = icmp ult i32 %10, 6
%12 = load i32, i32* @main.possible
%13 = icmp slt i32 %12, %6
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %16
15: ; preds = %5
store i32 %6, i32* @main.possible
br label %16
16: ; preds = %15, %5
%17 = add nsw i32 %7, 1
store i32 %17, i32* @main.i
%18 = tail call i32 (...) @getchar()
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %5
20: ; preds = %16, %0
%21 = load i32, i32* @main.possible
%22 = icmp sgt i32 %21, 96
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = add nsw i32 %21, -87
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %28
26: ; preds = %20
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* @main.cur_base)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%31 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* @main.base)
store i32 0, i32* @main.j
%32 = load i32, i32* @main.i
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %73
34: ; preds = %28, %68
%35 = phi i32 [ %71, %68 ], [ %32, %28 ]
%36 = phi i32 [ %70, %68 ], [ 0, %28 ]
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add i32 %39, -48
%41 = icmp ult i32 %40, 10
br i1 %41, label %42, label %52
42: ; preds = %34
%43 = load i32, i32* @main.cur_base
%44 = icmp slt i32 %40, %43
br i1 %44, label %45, label %66
45: ; preds = %42
%46 = xor i32 %36, -1
%47 = add i32 %35, %46
%48 = tail call i32 @pow(i32 %43, i32 %47)
%49 = mul nsw i32 %48, %40
%50 = load i32, i32* @main.decimal
%51 = add nsw i32 %50, %49
store i32 %51, i32* @main.decimal
br label %68
52: ; preds = %34
%53 = icmp sgt i32 %39, 96
br i1 %53, label %54, label %66
54: ; preds = %52
%55 = load i32, i32* @main.cur_base
%56 = add nsw i32 %55, 86
%57 = icmp sgt i32 %39, %56
br i1 %57, label %66, label %58
58: ; preds = %54
%59 = add nsw i32 %39, -87
%60 = xor i32 %36, -1
%61 = add i32 %35, %60
%62 = tail call i32 @pow(i32 %55, i32 %61)
%63 = mul nsw i32 %62, %59
%64 = load i32, i32* @main.decimal
%65 = add nsw i32 %64, %63
store i32 %65, i32* @main.decimal
br label %68
66: ; preds = %42, %54, %52
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
store i1 true, i1* @main.check
br label %68
68: ; preds = %45, %66, %58
%69 = load i32, i32* @main.j
%70 = add nsw i32 %69, 1
store i32 %70, i32* @main.j
%71 = load i32, i32* @main.i
%72 = icmp sgt i32 %71, %70
br i1 %72, label %34, label %73
73: ; preds = %68, %28
%74 = load i32, i32* @main.decimal
store i32 %74, i32* @main.decimal_temp
%75 = load i1, i1* @main.check
br i1 %75, label %76, label %77
76: ; preds = %73
store i1 false, i1* @main.check
br label %124
77: ; preds = %73
%78 = load i32, i32* @main.base
%79 = icmp eq i32 %78, 10
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 10, i32 %74)
br label %124
82: ; preds = %77
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %78)
%84 = load i32, i32* @main.decimal_temp
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %82
store i32 0, i32* @main.i
store i32 0, i32* @main.j
br label %92
87: ; preds = %82
%88 = load i32, i32* @main.base
br label %94
89: ; preds = %107
%90 = trunc i64 %108 to i32
store i32 0, i32* @main.decimal_temp
store i32 %90, i32* @main.i
store i32 %90, i32* @main.j
%91 = icmp sgt i32 %90, -1
br i1 %91, label %92, label %124
92: ; preds = %86, %89
%93 = phi i32 [ %90, %89 ], [ 0, %86 ]
br label %110
94: ; preds = %87, %107
%95 = phi i64 [ 0, %87 ], [ %108, %107 ]
%96 = phi i32 [ %84, %87 ], [ %99, %107 ]
%97 = srem i32 %96, %88
%98 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %95
store i32 %97, i32* %98
%99 = sdiv i32 %96, %88
%100 = add i32 %97, -10
%101 = icmp ult i32 %100, 6
%102 = add i32 %97, -10
%103 = icmp ult i32 %102, 6
%104 = and i1 %101, %103
br i1 %104, label %105, label %107
105: ; preds = %94
%106 = add i32 %97, 87
store i32 %106, i32* %98
br label %107
107: ; preds = %105, %94
%108 = add nuw i64 %95, 1
%109 = icmp eq i32 %99, 0
br i1 %109, label %89, label %94
110: ; preds = %92, %120
%111 = phi i32 [ %122, %120 ], [ %93, %92 ]
%112 = zext i32 %111 to i64
%113 = getelementptr inbounds [25 x i32], [25 x i32]* @main.arr_base, i64 0, i64 %112
%114 = load i32, i32* %113
%115 = icmp slt i32 %114, 97
br i1 %115, label %116, label %118
116: ; preds = %110
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %114)
br label %120
118: ; preds = %110
%119 = tail call i32 @putchar(i32 %114)
br label %120
120: ; preds = %116, %118
%121 = load i32, i32* @main.j
%122 = add nsw i32 %121, -1
store i32 %122, i32* @main.j
%123 = icmp sgt i32 %121, 0
br i1 %123, label %110, label %124
124: ; preds = %120, %89, %80, %76
%125 = tail call i32 @putchar(i32 10)
ret i32 0
}