#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_A(unsigned char **, unsigned char);
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:
    A2C128_A(ppOutPos, (unsigned char)Sum);
    break;
  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)
sub    $0x1,%eax
je     1178 <SumASCII+0x48>
jmp    1156 <SumASCII+0x26>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     118c <SumASCII+0x5c>
jmp    1167 <SumASCII+0x37>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11e7 <SumASCII+0xb7>
jmp    1216 <SumASCII+0xe6>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
movzbl %al,%esi
call   1050 <A2C128_A@plt>
jmp    1216 <SumASCII+0xe6>
cmpl   $0x1f,-0xc(%rbp)
jg     11ad <SumASCII+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x60,%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11e2 <SumASCII+0xb2>
cmpl   $0x2f,-0xc(%rbp)
jg     11cb <SumASCII+0x9b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11dd <SumASCII+0xad>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0xa,%eax
movzbl %al,%esi
call   1030 <A2C128_B@plt>
jmp    11e2 <SumASCII+0xb2>
jmp    1216 <SumASCII+0xe6>
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>:
cmp    $0x4,%edx
je     1148 <SumASCII+0x18>
cmp    $0x2,%edx
je     1176 <SumASCII+0x46>
cmp    $0x1,%edx
jne    1181 <SumASCII+0x51>
movzbl %sil,%esi
jmp    1050 <A2C128_A@plt>
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    $0x1f,%esi
jg     1182 <SumASCII+0x52>
add    $0x60,%sil
jmp    1187 <SumASCII+0x57>
ret
cmp    $0x2f,%esi
ja     1190 <SumASCII+0x60>
movzbl %sil,%esi
jmp    1030 <A2C128_B@plt>
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 %49 [
i32 1, label %8
i32 2, label %13
i32 4, label %38
]
8: ; preds = %3
%9 = load i8**, i8*** %4
%10 = load i32, i32* %5
%11 = trunc i32 %10 to i8
%12 = call i32 @A2C128_A(i8** %9, i8 zeroext %11)
br label %49
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp sle i32 %14, 31
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8**, i8*** %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 96
%20 = trunc i32 %19 to i8
%21 = call i32 @A2C128_B(i8** %17, i8 zeroext %20)
br label %37
22: ; preds = %13
%23 = load i32, i32* %5
%24 = icmp sle i32 %23, 47
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8**, i8*** %4
%27 = load i32, i32* %5
%28 = trunc i32 %27 to i8
%29 = call i32 @A2C128_B(i8** %26, i8 zeroext %28)
br label %36
30: ; preds = %22
%31 = load i8**, i8*** %4
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 10
%34 = trunc i32 %33 to i8
%35 = call i32 @A2C128_B(i8** %31, i8 zeroext %34)
br label %36
36: ; preds = %30, %25
br label %37
37: ; preds = %36, %16
br label %49
38: ; preds = %3
%39 = load i8**, i8*** %4
%40 = load i32, i32* %5
%41 = sdiv i32 %40, 10
%42 = add nsw i32 %41, 48
%43 = trunc i32 %42 to i8
%44 = load i32, i32* %5
%45 = srem i32 %44, 10
%46 = add nsw i32 %45, 48
%47 = trunc i32 %46 to i8
%48 = call i32 @A2C128_C(i8** %39, i8 signext %43, i8 zeroext %47)
br label %49
49: ; preds = %3, %38, %37, %8
ret void
}

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