#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*/ printf(char *);
int strlen(char const *);
int ieee1888_datapool_parse_CSV_line(const char *line, char *row_id,
                                     char *row_time, char *row_value) {
  int i;
  int column = 0;
  int row_id_index = 0;
  int row_time_index = 0;
  int row_value_index = 0;
  int len = strlen(line);
  for (i = 0; i < len; i++) {
    if (line[i] == '\n') {
      break;
    }
    if (line[i] == ',') {
      column++;
      continue;
    }
    switch (column) {
    case 0:
      if (row_id_index < 256 - 1) {
        row_id[row_id_index++] = line[i];
      } else {
        printf("the lendth of id section is too long...\n");
        return 0;
      }
      break;
    case 1:
      if (row_time_index < 50 - 1) {
        row_time[row_time_index++] = line[i];
      } else {
        printf("the lendth of time section is too long...\n");
        return 0;
      }
      break;
    case 2:
      if (row_value_index < 40 - 1) {
        row_value[row_value_index++] = line[i];
      } else {
        printf("the lendth of value section is too long...\n");
        return 0;
      }
      break;
    default:
      i = len;
    }
  }
  row_id[row_id_index] = '\0';
  row_time[row_time_index] = '\0';
  row_value[row_value_index] = '\0';
  if (column != 2) {
    printf("Error while parsing a line of datapool CSV ...\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ieee1888_datapool_parse_CSV_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    12e5 <ieee1888_datapool_parse_CSV_line+0x1c5>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    118d <ieee1888_datapool_parse_CSV_line+0x6d>
jmp    12e5 <ieee1888_datapool_parse_CSV_line+0x1c5>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    11b0 <ieee1888_datapool_parse_CSV_line+0x90>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12d7 <ieee1888_datapool_parse_CSV_line+0x1b7>
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
test   %eax,%eax
je     11e5 <ieee1888_datapool_parse_CSV_line+0xc5>
jmp    11c3 <ieee1888_datapool_parse_CSV_line+0xa3>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
je     1234 <ieee1888_datapool_parse_CSV_line+0x114>
jmp    11d4 <ieee1888_datapool_parse_CSV_line+0xb4>
mov    -0x44(%rbp),%eax
sub    $0x2,%eax
je     1280 <ieee1888_datapool_parse_CSV_line+0x160>
jmp    12cc <ieee1888_datapool_parse_CSV_line+0x1ac>
cmpl   $0xff,-0x34(%rbp)
jge    1217 <ieee1888_datapool_parse_CSV_line+0xf7>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    122f <ieee1888_datapool_parse_CSV_line+0x10f>
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1332 <ieee1888_datapool_parse_CSV_line+0x212>
jmp    12d2 <ieee1888_datapool_parse_CSV_line+0x1b2>
cmpl   $0x31,-0x38(%rbp)
jge    1263 <ieee1888_datapool_parse_CSV_line+0x143>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x38(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    127b <ieee1888_datapool_parse_CSV_line+0x15b>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1332 <ieee1888_datapool_parse_CSV_line+0x212>
jmp    12d2 <ieee1888_datapool_parse_CSV_line+0x1b2>
cmpl   $0x27,-0x3c(%rbp)
jge    12af <ieee1888_datapool_parse_CSV_line+0x18f>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x3c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    12c7 <ieee1888_datapool_parse_CSV_line+0x1a7>
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1332 <ieee1888_datapool_parse_CSV_line+0x212>
jmp    12d2 <ieee1888_datapool_parse_CSV_line+0x1b2>
mov    -0x40(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    12d7 <ieee1888_datapool_parse_CSV_line+0x1b7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <ieee1888_datapool_parse_CSV_line+0x47>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x2,-0x30(%rbp)
je     132b <ieee1888_datapool_parse_CSV_line+0x20b>
lea    0xd66(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1332 <ieee1888_datapool_parse_CSV_line+0x212>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ieee1888_datapool_parse_CSV_line>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e9 <ieee1888_datapool_parse_CSV_line+0xc9>
xor    %r10d,%r10d
lea    0xee3(%rip),%rdi
lea    0xf07(%rip),%r8
lea    0xf2a(%rip),%r9
xor    %r11d,%r11d
xor    %esi,%esi
xor    %ecx,%ecx
xor    %edx,%edx
jmp    117a <ieee1888_datapool_parse_CSV_line+0x5a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ecx
add    $0x1,%edx
cmp    %eax,%edx
jge    11f3 <ieee1888_datapool_parse_CSV_line+0xd3>
movslq %edx,%rbx
movzbl 0x0(%r13,%rbx,1),%ebx
cmp    $0x2c,%bl
je     1170 <ieee1888_datapool_parse_CSV_line+0x50>
cmp    $0xa,%bl
je     11f3 <ieee1888_datapool_parse_CSV_line+0xd3>
cmp    $0x2,%ecx
je     11b5 <ieee1888_datapool_parse_CSV_line+0x95>
cmp    $0x1,%ecx
je     11cd <ieee1888_datapool_parse_CSV_line+0xad>
test   %ecx,%ecx
jne    11e5 <ieee1888_datapool_parse_CSV_line+0xc5>
cmp    $0xfe,%esi
jg     122d <ieee1888_datapool_parse_CSV_line+0x10d>
movslq %esi,%rcx
add    $0x1,%esi
mov    %bl,(%r12,%rcx,1)
xor    %ecx,%ecx
jmp    1173 <ieee1888_datapool_parse_CSV_line+0x53>
cmp    $0x26,%r10d
jg     121c <ieee1888_datapool_parse_CSV_line+0xfc>
movslq %r10d,%rcx
add    $0x1,%r10d
mov    %bl,(%r14,%rcx,1)
mov    $0x2,%ecx
jmp    1173 <ieee1888_datapool_parse_CSV_line+0x53>
cmp    $0x30,%r11d
jg     1232 <ieee1888_datapool_parse_CSV_line+0x112>
movslq %r11d,%rcx
add    $0x1,%r11d
mov    %bl,(%r15,%rcx,1)
mov    $0x1,%ecx
jmp    1173 <ieee1888_datapool_parse_CSV_line+0x53>
mov    %eax,%edx
jmp    1173 <ieee1888_datapool_parse_CSV_line+0x53>
xor    %ecx,%ecx
xor    %esi,%esi
xor    %r11d,%r11d
xor    %r10d,%r10d
movslq %esi,%rax
movb   $0x0,(%r12,%rax,1)
movslq %r11d,%rax
movb   $0x0,(%r15,%rax,1)
movslq %r10d,%rax
movb   $0x0,(%r14,%rax,1)
mov    $0x1,%eax
cmp    $0x2,%ecx
je     1223 <ieee1888_datapool_parse_CSV_line+0x103>
lea    0xde4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r9,%rdi
jmp    121c <ieee1888_datapool_parse_CSV_line+0xfc>
mov    %r8,%rdi
jmp    121c <ieee1888_datapool_parse_CSV_line+0xfc>

LLVM IR (-O0):
@.str = [41 x i8] c"the lendth of id section is too long...\0A\00"
@.str.1 = [43 x i8] c"the lendth of time section is too long...\0A\00"
@.str.2 = [44 x i8] c"the lendth of value section is too long...\0A\00"
@.str.3 = [48 x i8] c"Error while parsing a line of datapool CSV ...\0A\00"
define i32 @ieee1888_datapool_parse_CSV_line(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %15
store i32 0, i32* %10
br label %18
18: ; preds = %98, %4
%19 = load i32, i32* %10
%20 = load i32, i32* %15
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %101
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %22
br label %101
31: ; preds = %22
%32 = load i8*, i8** %6
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 44
br i1 %38, label %39, label %42
39: ; preds = %31
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %98
42: ; preds = %31
%43 = load i32, i32* %11
switch i32 %43, label %95 [
i32 0, label %44
i32 1, label %61
i32 2, label %78
]
44: ; preds = %42
%45 = load i32, i32* %12
%46 = icmp slt i32 %45, 255
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %7
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
store i32 %55, i32* %12
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
store i8 %52, i8* %57
br label %60
58: ; preds = %44
%59 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %119
60: ; preds = %47
br label %97
61: ; preds = %42
%62 = load i32, i32* %13
%63 = icmp slt i32 %62, 49
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = load i8*, i8** %6
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = load i8*, i8** %8
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 1
store i32 %72, i32* %13
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
store i8 %69, i8* %74
br label %77
75: ; preds = %61
%76 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %119
77: ; preds = %64
br label %97
78: ; preds = %42
%79 = load i32, i32* %14
%80 = icmp slt i32 %79, 39
br i1 %80, label %81, label %92
81: ; preds = %78
%82 = load i8*, i8** %6
%83 = load i32, i32* %10
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = load i8, i8* %85
%87 = load i8*, i8** %9
%88 = load i32, i32* %14
%89 = add nsw i32 %88, 1
store i32 %89, i32* %14
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
store i8 %86, i8* %91
br label %94
92: ; preds = %78
%93 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %119
94: ; preds = %81
br label %97
95: ; preds = %42
%96 = load i32, i32* %15
store i32 %96, i32* %10
br label %97
97: ; preds = %95, %94, %77, %60
br label %98
98: ; preds = %97, %39
%99 = load i32, i32* %10
%100 = add nsw i32 %99, 1
store i32 %100, i32* %10
br label %18
101: ; preds = %30, %18
%102 = load i8*, i8** %7
%103 = load i32, i32* %12
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %102, i64 %104
store i8 0, i8* %105
%106 = load i8*, i8** %8
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
store i8 0, i8* %109
%110 = load i8*, i8** %9
%111 = load i32, i32* %14
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %110, i64 %112
store i8 0, i8* %113
%114 = load i32, i32* %11
%115 = icmp ne i32 %114, 2
br i1 %115, label %116, label %118
116: ; preds = %101
%117 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %119
118: ; preds = %101
store i32 1, i32* %5
br label %119
119: ; preds = %118, %116, %92, %75, %58
%120 = load i32, i32* %5
ret i32 %120
}

LLVM IR (-O2):
@str = [47 x i8] c"Error while parsing a line of datapool CSV ...\00"
@str.4 = [43 x i8] c"the lendth of value section is too long...\00"
@str.5 = [42 x i8] c"the lendth of time section is too long...\00"
@str.6 = [40 x i8] c"the lendth of id section is too long...\00"
define i32 @ieee1888_datapool_parse_CSV_line(i8* %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2, i8* nocapture writeonly %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %45
7: ; preds = %4, %37
%8 = phi i32 [ %42, %37 ], [ 0, %4 ]
%9 = phi i32 [ %41, %37 ], [ 0, %4 ]
%10 = phi i32 [ %40, %37 ], [ 0, %4 ]
%11 = phi i32 [ %39, %37 ], [ 0, %4 ]
%12 = phi i32 [ %43, %37 ], [ 0, %4 ]
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
switch i8 %15, label %18 [
i8 10, label %45
i8 44, label %16
]
16: ; preds = %7
%17 = add nsw i32 %11, 1
br label %37
18: ; preds = %7
switch i32 %11, label %37 [
i32 0, label %19
i32 1, label %25
i32 2, label %31
]
19: ; preds = %18
%20 = icmp slt i32 %10, 255
br i1 %20, label %21, label %57
21: ; preds = %19
%22 = add nsw i32 %10, 1
%23 = sext i32 %10 to i64
%24 = getelementptr inbounds i8, i8* %1, i64 %23
store i8 %15, i8* %24
br label %37
25: ; preds = %18
%26 = icmp slt i32 %9, 49
br i1 %26, label %27, label %57
27: ; preds = %25
%28 = add nsw i32 %9, 1
%29 = sext i32 %9 to i64
%30 = getelementptr inbounds i8, i8* %2, i64 %29
store i8 %15, i8* %30
br label %37
31: ; preds = %18
%32 = icmp slt i32 %8, 39
br i1 %32, label %33, label %57
33: ; preds = %31
%34 = add nsw i32 %8, 1
%35 = sext i32 %8 to i64
%36 = getelementptr inbounds i8, i8* %3, i64 %35
store i8 %15, i8* %36
br label %37
37: ; preds = %18, %21, %27, %33, %16
%38 = phi i32 [ %12, %16 ], [ %12, %33 ], [ %12, %27 ], [ %12, %21 ], [ %5, %18 ]
%39 = phi i32 [ %17, %16 ], [ 2, %33 ], [ 1, %27 ], [ 0, %21 ], [ %11, %18 ]
%40 = phi i32 [ %10, %16 ], [ %10, %33 ], [ %10, %27 ], [ %22, %21 ], [ %10, %18 ]
%41 = phi i32 [ %9, %16 ], [ %9, %33 ], [ %28, %27 ], [ %9, %21 ], [ %9, %18 ]
%42 = phi i32 [ %8, %16 ], [ %34, %33 ], [ %8, %27 ], [ %8, %21 ], [ %8, %18 ]
%43 = add nsw i32 %38, 1
%44 = icmp slt i32 %43, %5
br i1 %44, label %7, label %45
45: ; preds = %37, %7, %4
%46 = phi i32 [ 0, %4 ], [ %11, %7 ], [ %39, %37 ]
%47 = phi i32 [ 0, %4 ], [ %10, %7 ], [ %40, %37 ]
%48 = phi i32 [ 0, %4 ], [ %9, %7 ], [ %41, %37 ]
%49 = phi i32 [ 0, %4 ], [ %8, %7 ], [ %42, %37 ]
%50 = sext i32 %47 to i64
%51 = getelementptr inbounds i8, i8* %1, i64 %50
store i8 0, i8* %51
%52 = sext i32 %48 to i64
%53 = getelementptr inbounds i8, i8* %2, i64 %52
store i8 0, i8* %53
%54 = sext i32 %49 to i64
%55 = getelementptr inbounds i8, i8* %3, i64 %54
store i8 0, i8* %55
%56 = icmp eq i32 %46, 2
br i1 %56, label %60, label %57
57: ; preds = %31, %25, %19, %45
%58 = phi i8* [ getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0), %45 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0), %19 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.5, i64 0, i64 0), %25 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.4, i64 0, i64 0), %31 ]
%59 = tail call i32 @puts(i8* dereferenceable(1) %58)
br label %60
60: ; preds = %57, %45
%61 = phi i32 [ 1, %45 ], [ 0, %57 ]
ret i32 %61
}