#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 iBaseConvert(unsigned char *, unsigned int, int, unsigned char *,
                 unsigned int, int);
int iDecode(unsigned char *, int, unsigned char *, unsigned int, unsigned int,
            unsigned char);
int iEncode(unsigned char *, unsigned char *, int, unsigned int,
            int /*<<< orphan*/ *);
int iStrNumBaseConvert(unsigned char *pszSource, unsigned int uiSourceBase,
                       unsigned char *pszTarget, unsigned int uiTargetSize,
                       unsigned int uiTargetBase, unsigned char ucFillChar) {
  int iRet;
  unsigned char sS[128], sT[128];
  iRet = iEncode(pszSource, sS, 128, uiSourceBase, NULL);
  if (iRet)
    return (iRet);
  iRet = iBaseConvert(sS, uiSourceBase, 128, sT, uiTargetBase, 128);
  if (iRet)
    return (iRet);
  iRet = iDecode(sT, 128, pszTarget, uiTargetSize, uiTargetBase, ucFillChar);
  if (iRet)
    return (iRet);
  return (0);
}


x86 assembly (clang, -O0):
<iStrNumBaseConvert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %r9b,%al
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %al,-0x29(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <iEncode@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1188 <iStrNumBaseConvert+0x58>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1203 <iStrNumBaseConvert+0xd3>
lea    -0xb0(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x130(%rbp),%rcx
mov    -0x28(%rbp),%r8d
mov    $0x80,%r9d
mov    %r9d,%edx
call   1030 <iBaseConvert@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11c3 <iStrNumBaseConvert+0x93>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1203 <iStrNumBaseConvert+0xd3>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    $0x80,%esi
movzbl -0x29(%rbp),%r9d
call   1040 <iDecode@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11fc <iStrNumBaseConvert+0xcc>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1203 <iStrNumBaseConvert+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iStrNumBaseConvert>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %r9d,%r12d
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%ebp
lea    0x80(%rsp),%rsi
mov    $0x80,%edx
mov    %ebp,%ecx
xor    %r8d,%r8d
call   1050 <iEncode@plt>
test   %eax,%eax
jne    11a6 <iStrNumBaseConvert+0x76>
lea    0x80(%rsp),%rdi
mov    %rsp,%rcx
mov    %ebp,%esi
mov    $0x80,%edx
mov    %ebx,%r8d
mov    $0x80,%r9d
call   1030 <iBaseConvert@plt>
test   %eax,%eax
jne    11a6 <iStrNumBaseConvert+0x76>
movzbl %r12b,%r9d
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1040 <iDecode@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iStrNumBaseConvert(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8 zeroext %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i32
%15 = alloca [128 x i8]
%16 = alloca [128 x i8]
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i8 %5, i8* %13
%17 = load i8*, i8** %8
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%19 = load i32, i32* %9
%20 = call i32 @iEncode(i8* %17, i8* %18, i32 128, i32 %19, i32* null)
store i32 %20, i32* %14
%21 = load i32, i32* %14
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %6
%24 = load i32, i32* %14
store i32 %24, i32* %7
br label %47
25: ; preds = %6
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%27 = load i32, i32* %9
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%29 = load i32, i32* %12
%30 = call i32 @iBaseConvert(i8* %26, i32 %27, i32 128, i8* %28, i32 %29, i32 128)
store i32 %30, i32* %14
%31 = load i32, i32* %14
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %25
%34 = load i32, i32* %14
store i32 %34, i32* %7
br label %47
35: ; preds = %25
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%37 = load i8*, i8** %10
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = load i8, i8* %13
%41 = call i32 @iDecode(i8* %36, i32 128, i8* %37, i32 %38, i32 %39, i8 zeroext %40)
store i32 %41, i32* %14
%42 = load i32, i32* %14
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %35
%45 = load i32, i32* %14
store i32 %45, i32* %7
br label %47
46: ; preds = %35
store i32 0, i32* %7
br label %47
47: ; preds = %46, %44, %33, %23
%48 = load i32, i32* %7
ret i32 %48
}

LLVM IR (-O2):
define i32 @iStrNumBaseConvert(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8 zeroext %5) {
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%11 = call i32 @iEncode(i8* %0, i8* %9, i32 128, i32 %1, i32* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %6
%14 = call i32 @iBaseConvert(i8* %9, i32 %1, i32 128, i8* %10, i32 %4, i32 128)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @iDecode(i8* %10, i32 128, i8* %2, i32 %3, i32 %4, i8 zeroext %5)
br label %18
18: ; preds = %16, %13, %6
%19 = phi i32 [ %11, %6 ], [ %14, %13 ], [ %17, %16 ]
ret i32 %19
}