#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 charToDigit(char);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
void parseDigits(int *digits, char *string) {
  char *end = string + strlen(string) - 1;
  int i;
  for (i = 0; i < strlen(string); i++, end--) {
    int *digit = digits + i;
    printf("%d", *digit);
    *digit += charToDigit(*end);
    printf("%d", charToDigit(*end));
    if (*digit >= 10) {
      *digit -= 10;
      digit++;
      *digit += 1;
    }
  }
}


x86 assembly (clang, -O0):
<parseDigits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    122b <parseDigits+0xfb>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <charToDigit@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <charToDigit@plt>
mov    %eax,%esi
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
cmpl   $0xa,(%rax)
jl     120c <parseDigits+0xdc>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
sub    $0xa,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1211 <parseDigits+0xe1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    116c <parseDigits+0x3c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDigits>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11cb <parseDigits+0x9b>
movslq %ebp,%rax
lea    (%rax,%r14,1),%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
lea    0xe98(%rip),%r15
jmp    1187 <parseDigits+0x57>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    $0xffffffffffffffff,%rbp
cmp    %rax,%rbx
jge    11cb <parseDigits+0x9b>
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
movsbl 0x0(%rbp),%edi
call   1050 <charToDigit@plt>
add    %eax,(%r12,%rbx,4)
movsbl 0x0(%rbp),%edi
call   1050 <charToDigit@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    (%r12,%rbx,4),%eax
cmp    $0xa,%eax
jl     1170 <parseDigits+0x40>
add    $0xfffffff6,%eax
mov    %eax,(%r12,%rbx,4)
addl   $0x1,0x4(%r12,%rbx,4)
jmp    1170 <parseDigits+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @parseDigits(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -1
store i8* %13, i8** %5
store i32 0, i32* %6
br label %14
14: ; preds = %50, %2
%15 = load i32, i32* %6
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %55
19: ; preds = %14
%20 = load i32*, i32** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = call i32 @charToDigit(i8 signext %28)
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = add nsw i32 %31, %29
store i32 %32, i32* %30
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = call i32 @charToDigit(i8 signext %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %7
%38 = load i32, i32* %37
%39 = icmp sge i32 %38, 10
br i1 %39, label %40, label %49
40: ; preds = %19
%41 = load i32*, i32** %7
%42 = load i32, i32* %41
%43 = sub nsw i32 %42, 10
store i32 %43, i32* %41
%44 = load i32*, i32** %7
%45 = getelementptr inbounds i32, i32* %44, i32 1
store i32* %45, i32** %7
%46 = load i32*, i32** %7
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
br label %49
49: ; preds = %40, %19
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i32 -1
store i8* %54, i8** %5
br label %14
55: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @parseDigits(i32* nocapture %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %35
6: ; preds = %2
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i8, i8* %1, i64 %7
br label %9
9: ; preds = %6, %30
%10 = phi i64 [ 0, %6 ], [ %31, %30 ]
%11 = phi i8* [ %8, %6 ], [ %12, %30 ]
%12 = getelementptr inbounds i8, i8* %11, i64 -1
%13 = getelementptr inbounds i32, i32* %0, i64 %10
%14 = load i32, i32* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i8, i8* %12
%17 = tail call i32 @charToDigit(i8 signext %16)
%18 = load i32, i32* %13
%19 = add nsw i32 %18, %17
store i32 %19, i32* %13
%20 = load i8, i8* %12
%21 = tail call i32 @charToDigit(i8 signext %20)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %13
%24 = icmp sgt i32 %23, 9
br i1 %24, label %25, label %30
25: ; preds = %9
%26 = add nsw i32 %23, -10
store i32 %26, i32* %13
%27 = getelementptr inbounds i32, i32* %13, i64 1
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
br label %30
30: ; preds = %25, %9
%31 = add nuw nsw i64 %10, 1
%32 = tail call i32 @strlen(i8* %1)
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %9, label %35
35: ; preds = %30, %2
ret void
}