#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*/ A2C128_B(unsigned char **, unsigned char);
int /*<<< orphan*/ A2C128_C(unsigned char **, char, unsigned char);
void SumASCII(unsigned char **ppOutPos, int Sum, int CharacterSet) {
  switch (CharacterSet) {
  case 1:
  case 2:
    if (Sum <= 31)
      A2C128_B(ppOutPos, (unsigned char)(Sum + 96));
    else if (Sum <= 47)
      A2C128_B(ppOutPos, (unsigned char)Sum);
    else
      A2C128_B(ppOutPos, (unsigned char)(Sum + 10));
    break;
  case 4:
    A2C128_C(ppOutPos, (char)(Sum / 10 + '0'), (unsigned char)(Sum % 10 + '0'));
    break;
  }
}


x86 assembly (clang, -O0):
<SumASCII>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     115a <SumASCII+0x3a>
jmp    1149 <SumASCII+0x29>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11b5 <SumASCII+0x95>
jmp    11e4 <SumASCII+0xc4>
cmpl   $0x1f,-0xc(%rbp)
jg     117b <SumASCII+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x60,%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11b0 <SumASCII+0x90>
cmpl   $0x2f,-0xc(%rbp)
jg     1199 <SumASCII+0x79>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11ab <SumASCII+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0xa,%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11b0 <SumASCII+0x90>
jmp    11e4 <SumASCII+0xc4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
add    $0x30,%edx
mov    %dl,%al
movsbl %cl,%esi
movzbl %al,%edx
call   1040 <A2C128_C@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SumASCII>:
lea    -0x1(%rdx),%eax
cmp    $0x2,%eax
jae    1133 <SumASCII+0x13>
cmp    $0x1f,%esi
jg     1166 <SumASCII+0x46>
add    $0x60,%sil
jmp    116b <SumASCII+0x4b>
cmp    $0x4,%edx
jne    1174 <SumASCII+0x54>
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x30,%al
movsbl %dl,%esi
movzbl %al,%edx
jmp    1040 <A2C128_C@plt>
cmp    $0x2f,%esi
ja     1175 <SumASCII+0x55>
movzbl %sil,%esi
jmp    1030 <A2C128_B@plt>
ret
add    $0xa,%sil
movzbl %sil,%esi
jmp    1030 <A2C128_B@plt>

LLVM IR (-O0):
define void @SumASCII(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
switch i32 %7, label %44 [
i32 1, label %8
i32 2, label %8
i32 4, label %33
]
8: ; preds = %3, %3
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 31
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i8**, i8*** %4
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 96
%15 = trunc i32 %14 to i8
%16 = call i32 @A2C128_B(i8** %12, i8 zeroext %15)
br label %32
17: ; preds = %8
%18 = load i32, i32* %5
%19 = icmp sle i32 %18, 47
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8**, i8*** %4
%22 = load i32, i32* %5
%23 = trunc i32 %22 to i8
%24 = call i32 @A2C128_B(i8** %21, i8 zeroext %23)
br label %31
25: ; preds = %17
%26 = load i8**, i8*** %4
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 10
%29 = trunc i32 %28 to i8
%30 = call i32 @A2C128_B(i8** %26, i8 zeroext %29)
br label %31
31: ; preds = %25, %20
br label %32
32: ; preds = %31, %11
br label %44
33: ; preds = %3
%34 = load i8**, i8*** %4
%35 = load i32, i32* %5
%36 = sdiv i32 %35, 10
%37 = add nsw i32 %36, 48
%38 = trunc i32 %37 to i8
%39 = load i32, i32* %5
%40 = srem i32 %39, 10
%41 = add nsw i32 %40, 48
%42 = trunc i32 %41 to i8
%43 = call i32 @A2C128_C(i8** %34, i8 signext %38, i8 zeroext %42)
br label %44
44: ; preds = %3, %33, %32
ret void
}

LLVM IR (-O2):
define void @SumASCII(i8** %0, i32 %1, i32 %2) {
switch i32 %2, label %26 [
i32 1, label %4
i32 2, label %4
i32 4, label %18
]
4: ; preds = %3, %3
%5 = icmp slt i32 %1, 32
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = trunc i32 %1 to i8
%8 = add i8 %7, 96
%9 = tail call i32 @A2C128_B(i8** %0, i8 zeroext %8)
br label %26
10: ; preds = %4
%11 = icmp ult i32 %1, 48
%12 = trunc i32 %1 to i8
br i1 %11, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @A2C128_B(i8** %0, i8 zeroext %12)
br label %26
15: ; preds = %10
%16 = add i8 %12, 10
%17 = tail call i32 @A2C128_B(i8** %0, i8 zeroext %16)
br label %26
18: ; preds = %3
%19 = sdiv i32 %1, 10
%20 = trunc i32 %19 to i8
%21 = add i8 %20, 48
%22 = srem i32 %1, 10
%23 = trunc i32 %22 to i8
%24 = add nsw i8 %23, 48
%25 = tail call i32 @A2C128_C(i8** %0, i8 signext %21, i8 zeroext %24)
br label %26
26: ; preds = %6, %15, %13, %3, %18
ret void
}