#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*/ overflow(char *, int);
void combine_char(char total[], char addy, int idx) {
  int add_in = addy - '0';
  int add_to = total[idx] - '0';
  if (add_to + add_in > 9)
    overflow(total, idx + 1);
  total[idx] = ((add_to + add_in) % 10) + '0';
}


x86 assembly (clang, -O0):
<combine_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    $0x9,%eax
jle    115f <combine_char+0x4f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1030 <overflow@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine_char>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movslq %edx,%r14
movsbl (%rdi,%r14,1),%ebp
add    %esi,%ebp
cmp    $0x6a,%ebp
jl     1133 <combine_char+0x23>
add    $0x1,%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <overflow@plt>
add    $0xffffffa0,%ebp
imul   $0x6667,%ebp,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x12,%eax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
add    $0x30,%bpl
mov    %bpl,(%rbx,%r14,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @combine_char(i8* %0, i8 signext %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
store i32 %2, i32* %6
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = sub nsw i32 %10, 48
store i32 %11, i32* %7
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 48
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = load i32, i32* %7
%21 = add nsw i32 %19, %20
%22 = icmp sgt i32 %21, 9
br i1 %22, label %23, label %28
23: ; preds = %3
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = call i32 @overflow(i8* %24, i32 %26)
br label %28
28: ; preds = %23, %3
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = add nsw i32 %29, %30
%32 = srem i32 %31, 10
%33 = add nsw i32 %32, 48
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %4
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
ret void
}

LLVM IR (-O2):
define void @combine_char(i8* %0, i8 signext %1, i32 %2) {
%4 = sext i8 %1 to i32
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = add nsw i32 %8, %4
%10 = icmp sgt i32 %9, 105
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = add nsw i32 %2, 1
%13 = tail call i32 @overflow(i8* %0, i32 %12)
br label %14
14: ; preds = %11, %3
%15 = trunc i32 %9 to i16
%16 = add nsw i16 %15, -96
%17 = srem i16 %16, 10
%18 = trunc i16 %17 to i8
%19 = add nsw i8 %18, 48
store i8 %19, i8* %6
ret void
}