#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint64_t;
typedef int uint32_t;

/* Variables and functions */
void foo(const uint8_t *str, uint32_t *res) {
  uint32_t rdVal0, rdVal1, rdVal2;
  rdVal0 = rdVal1 = rdVal2 = 0;
  unsigned c;
  for (;;) {
    c = *str++;
    unsigned dig = c - '0';
    if (dig > 9)
      break;
    uint64_t x10;
    x10 = (uint64_t)rdVal0 * 10 + dig;
    rdVal0 = (uint32_t)x10;
    dig = (uint32_t)(x10 >> 32);
    x10 = (uint64_t)rdVal1 * 10 + dig;
    rdVal1 = (uint32_t)x10;
    dig = (uint32_t)(x10 >> 32);
    rdVal2 = rdVal2 * 10 + dig;
  }
  res[0] = rdVal0;
  res[1] = rdVal1;
  res[2] = rdVal2;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x9,-0x24(%rbp)
jbe    114d <foo+0x4d>
jmp    1196 <foo+0x96>
imul   $0xa,-0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x24(%rbp)
imul   $0xa,-0x18(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x24(%rbp)
imul   $0xa,-0x1c(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1121 <foo+0x21>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%eax
mov    (%rdi),%ecx
add    $0x4,%rdi
lea    -0x30(%rcx),%r8d
lea    (%rax,%rax,4),%edx
lea    (%rcx,%rdx,2),%ecx
add    $0xffffffd0,%ecx
cmp    $0xa,%r8d
jb     1110 <foo+0x10>
mov    %eax,(%rsi)
movq   $0x0,0x4(%rsi)
ret

LLVM IR (-O0):
define void @foo(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %11
11: ; preds = %20, %2
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %3
%14 = load i32, i32* %12
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = sub i32 %15, 48
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ugt i32 %17, 9
br i1 %18, label %19, label %20
19: ; preds = %11
br label %39
20: ; preds = %11
%21 = load i32, i32* %5
%22 = mul nsw i32 %21, 10
%23 = load i32, i32* %9
%24 = add i32 %22, %23
store i32 %24, i32* %10
%25 = load i32, i32* %10
store i32 %25, i32* %5
%26 = load i32, i32* %10
%27 = ashr i32 %26, 32
store i32 %27, i32* %9
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 10
%30 = load i32, i32* %9
%31 = add i32 %29, %30
store i32 %31, i32* %10
%32 = load i32, i32* %10
store i32 %32, i32* %6
%33 = load i32, i32* %10
%34 = ashr i32 %33, 32
store i32 %34, i32* %9
%35 = load i32, i32* %7
%36 = mul nsw i32 %35, 10
%37 = load i32, i32* %9
%38 = add i32 %36, %37
store i32 %38, i32* %7
br label %11
39: ; preds = %19
%40 = load i32, i32* %5
%41 = load i32*, i32** %4
%42 = getelementptr inbounds i32, i32* %41, i64 0
store i32 %40, i32* %42
%43 = load i32, i32* %6
%44 = load i32*, i32** %4
%45 = getelementptr inbounds i32, i32* %44, i64 1
store i32 %43, i32* %45
%46 = load i32, i32* %7
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 2
store i32 %46, i32* %48
ret void
}

LLVM IR (-O2):
define void @foo(i32* nocapture %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %11, %3 ]
%5 = phi i32* [ %0, %2 ], [ %6, %3 ]
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %5
%8 = add i32 %7, -48
%9 = icmp ugt i32 %8, 9
%10 = mul nsw i32 %4, 10
%11 = add i32 %8, %10
br i1 %9, label %12, label %3
12: ; preds = %3
store i32 %4, i32* %1
%13 = getelementptr inbounds i32, i32* %1, i64 1
store i32 0, i32* %13
%14 = getelementptr inbounds i32, i32* %1, i64 2
store i32 0, i32* %14
ret void
}