#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 */
double atof(char *);
int /*<<< orphan*/ printf(char *);
void vExplode(const char *sLine, double *dArray, unsigned iItemsOnLine) {
  char sBuffer[128];
  short iPos = 0;
  char *c = (char *)sLine;
  unsigned i = 0;
  while (1) {
    if (*c == 0)
      break;
    if (*c == '\t' || *c == '\n') {
      sBuffer[iPos] = 0;
      iPos = 0;
      if (i < iItemsOnLine)
        dArray[i] = atof(sBuffer);
      else {
        printf("error: too many items on line\n");
        break;
      }
      ++i;
    } else {
      sBuffer[iPos] = *c;
      ++iPos;
    }
    ++c;
  }
}


x86 assembly (clang, -O0):
<vExplode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movw   $0x0,-0xa2(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <vExplode+0x4c>
jmp    1240 <vExplode+0x120>
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     1192 <vExplode+0x72>
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11ff <vExplode+0xdf>
movswq -0xa2(%rbp),%rax
ff
movb   $0x0,-0xa0(%rbp,%rax,1)
movw   $0x0,-0xa2(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11da <vExplode+0xba>
lea    -0xa0(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x10(%rbp),%rax
mov    -0xb4(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11eb <vExplode+0xcb>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
jmp    1240 <vExplode+0x120>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1229 <vExplode+0x109>
mov    -0xb0(%rbp),%rax
mov    (%rax),%cl
movswq -0xa2(%rbp),%rax
ff
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xa2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa2(%rbp)
mov    -0xb0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xb0(%rbp)
jmp    1154 <vExplode+0x34>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vExplode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
mov    %rsp,%r15
xor    %ebp,%ebp
nop
movzbl (%rbx),%ecx
lea    -0x9(%rcx),%edx
cmp    $0x2,%dl
jae    1180 <vExplode+0x60>
movswq %ax,%rax
movb   $0x0,(%rsp,%rax,1)
cmp    %r12d,%ebp
jae    1194 <vExplode+0x74>
mov    %r15,%rdi
call   1040 <atof@plt>
mov    %ebp,%eax
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%ebp
xor    %eax,%eax
add    $0x1,%rbx
jmp    1140 <vExplode+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %cl,%cl
je     11af <vExplode+0x8f>
movswq %ax,%rdx
mov    %cl,(%rsp,%rdx,1)
add    $0x1,%eax
add    $0x1,%rbx
jmp    1140 <vExplode+0x20>
lea    0xe65(%rip),%rdi
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"error: too many items on line\0A\00"
define void @vExplode(i8* %0, double* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i16
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i16 0, i16* %8
%11 = load i8*, i8** %4
store i8* %11, i8** %9
store i32 0, i32* %10
br label %12
12: ; preds = %3, %55
%13 = load i8*, i8** %9
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %58
18: ; preds = %12
%19 = load i8*, i8** %9
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 9
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %9
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %47
28: ; preds = %23, %18
%29 = load i16, i16* %8
%30 = sext i16 %29 to i64
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %30
store i8 0, i8* %31
store i16 0, i16* %8
%32 = load i32, i32* %10
%33 = load i32, i32* %6
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %28
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%37 = call double @atof(i8* %36)
%38 = load double*, double** %5
%39 = load i32, i32* %10
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %44
42: ; preds = %28
%43 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %58
44: ; preds = %35
%45 = load i32, i32* %10
%46 = add i32 %45, 1
store i32 %46, i32* %10
br label %55
47: ; preds = %23
%48 = load i8*, i8** %9
%49 = load i8, i8* %48
%50 = load i16, i16* %8
%51 = sext i16 %50 to i64
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %51
store i8 %49, i8* %52
%53 = load i16, i16* %8
%54 = add i16 %53, 1
store i16 %54, i16* %8
br label %55
55: ; preds = %47, %44
%56 = load i8*, i8** %9
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %9
br label %12
58: ; preds = %42, %17
ret void
}

LLVM IR (-O2):
@str = [30 x i8] c"error: too many items on line\00"
define void @vExplode(i8* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
br label %6
6: ; preds = %26, %3
%7 = phi i16 [ 0, %3 ], [ %27, %26 ]
%8 = phi i8* [ %0, %3 ], [ %29, %26 ]
%9 = phi i32 [ 0, %3 ], [ %28, %26 ]
%10 = load i8, i8* %8
switch i8 %10, label %22 [
i8 0, label %30
i8 9, label %11
i8 10, label %11
]
11: ; preds = %6, %6
%12 = sext i16 %7 to i64
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %12
store i8 0, i8* %13
%14 = icmp ult i32 %9, %2
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call double @atof(i8* %5)
%17 = zext i32 %9 to i64
%18 = getelementptr inbounds double, double* %1, i64 %17
store double %16, double* %18
%19 = add nuw i32 %9, 1
br label %26
20: ; preds = %11
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %30
22: ; preds = %6
%23 = sext i16 %7 to i64
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %23
store i8 %10, i8* %24
%25 = add i16 %7, 1
br label %26
26: ; preds = %22, %15
%27 = phi i16 [ 0, %15 ], [ %25, %22 ]
%28 = phi i32 [ %19, %15 ], [ %9, %22 ]
%29 = getelementptr inbounds i8, i8* %8, i64 1
br label %6
30: ; preds = %6, %20
ret void
}