#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 iAdd(unsigned char *, unsigned char *, int, unsigned 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 iStrNumAdd(unsigned char *pszA, unsigned int uiSizeA, unsigned char *pszB,
               unsigned char *pszC, unsigned int uiBase,
               unsigned char ucFillChar) {
  int iRet;
  int iCarry;
  unsigned char sB[128], sC[128];
  iRet = iEncode(pszB, sB, 128, uiBase, NULL);
  if (iRet)
    return (iRet);
  iRet = iEncode(pszC, sC, 128, uiBase, NULL);
  if (iRet)
    return (iRet);
  iCarry = iAdd(sB, sC, 128, uiBase);
  if (iCarry < 0)
    return (iCarry);
  if (iCarry > 0)
    return (-2);
  iRet = iDecode(sB, 128, pszA, uiSizeA, uiBase, ucFillChar);
  if (iRet)
    return (iRet);
  return (0);
}


x86 assembly (clang, -O0):
<iStrNumAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%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    -0xc0(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <iEncode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1189 <iStrNumAdd+0x59>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <iStrNumAdd+0x117>
mov    -0x28(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <iEncode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11be <iStrNumAdd+0x8e>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <iStrNumAdd+0x117>
lea    -0xc0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%edx
call   1030 <iAdd@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    11f1 <iStrNumAdd+0xc1>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <iStrNumAdd+0x117>
cmpl   $0x0,-0x38(%rbp)
jle    1207 <iStrNumAdd+0xd7>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1247 <iStrNumAdd+0x117>
lea    -0xc0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    $0x80,%esi
movzbl -0x2d(%rbp),%r9d
call   1040 <iDecode@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1240 <iStrNumAdd+0x110>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <iStrNumAdd+0x117>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iStrNumAdd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %r9d,%r15d
mov    %r8d,%ebx
mov    %rcx,%rbp
mov    %esi,%r14d
mov    %rdi,%r12
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    $0x80,%edx
mov    %r8d,%ecx
xor    %r8d,%r8d
call   1050 <iEncode@plt>
test   %eax,%eax
jne    1186 <iStrNumAdd+0x56>
lea    0x80(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x80,%edx
mov    %ebx,%ecx
xor    %r8d,%r8d
call   1050 <iEncode@plt>
test   %eax,%eax
je     1196 <iStrNumAdd+0x66>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rdi
lea    0x80(%rsp),%rsi
mov    $0x80,%edx
mov    %ebx,%ecx
call   1030 <iAdd@plt>
test   %eax,%eax
js     1186 <iStrNumAdd+0x56>
mov    $0xfffffffe,%eax
jne    1186 <iStrNumAdd+0x56>
movzbl %r15b,%r9d
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1040 <iDecode@plt>
jmp    1186 <iStrNumAdd+0x56>

LLVM IR (-O0):
define i32 @iStrNumAdd(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 [128 x i8]
%17 = 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
%18 = load i8*, i8** %10
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%20 = load i32, i32* %12
%21 = call i32 @iEncode(i8* %18, i8* %19, i32 128, i32 %20, i32* null)
store i32 %21, i32* %14
%22 = load i32, i32* %14
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %6
%25 = load i32, i32* %14
store i32 %25, i32* %7
br label %60
26: ; preds = %6
%27 = load i8*, i8** %11
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%29 = load i32, i32* %12
%30 = call i32 @iEncode(i8* %27, i8* %28, i32 128, i32 %29, i32* null)
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 = %26
%34 = load i32, i32* %14
store i32 %34, i32* %7
br label %60
35: ; preds = %26
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%38 = load i32, i32* %12
%39 = call i32 @iAdd(i8* %36, i8* %37, i32 128, i32 %38)
store i32 %39, i32* %15
%40 = load i32, i32* %15
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = load i32, i32* %15
store i32 %43, i32* %7
br label %60
44: ; preds = %35
%45 = load i32, i32* %15
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 -2, i32* %7
br label %60
48: ; preds = %44
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%50 = load i8*, i8** %8
%51 = load i32, i32* %9
%52 = load i32, i32* %12
%53 = load i8, i8* %13
%54 = call i32 @iDecode(i8* %49, i32 128, i8* %50, i32 %51, i32 %52, i8 zeroext %53)
store i32 %54, i32* %14
%55 = load i32, i32* %14
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %48
%58 = load i32, i32* %14
store i32 %58, i32* %7
br label %60
59: ; preds = %48
store i32 0, i32* %7
br label %60
60: ; preds = %59, %57, %47, %42, %33, %24
%61 = load i32, i32* %7
ret i32 %61
}

LLVM IR (-O2):
define i32 @iStrNumAdd(i8* %0, i32 %1, i8* %2, i8* %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* %2, i8* %9, i32 128, i32 %4, i32* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %6
%14 = call i32 @iEncode(i8* %3, i8* %10, i32 128, i32 %4, i32* null)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i32 @iAdd(i8* %9, i8* %10, i32 128, i32 %4)
%18 = icmp slt i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = icmp eq i32 %17, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32 @iDecode(i8* %9, i32 128, i8* %0, i32 %1, i32 %4, i8 zeroext %5)
br label %23
23: ; preds = %21, %19, %16, %13, %6
%24 = phi i32 [ %11, %6 ], [ %14, %13 ], [ %17, %16 ], [ -2, %19 ], [ %22, %21 ]
ret i32 %24
}