#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*/ initializeString(char *, int);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int strnlen(char *, int);
void parseCSV(char *line, char csvData[10][50]) {
  char buffer[50];
  initializeString(buffer, 50);
  const int maxLength = strnlen(line, 500);
  int i = 0;
  int currentField = 0;
  for (i = 0; i < maxLength; i++) {
    if (line[i] == ',' || line[i] == '\n' || line[i] == '\0' ||
        i == (maxLength - 1)) {
      initializeString(csvData[currentField], 50);
      strncpy(csvData[currentField], buffer, 50);
      currentField++;
      initializeString(buffer, 50);
      continue;
    }
    if (i >= 0 && i < maxLength) {
      char temp[2];
      initializeString(temp, 2);
      temp[0] = line[i];
      strncat(buffer, temp, 1);
    }
  }
}


x86 assembly (clang, -O0):
<parseCSV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1f4,%esi
call   1050 <strnlen@plt>
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1289 <parseCSV+0x149>
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
je     11e0 <parseCSV+0xa0>
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11e0 <parseCSV+0xa0>
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11e0 <parseCSV+0xa0>
mov    -0x58(%rbp),%eax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1232 <parseCSV+0xf2>
mov    -0x10(%rbp),%rdi
movslq -0x5c(%rbp),%rax
imul   $0x32,%rax,%rax
add    %rax,%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
mov    -0x10(%rbp),%rdi
movslq -0x5c(%rbp),%rax
imul   $0x32,%rax,%rax
add    %rax,%rdi
lea    -0x50(%rbp),%rsi
mov    $0x32,%edx
call   1030 <strncpy@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
jmp    127b <parseCSV+0x13b>
cmpl   $0x0,-0x58(%rbp)
jl     1276 <parseCSV+0x136>
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1276 <parseCSV+0x136>
lea    -0x5e(%rbp),%rdi
mov    $0x2,%esi
call   1040 <initializeString@plt>
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x5e(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x5e(%rbp),%rsi
mov    $0x1,%edx
call   1060 <strncat@plt>
jmp    127b <parseCSV+0x13b>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1184 <parseCSV+0x44>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseCSV>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,0x18(%rsp)
mov    %rdi,%r12
lea    0x20(%rsp),%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
mov    %r12,%rdi
mov    $0x1f4,%esi
call   1050 <strnlen@plt>
test   %eax,%eax
jle    1232 <parseCSV+0xf2>
lea    -0x1(%rax),%ecx
mov    %rcx,0x10(%rsp)
mov    %eax,%r15d
xor    %ebp,%ebp
lea    0x20(%rsp),%r13
xor    %r14d,%r14d
jmp    11e3 <parseCSV+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %r14d,%r14
imul   $0x32,%r14,%rbx
add    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x32,%edx
call   1030 <strncpy@plt>
add    $0x1,%r14d
mov    %r13,%rdi
mov    $0x32,%esi
call   1040 <initializeString@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     1232 <parseCSV+0xf2>
movzbl (%r12,%rbp,1),%eax
cmp    $0x2c,%rax
ja     11fe <parseCSV+0xbe>
movabs $0x100000000401,%rcx
bt     %rax,%rcx
jb     11a0 <parseCSV+0x60>
cmp    %rbp,0x10(%rsp)
je     11a0 <parseCSV+0x60>
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <initializeString@plt>
movzbl (%r12,%rbp,1),%eax
mov    %al,0xe(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1060 <strncat@plt>
jmp    11da <parseCSV+0x9a>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @parseCSV(i8* %0, [50 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [50 x i8]*
%5 = alloca [50 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i8]
store i8* %0, i8** %3
store [50 x i8]* %1, [50 x i8]** %4
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%11 = call i32 @initializeString(i8* %10, i32 50)
%12 = load i8*, i8** %3
%13 = call i32 @strnlen(i8* %12, i32 500)
store i32 %13, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %7
br label %14
14: ; preds = %85, %2
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %88
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 44
br i1 %25, label %47, label %26
26: ; preds = %18
%27 = load i8*, i8** %3
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %47, label %34
34: ; preds = %26
%35 = load i8*, i8** %3
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %34
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, 1
%46 = icmp eq i32 %43, %45
br i1 %46, label %47, label %65
47: ; preds = %42, %34, %26, %18
%48 = load [50 x i8]*, [50 x i8]** %4
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %48, i64 %50
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %51, i64 0, i64 0
%53 = call i32 @initializeString(i8* %52, i32 50)
%54 = load [50 x i8]*, [50 x i8]** %4
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %54, i64 %56
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %57, i64 0, i64 0
%59 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%60 = call i32 @strncpy(i8* %58, i8* %59, i32 50)
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
%63 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%64 = call i32 @initializeString(i8* %63, i32 50)
br label %85
65: ; preds = %42
%66 = load i32, i32* %7
%67 = icmp sge i32 %66, 0
br i1 %67, label %68, label %84
68: ; preds = %65
%69 = load i32, i32* %7
%70 = load i32, i32* %6
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %84
72: ; preds = %68
%73 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%74 = call i32 @initializeString(i8* %73, i32 2)
%75 = load i8*, i8** %3
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %75, i64 %77
%79 = load i8, i8* %78
%80 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
store i8 %79, i8* %80
%81 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%82 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%83 = call i32 @strncat(i8* %81, i8* %82, i32 1)
br label %84
84: ; preds = %72, %68, %65
br label %85
85: ; preds = %84, %47
%86 = load i32, i32* %7
%87 = add nsw i32 %86, 1
store i32 %87, i32* %7
br label %14
88: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @parseCSV(i8* %0, [50 x i8]* %1) {
%3 = alloca [50 x i8]
%4 = alloca [2 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = call i32 @initializeString(i8* %5, i32 50)
%7 = call i32 @strnlen(i8* %0, i32 500)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %2
%10 = add nsw i32 %7, -1
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%12 = zext i32 %10 to i64
%13 = zext i32 %7 to i64
br label %14
14: ; preds = %9, %32
%15 = phi i64 [ 0, %9 ], [ %34, %32 ]
%16 = phi i32 [ 0, %9 ], [ %33, %32 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 44, label %21
i8 10, label %21
i8 0, label %21
]
19: ; preds = %14
%20 = icmp eq i64 %15, %12
br i1 %20, label %21, label %28
21: ; preds = %14, %14, %14, %19
%22 = sext i32 %16 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 %22, i64 0
%24 = call i32 @initializeString(i8* %23, i32 50)
%25 = call i32 @strncpy(i8* %23, i8* %5, i32 50)
%26 = add nsw i32 %16, 1
%27 = call i32 @initializeString(i8* %5, i32 50)
br label %32
28: ; preds = %19
%29 = call i32 @initializeString(i8* %11, i32 2)
%30 = load i8, i8* %17
store i8 %30, i8* %11
%31 = call i32 @strncat(i8* %5, i8* %11, i32 1)
br label %32
32: ; preds = %28, %21
%33 = phi i32 [ %26, %21 ], [ %16, %28 ]
%34 = add nuw nsw i64 %15, 1
%35 = icmp eq i64 %34, %13
br i1 %35, label %36, label %14
36: ; preds = %32, %2
ret void
}