#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 */
typedef int /*<<< orphan*/ sA;

/* Variables and functions */
int iDecode(unsigned char *, int, unsigned char *, unsigned int, unsigned int,
            unsigned char);
int iEncode(unsigned char *, unsigned char *, int, unsigned int,
            unsigned int *);
int iMult(unsigned char *, unsigned char *, unsigned char *, unsigned int,
          unsigned int);
int /*<<< orphan*/ vSetZero(unsigned char *, int);
int iStrNumMult(unsigned char *pszA, unsigned int uiSizeA, unsigned char *pszB,
                unsigned char *pszC, unsigned int uiBase,
                unsigned char ucFillChar) {
  int iRet;
  unsigned int uiBValidLen, uiCValidLen;
  unsigned char sA[128 * 2], sB[128], sC[128];
  iRet = iEncode(pszB, sB, 128, uiBase, &uiBValidLen);
  if (iRet)
    return (iRet);
  iRet = iEncode(pszC, sC, 128, uiBase, &uiCValidLen);
  if (iRet)
    return (iRet);
  vSetZero(sA, sizeof(sA));
  iRet = iMult(sA, sB, sC,
               (uiBValidLen > uiCValidLen ? uiBValidLen : uiCValidLen), uiBase);
  if (iRet)
    return (iRet);
  iRet = iDecode(sA, 128, pszA, uiSizeA, uiBase, ucFillChar);
  if (iRet)
    return (iRet);
  return (0);
}


x86 assembly (clang, -O0):
<iStrNumMult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %r9b,%al
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %al,-0x2d(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%edx
lea    -0x38(%rbp),%r8
call   1060 <iEncode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1198 <iStrNumMult+0x58>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a6 <iStrNumMult+0x166>
mov    -0x28(%rbp),%rdi
lea    -0x240(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%edx
lea    -0x3c(%rbp),%r8
call   1060 <iEncode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11cc <iStrNumMult+0x8c>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a6 <iStrNumMult+0x166>
lea    -0x140(%rbp),%rdi
mov    $0x100,%esi
call   1040 <vSetZero@plt>
lea    -0x140(%rbp),%rax
mov    %rax,-0x258(%rbp)
lea    -0x1c0(%rbp),%rax
mov    %rax,-0x250(%rbp)
lea    -0x240(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jbe    1221 <iStrNumMult+0xe1>
mov    -0x38(%rbp),%eax
mov    %eax,-0x25c(%rbp)
jmp    122a <iStrNumMult+0xea>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x25c(%rbp)
mov    -0x248(%rbp),%rdx
mov    -0x250(%rbp),%rsi
mov    -0x258(%rbp),%rdi
mov    -0x25c(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1030 <iMult@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1266 <iStrNumMult+0x126>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a6 <iStrNumMult+0x166>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    $0x80,%esi
movzbl -0x2d(%rbp),%r9d
call   1050 <iDecode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     129f <iStrNumMult+0x15f>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a6 <iStrNumMult+0x166>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iStrNumMult>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x210,%rsp
mov    %r9d,%r15d
mov    %r8d,%ebx
mov    %rcx,%rbp
mov    %esi,%r14d
mov    %rdi,%r12
lea    0x90(%rsp),%rsi
lea    0xc(%rsp),%r8
mov    %rdx,%rdi
mov    $0x80,%edx
mov    %ebx,%ecx
call   1060 <iEncode@plt>
test   %eax,%eax
jne    11f8 <iStrNumMult+0xb8>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%r8
mov    %rbp,%rdi
mov    $0x80,%edx
mov    %ebx,%ecx
call   1060 <iEncode@plt>
test   %eax,%eax
jne    11f8 <iStrNumMult+0xb8>
lea    0x110(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
call   1040 <vSetZero@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ecx
cmp    %ecx,%eax
cmova  %eax,%ecx
lea    0x90(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbp,%rdi
mov    %ebx,%r8d
call   1030 <iMult@plt>
test   %eax,%eax
jne    11f8 <iStrNumMult+0xb8>
movzbl %r15b,%r9d
lea    0x110(%rsp),%rdi
mov    $0x80,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1050 <iDecode@plt>
add    $0x210,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iStrNumMult(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4, i8 zeroext %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [256 x i8]
%18 = alloca [128 x i8]
%19 = alloca [128 x i8]
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8 %5, i8* %13
%20 = load i8*, i8** %10
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%22 = load i32, i32* %12
%23 = call i32 @iEncode(i8* %20, i8* %21, i32 128, i32 %22, i32* %15)
store i32 %23, i32* %14
%24 = load i32, i32* %14
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %6
%27 = load i32, i32* %14
store i32 %27, i32* %7
br label %70
28: ; preds = %6
%29 = load i8*, i8** %11
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %19, i64 0, i64 0
%31 = load i32, i32* %12
%32 = call i32 @iEncode(i8* %29, i8* %30, i32 128, i32 %31, i32* %16)
store i32 %32, i32* %14
%33 = load i32, i32* %14
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = load i32, i32* %14
store i32 %36, i32* %7
br label %70
37: ; preds = %28
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%39 = call i32 @vSetZero(i8* %38, i32 256)
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %19, i64 0, i64 0
%43 = load i32, i32* %15
%44 = load i32, i32* %16
%45 = icmp ugt i32 %43, %44
br i1 %45, label %46, label %48
46: ; preds = %37
%47 = load i32, i32* %15
br label %50
48: ; preds = %37
%49 = load i32, i32* %16
br label %50
50: ; preds = %48, %46
%51 = phi i32 [ %47, %46 ], [ %49, %48 ]
%52 = load i32, i32* %12
%53 = call i32 @iMult(i8* %40, i8* %41, i8* %42, i32 %51, i32 %52)
store i32 %53, i32* %14
%54 = load i32, i32* %14
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = load i32, i32* %14
store i32 %57, i32* %7
br label %70
58: ; preds = %50
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%60 = load i8*, i8** %8
%61 = load i32, i32* %9
%62 = load i32, i32* %12
%63 = load i8, i8* %13
%64 = call i32 @iDecode(i8* %59, i32 128, i8* %60, i32 %61, i32 %62, i8 zeroext %63)
store i32 %64, i32* %14
%65 = load i32, i32* %14
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %58
%68 = load i32, i32* %14
store i32 %68, i32* %7
br label %70
69: ; preds = %58
store i32 0, i32* %7
br label %70
70: ; preds = %69, %67, %56, %35, %26
%71 = load i32, i32* %7
ret i32 %71
}

LLVM IR (-O2):
define i32 @iStrNumMult(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4, i8 zeroext %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [128 x i8]
%11 = alloca [128 x i8]
%12 = bitcast i32* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%17 = call i32 @iEncode(i8* %2, i8* %15, i32 128, i32 %4, i32* %7)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %6
%20 = call i32 @iEncode(i8* %3, i8* %16, i32 128, i32 %4, i32* %8)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = call i32 @vSetZero(i8* %14, i32 256)
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = icmp ugt i32 %24, %25
%27 = select i1 %26, i32 %24, i32 %25
%28 = call i32 @iMult(i8* %14, i8* %15, i8* %16, i32 %27, i32 %4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @iDecode(i8* %14, i32 128, i8* %0, i32 %1, i32 %4, i8 zeroext %5)
br label %32
32: ; preds = %30, %22, %19, %6
%33 = phi i32 [ %17, %6 ], [ %20, %19 ], [ %28, %22 ], [ %31, %30 ]
ret i32 %33
}