#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*/ ASRT_char(char, char);
int /*<<< orphan*/ add_digits(char, char, char, char *, char *);
void test_add_digits() {
  for (char a = 0; a < 10; a++) {
    for (char b = 0; b < 10; b++) {
      for (char c = 0; c < 10; c++) {
        char d = 0;
        char e = 0;
        add_digits(a, b, c, &d, &e);
        ASRT_char((a + b + c) / 10, d);
        ASRT_char((a + b + c) % 10, e);
      }
    }
  }
}


x86 assembly (clang, -O0):
<test_add_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jge    11fb <test_add_digits+0xdb>
movb   $0x0,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0xa,%eax
jge    11e9 <test_add_digits+0xc9>
movb   $0x0,-0x3(%rbp)
movsbl -0x3(%rbp),%eax
cmp    $0xa,%eax
jge    11d7 <test_add_digits+0xb7>
movb   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    -0x1(%rbp),%dl
mov    -0x2(%rbp),%al
lea    -0x4(%rbp),%rcx
lea    -0x5(%rbp),%r8
movsbl %dl,%edi
movsbl %al,%esi
movsbl -0x3(%rbp),%edx
call   1030 <add_digits@plt>
movsbl -0x1(%rbp),%eax
movsbl -0x2(%rbp),%ecx
add    %ecx,%eax
movsbl -0x3(%rbp),%ecx
add    %ecx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movsbl %al,%edi
movsbl -0x4(%rbp),%esi
call   1040 <ASRT_char@plt>
movsbl -0x1(%rbp),%eax
movsbl -0x2(%rbp),%ecx
add    %ecx,%eax
movsbl -0x3(%rbp),%ecx
add    %ecx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %dl,%al
movsbl %al,%edi
movsbl -0x5(%rbp),%esi
call   1040 <ASRT_char@plt>
mov    -0x3(%rbp),%al
add    $0x1,%al
mov    %al,-0x3(%rbp)
jmp    114e <test_add_digits+0x2e>
jmp    11dc <test_add_digits+0xbc>
mov    -0x2(%rbp),%al
add    $0x1,%al
mov    %al,-0x2(%rbp)
jmp    113d <test_add_digits+0x1d>
jmp    11ee <test_add_digits+0xce>
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    112c <test_add_digits+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_add_digits>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edx,%edx
mov    $0xcccccccd,%esi
lea    0x6(%rsp),%rcx
lea    0x7(%rsp),%r13
nop
mov    %edx,%eax
mov    %rax,0x8(%rsp)
xor    %r8d,%r8d
mov    %edx,0x14(%rsp)
xchg   %ax,%ax
xor    %r14d,%r14d
mov    0x8(%rsp),%rax
mov    %eax,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r15d,%eax
imul   %rsi,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    0x8(%rsp),%rbp
mov    %ebp,%ebx
sub    %al,%bl
movzbl %bl,%r12d
movb   $0x0,0x6(%rsp)
movb   $0x0,0x7(%rsp)
movsbl %dl,%edi
movsbl %r8b,%esi
movsbl %r14b,%edx
mov    %r8d,%ebx
mov    %r13,%r8
call   1030 <add_digits@plt>
lea    (%r14,%rbp,1),%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
movsbl 0x6(%rsp),%esi
movsbl %al,%edi
call   1040 <ASRT_char@plt>
add    %r14d,%r12d
movsbl 0x7(%rsp),%esi
movsbl %r12b,%edi
call   1040 <ASRT_char@plt>
mov    %ebx,%r8d
lea    0x6(%rsp),%rcx
mov    0x14(%rsp),%edx
mov    $0xcccccccd,%esi
add    $0x1,%r14d
add    $0x1,%r15d
cmp    $0xa,%r14d
jne    1160 <test_add_digits+0x40>
add    $0x1,%r8d
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
cmp    $0xa,%r8d
jne    1150 <test_add_digits+0x30>
add    $0x1,%edx
cmp    $0xa,%edx
jne    1140 <test_add_digits+0x20>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @test_add_digits() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
store i8 0, i8* %1
br label %6
6: ; preds = %57, %0
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %60
10: ; preds = %6
store i8 0, i8* %2
br label %11
11: ; preds = %53, %10
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %56
15: ; preds = %11
store i8 0, i8* %3
br label %16
16: ; preds = %49, %15
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %52
20: ; preds = %16
store i8 0, i8* %4
store i8 0, i8* %5
%21 = load i8, i8* %1
%22 = load i8, i8* %2
%23 = load i8, i8* %3
%24 = call i32 @add_digits(i8 signext %21, i8 signext %22, i8 signext %23, i8* %4, i8* %5)
%25 = load i8, i8* %1
%26 = sext i8 %25 to i32
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = add nsw i32 %26, %28
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = add nsw i32 %29, %31
%33 = sdiv i32 %32, 10
%34 = trunc i32 %33 to i8
%35 = load i8, i8* %4
%36 = call i32 @ASRT_char(i8 signext %34, i8 signext %35)
%37 = load i8, i8* %1
%38 = sext i8 %37 to i32
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = add nsw i32 %38, %40
%42 = load i8, i8* %3
%43 = sext i8 %42 to i32
%44 = add nsw i32 %41, %43
%45 = srem i32 %44, 10
%46 = trunc i32 %45 to i8
%47 = load i8, i8* %5
%48 = call i32 @ASRT_char(i8 signext %46, i8 signext %47)
br label %49
49: ; preds = %20
%50 = load i8, i8* %3
%51 = add i8 %50, 1
store i8 %51, i8* %3
br label %16
52: ; preds = %16
br label %53
53: ; preds = %52
%54 = load i8, i8* %2
%55 = add i8 %54, 1
store i8 %55, i8* %2
br label %11
56: ; preds = %11
br label %57
57: ; preds = %56
%58 = load i8, i8* %1
%59 = add i8 %58, 1
store i8 %59, i8* %1
br label %6
60: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @test_add_digits() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %0, %11
%4 = phi i32 [ 0, %0 ], [ %12, %11 ]
%5 = trunc i32 %4 to i8
br label %7
6: ; preds = %11
ret void
7: ; preds = %3, %14
%8 = phi i32 [ 0, %3 ], [ %15, %14 ]
%9 = add nuw nsw i32 %8, %4
%10 = trunc i32 %8 to i8
br label %17
11: ; preds = %14
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 10
br i1 %13, label %6, label %3
14: ; preds = %17
%15 = add nuw nsw i32 %8, 1
%16 = icmp eq i32 %15, 10
br i1 %16, label %11, label %7
17: ; preds = %7, %17
%18 = phi i32 [ 0, %7 ], [ %30, %17 ]
store i8 0, i8* %1
store i8 0, i8* %2
%19 = trunc i32 %18 to i8
%20 = call i32 @add_digits(i8 signext %5, i8 signext %10, i8 signext %19, i8* %1, i8* %2)
%21 = add nuw nsw i32 %9, %18
%22 = udiv i32 %21, 10
%23 = trunc i32 %22 to i8
%24 = load i8, i8* %1
%25 = call i32 @ASRT_char(i8 signext %23, i8 signext %24)
%26 = urem i32 %21, 10
%27 = trunc i32 %26 to i8
%28 = load i8, i8* %2
%29 = call i32 @ASRT_char(i8 signext %27, i8 signext %28)
%30 = add nuw nsw i32 %18, 1
%31 = icmp eq i32 %30, 10
br i1 %31, label %14, label %17
}