#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*/ FILE;

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok_csv(char *, char *, char **);
int getStoreCtHeader(char **header) {
  FILE *fp;
  fp = fopen("/local/etc/sysconfig"
             "/Crosstable.csv",
             "r");
  if (fp == NULL) {
    ;
    return -1;
  }
  char line[4096];
  char *p, *r;
  strcpy(header[0], "date");
  strcpy(header[1], "time");
  int j = 2;
  while (fgets(line, 4096, fp) != NULL) {
    p = strtok_csv(line, ";", &r);
    if (p != NULL && atoi(p) > 0) {
      p = strtok_csv(NULL, ";", &r);
      if (p != NULL) {
        switch (p[0]) {
        case 'S':
        case 'F':
        case 'V':
        case 'X':
          p = strtok_csv(NULL, ";", &r);
          if (p != NULL) {
            strcpy(header[j], p);
            ;
            j++;
          }
          break;
        default:
          break;
        }
      }
    }
  }
  fclose(fp);
  return j;
}


x86 assembly (clang, -O0):
<getStoreCtHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119d <getStoreCtHeader+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <getStoreCtHeader+0x1d9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x2,-0x1034(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1327 <getStoreCtHeader+0x1c7>
lea    -0x1020(%rbp),%rdi
lea    0xe35(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
je     1322 <getStoreCtHeader+0x1c2>
mov    -0x1028(%rbp),%rdi
call   1080 <atoi@plt>
cmp    $0x0,%rax
jle    1322 <getStoreCtHeader+0x1c2>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf3(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
je     131d <getStoreCtHeader+0x1bd>
mov    -0x1028(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1038(%rbp)
sub    $0x46,%eax
je     12b8 <getStoreCtHeader+0x158>
jmp    127c <getStoreCtHeader+0x11c>
mov    -0x1038(%rbp),%eax
sub    $0x53,%eax
je     12b8 <getStoreCtHeader+0x158>
jmp    1290 <getStoreCtHeader+0x130>
mov    -0x1038(%rbp),%eax
sub    $0x56,%eax
je     12b8 <getStoreCtHeader+0x158>
jmp    12a4 <getStoreCtHeader+0x144>
mov    -0x1038(%rbp),%eax
sub    $0x58,%eax
jne    1313 <getStoreCtHeader+0x1b3>
jmp    12b8 <getStoreCtHeader+0x158>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd6d(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
je     130e <getStoreCtHeader+0x1ae>
mov    -0x10(%rbp),%rax
movslq -0x1034(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x1028(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x1034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1034(%rbp)
jmp    1318 <getStoreCtHeader+0x1b8>
jmp    1318 <getStoreCtHeader+0x1b8>
jmp    131d <getStoreCtHeader+0x1bd>
jmp    1322 <getStoreCtHeader+0x1c2>
jmp    11ce <getStoreCtHeader+0x6e>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getStoreCtHeader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rdi,%r14
lea    0xe85(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1280 <getStoreCtHeader+0x120>
mov    %rax,%r13
mov    (%r14),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x8(%r14),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rdi
mov    $0x1000,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    $0x2,%r15d
test   %rax,%rax
je     1276 <getStoreCtHeader+0x116>
lea    0xe56(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rbp
jmp    1205 <getStoreCtHeader+0xa5>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1276 <getStoreCtHeader+0x116>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <strtok_csv@plt>
test   %rax,%rax
je     11f0 <getStoreCtHeader+0x90>
mov    %rax,%rdi
call   1080 <atoi@plt>
test   %rax,%rax
jle    11f0 <getStoreCtHeader+0x90>
xor    %edi,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <strtok_csv@plt>
test   %rax,%rax
je     11f0 <getStoreCtHeader+0x90>
movsbl (%rax),%eax
add    $0xffffffba,%eax
cmp    $0x12,%eax
ja     11f0 <getStoreCtHeader+0x90>
mov    $0x52001,%ecx
bt     %eax,%ecx
jae    11f0 <getStoreCtHeader+0x90>
xor    %edi,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <strtok_csv@plt>
test   %rax,%rax
je     11f0 <getStoreCtHeader+0x90>
movslq %r15d,%r15
mov    (%r14,%r15,8),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r15d
jmp    11f0 <getStoreCtHeader+0x90>
mov    %r13,%rdi
call   1050 <fclose@plt>
jmp    1286 <getStoreCtHeader+0x126>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"/local/etc/sysconfig/Crosstable.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"date\00"
@.str.3 = [5 x i8] c"time\00"
@.str.4 = [2 x i8] c";\00"
define i32 @getStoreCtHeader(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca [4096 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %3
%9 = call i32* @fopen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %68
13: ; preds = %1
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8**, i8*** %3
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %8
br label %22
22: ; preds = %63, %13
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%24 = load i32*, i32** %4
%25 = call i32* @fgets(i8* %23, i32 4096, i32* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %64
27: ; preds = %22
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%29 = call i8* @strtok_csv(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %7)
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %63
32: ; preds = %27
%33 = load i8*, i8** %6
%34 = call i64 @atoi(i8* %33)
%35 = icmp sgt i64 %34, 0
br i1 %35, label %36, label %63
36: ; preds = %32
%37 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %7)
store i8* %37, i8** %6
%38 = load i8*, i8** %6
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %62
40: ; preds = %36
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
switch i32 %44, label %60 [
i32 83, label %45
i32 70, label %45
i32 86, label %45
i32 88, label %45
]
45: ; preds = %40, %40, %40, %40
%46 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %7)
store i8* %46, i8** %6
%47 = load i8*, i8** %6
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i8**, i8*** %3
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = load i8*, i8** %6
%56 = call i32 @strcpy(i8* %54, i8* %55)
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %59
59: ; preds = %49, %45
br label %61
60: ; preds = %40
br label %61
61: ; preds = %60, %59
br label %62
62: ; preds = %61, %36
br label %63
63: ; preds = %62, %32, %27
br label %22
64: ; preds = %22
%65 = load i32*, i32** %4
%66 = call i32 @fclose(i32* %65)
%67 = load i32, i32* %8
store i32 %67, i32* %2
br label %68
68: ; preds = %64, %12
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [36 x i8] c"/local/etc/sysconfig/Crosstable.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"date\00"
@.str.3 = [5 x i8] c"time\00"
@.str.4 = [2 x i8] c";\00"
define i32 @getStoreCtHeader(i8** nocapture %0) {
%2 = alloca [4096 x i8]
%3 = alloca i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %45, label %6
6: ; preds = %1
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%8 = bitcast i8** %3 to i8*
%9 = load i8*, i8** %0
%10 = tail call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %0, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32* @fgets(i8* %7, i32 4096, i32* %4)
%15 = icmp eq i32* %14, null
br i1 %15, label %42, label %16
16: ; preds = %6, %38
%17 = phi i32 [ %39, %38 ], [ 2, %6 ]
%18 = call i8* @strtok_csv(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %3)
%19 = icmp eq i8* %18, null
br i1 %19, label %38, label %20
20: ; preds = %16
%21 = call i64 @atoi(i8* %18)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %3)
%25 = icmp eq i8* %24, null
br i1 %25, label %38, label %26
26: ; preds = %23
%27 = load i8, i8* %24
%28 = sext i8 %27 to i32
switch i32 %28, label %38 [
i32 83, label %29
i32 70, label %29
i32 86, label %29
i32 88, label %29
]
29: ; preds = %26, %26, %26, %26
%30 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %3)
%31 = icmp eq i8* %30, null
br i1 %31, label %38, label %32
32: ; preds = %29
%33 = sext i32 %17 to i64
%34 = getelementptr inbounds i8*, i8** %0, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %35, i8* %30)
%37 = add nsw i32 %17, 1
br label %38
38: ; preds = %23, %26, %29, %32, %20, %16
%39 = phi i32 [ %17, %26 ], [ %37, %32 ], [ %17, %29 ], [ %17, %23 ], [ %17, %20 ], [ %17, %16 ]
%40 = call i32* @fgets(i8* %7, i32 4096, i32* %4)
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %16
42: ; preds = %38, %6
%43 = phi i32 [ 2, %6 ], [ %39, %38 ]
%44 = call i32 @fclose(i32* %4)
br label %45
45: ; preds = %1, %42
%46 = phi i32 [ %43, %42 ], [ -1, %1 ]
ret i32 %46
}