void extract_dimension_sizes(num_of_dimensions, string,
                             size_of_dimension) int num_of_dimensions;
char *string;
unsigned int *size_of_dimension;
{
  int i;
  char *cur = string;
  char *last = string;
  for (i = 0; i < num_of_dimensions; i++) {
    size_of_dimension[i] = 0;
  }
  for (i = 0; (('\0' != *last) && (i < num_of_dimensions)); cur++) {
    if ('\0' == *cur) {
      size_of_dimension[i] = xstrtoul(last, 16);
      last = cur;
    } else if (':' == *cur) {
      *cur = '\0';
      size_of_dimension[i] = xstrtoul(last, 16);
      *cur = ':';
      last = cur + 1;
      i++;
    }
  }
}


x86 assembly (clang, -O0):
<extract_dimension_sizes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1163 <extract_dimension_sizes+0x53>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <extract_dimension_sizes+0x2a>
movl   $0x0,-0x1c(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x31(%rbp)
je     118c <extract_dimension_sizes+0x7c>
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    119c <extract_dimension_sizes+0x8c>
jmp    1246 <extract_dimension_sizes+0x136>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    11d7 <extract_dimension_sizes+0xc7>
mov    -0x30(%rbp),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1030 <xstrtoul@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1230 <extract_dimension_sizes+0x120>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    122b <extract_dimension_sizes+0x11b>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1030 <xstrtoul@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
movb   $0x3a,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1230 <extract_dimension_sizes+0x120>
jmp    1235 <extract_dimension_sizes+0x125>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116a <extract_dimension_sizes+0x5a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_dimension_sizes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11e0 <extract_dimension_sizes+0xc0>
mov    %rdx,%r14
mov    %rsi,%r13
mov    %edi,%r15d
mov    %edi,%edx
shl    $0x2,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x0(%r13),%al
test   %al,%al
je     11e0 <extract_dimension_sizes+0xc0>
test   %r15d,%r15d
jle    11e0 <extract_dimension_sizes+0xc0>
lea    0x1(%r13),%rbx
mov    %r13,%r12
xor    %ebp,%ebp
cmp    $0x3a,%al
je     11a0 <extract_dimension_sizes+0x80>
xchg   %ax,%ax
test   %al,%al
jne    118d <extract_dimension_sizes+0x6d>
mov    %r13,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <xstrtoul@plt>
movslq %ebp,%rcx
mov    %eax,(%r14,%rcx,4)
mov    %r12,%r13
cmpb   $0x0,0x0(%r13)
jne    11cb <extract_dimension_sizes+0xab>
jmp    11e0 <extract_dimension_sizes+0xc0>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,-0x1(%rbx)
mov    %r13,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <xstrtoul@plt>
movslq %ebp,%rbp
mov    %eax,(%r14,%rbp,4)
movb   $0x3a,-0x1(%rbx)
add    $0x1,%ebp
mov    %rbx,%r13
cmpb   $0x0,0x0(%r13)
je     11e0 <extract_dimension_sizes+0xc0>
cmp    %r15d,%ebp
jge    11e0 <extract_dimension_sizes+0xc0>
add    $0x1,%r12
mov    (%rbx),%al
add    $0x1,%rbx
cmp    $0x3a,%al
jne    1170 <extract_dimension_sizes+0x50>
jmp    11a0 <extract_dimension_sizes+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @extract_dimension_sizes(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %5
store i8* %10, i8** %8
%11 = load i8*, i8** %5
store i8* %11, i8** %9
store i32 0, i32* %7
br label %12
12: ; preds = %21, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32*, i32** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 0, i32* %20
br label %21
21: ; preds = %16
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %12
24: ; preds = %12
store i32 0, i32* %7
br label %25
25: ; preds = %69, %24
%26 = load i8*, i8** %9
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 0, %28
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br label %34
34: ; preds = %30, %25
%35 = phi i1 [ false, %25 ], [ %33, %30 ]
br i1 %35, label %36, label %72
36: ; preds = %34
%37 = load i8*, i8** %8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 0, %39
br i1 %40, label %41, label %49
41: ; preds = %36
%42 = load i8*, i8** %9
%43 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @xstrtoul to i32 (i8*, i32, ...)*)(i8* %42, i32 16)
%44 = load i32*, i32** %6
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 %43, i32* %47
%48 = load i8*, i8** %8
store i8* %48, i8** %9
br label %68
49: ; preds = %36
%50 = load i8*, i8** %8
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 58, %52
br i1 %53, label %54, label %67
54: ; preds = %49
%55 = load i8*, i8** %8
store i8 0, i8* %55
%56 = load i8*, i8** %9
%57 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @xstrtoul to i32 (i8*, i32, ...)*)(i8* %56, i32 16)
%58 = load i32*, i32** %6
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
store i32 %57, i32* %61
%62 = load i8*, i8** %8
store i8 58, i8* %62
%63 = load i8*, i8** %8
%64 = getelementptr inbounds i8, i8* %63, i64 1
store i8* %64, i8** %9
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %67
67: ; preds = %54, %49
br label %68
68: ; preds = %67, %41
br label %69
69: ; preds = %68
%70 = load i8*, i8** %8
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %8
br label %25
72: ; preds = %34
ret void
}

LLVM IR (-O2):
define void @extract_dimension_sizes(i32 %0, i8* %1, i32* nocapture writeonly %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %37
5: ; preds = %3
%6 = bitcast i32* %2 to i8*
%7 = zext i32 %0 to i64
%8 = shl nuw nsw i64 %7, 2
%9 = load i8, i8* %1
%10 = icmp ne i8 %9, 0
%11 = and i1 %10, %4
br i1 %11, label %12, label %37
12: ; preds = %5, %35
%13 = phi i8 [ %36, %35 ], [ %9, %5 ]
%14 = phi i8* [ %29, %35 ], [ %1, %5 ]
%15 = phi i8* [ %30, %35 ], [ %1, %5 ]
%16 = phi i32 [ %28, %35 ], [ 0, %5 ]
switch i8 %13, label %27 [
i8 0, label %17
i8 58, label %21
]
17: ; preds = %12
%18 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @xstrtoul to i32 (i8*, i32, ...)*)(i8* %14, i32 16)
%19 = sext i32 %16 to i64
%20 = getelementptr inbounds i32, i32* %2, i64 %19
store i32 %18, i32* %20
br label %27
21: ; preds = %12
store i8 0, i8* %15
%22 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @xstrtoul to i32 (i8*, i32, ...)*)(i8* %14, i32 16)
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds i32, i32* %2, i64 %23
store i32 %22, i32* %24
store i8 58, i8* %15
%25 = getelementptr inbounds i8, i8* %15, i64 1
%26 = add nsw i32 %16, 1
br label %27
27: ; preds = %12, %17, %21
%28 = phi i32 [ %16, %17 ], [ %26, %21 ], [ %16, %12 ]
%29 = phi i8* [ %15, %17 ], [ %25, %21 ], [ %14, %12 ]
%30 = getelementptr inbounds i8, i8* %15, i64 1
%31 = load i8, i8* %29
%32 = icmp ne i8 %31, 0
%33 = icmp slt i32 %28, %0
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = load i8, i8* %30
br label %12
37: ; preds = %27, %3, %5
ret void
}