#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 */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok_csv(char *, char *, char **);
int getStoreLogHeader(FILE *fp, char **logHeader) {
  char line[4096];
  char *p, *r;
  if (fgets(line, 4096, fp) == NULL) {
    ;
    return -1;
  }
  int i = 0;
  p = strtok_csv(line, ";", &r);
  do {
    strcpy(logHeader[i], p);
    i++;
  } while ((p = strtok_csv(NULL, ";", &r)));
  return i;
}


x86 assembly (clang, -O0):
<getStoreLogHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    116e <getStoreLogHeader+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <getStoreLogHeader+0xc4>
movl   $0x0,-0x1034(%rbp)
lea    -0x1020(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x1028(%rbp)
mov    -0x18(%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)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe32(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x1028(%rbp)
cmp    $0x0,%rax
jne    1199 <getStoreLogHeader+0x69>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getStoreLogHeader>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%r15
mov    %rdi,%rdx
lea    0x10(%rsp),%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11a4 <getStoreLogHeader+0x74>
lea    0xea1(%rip),%r14
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%r12
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <strtok_csv@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <strtok_csv@plt>
test   %rax,%rax
jne    1180 <getStoreLogHeader+0x50>
jmp    11a9 <getStoreLogHeader+0x79>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
define i32 @getStoreLogHeader(i32* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i32* @fgets(i8* %10, i32 4096, i32* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %33
15: ; preds = %2
store i32 0, i32* %9
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%17 = call i8* @strtok_csv(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %17, i8** %7
br label %18
18: ; preds = %28, %15
%19 = load i8**, i8*** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i8*, i8** %7
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %28
28: ; preds = %18
%29 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %29, i8** %7
%30 = icmp ne i8* %29, null
br i1 %30, label %18, label %31
31: ; preds = %28
%32 = load i32, i32* %9
store i32 %32, i32* %3
br label %33
33: ; preds = %31, %14
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
define i32 @getStoreLogHeader(i32* nocapture %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = call i32* @fgets(i8* %5, i32 4096, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %22, label %9
9: ; preds = %2
%10 = call i8* @strtok_csv(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ %17, %11 ], [ 0, %9 ]
%13 = phi i8* [ %18, %11 ], [ %10, %9 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
%15 = load i8*, i8** %14
%16 = call i32 @strcpy(i8* %15, i8* %13)
%17 = add nuw i64 %12, 1
%18 = call i8* @strtok_csv(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = trunc i64 %17 to i32
br label %22
22: ; preds = %20, %2
%23 = phi i32 [ -1, %2 ], [ %21, %20 ]
ret i32 %23
}