#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float atof(char *);
int atoi(char *);
int /*<<< orphan*/ choppy(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int /*<<< orphan*/);
char *strtok(char *, char *);
int checkSumstatPar(char name[], int *par1, float *par2, char *type,
                    const int npar) {
  FILE *parfile;
  char buf[100];
  char *buf_split;
  int ok = 0;
  int i;
  parfile = fopen("./sumstat.par", "r");
  if (parfile == NULL) {
    printf("ERROR: opening input file!\n");
    perror("Impossible to open sumstat.par\n");
    return 0;
  }
  while (fgets(buf, sizeof(buf), parfile) != NULL) {
    choppy(buf);
    if ((buf[0] == '/') && (buf[1] = '/')) {
      continue;
    }
    buf_split = strtok(buf, "#");
    i = 0;
    while (buf_split != NULL) {
      i++;
      if (strncmp(buf_split, name, strlen(name)) == 0) {
        ok = 1;
      } else {
        if ((ok == 1) && (npar == 2)) {
          if (i == 2) {
            *par1 = atoi(buf_split);
          }
          if (i == 3) {
            strncpy(type, buf_split, strlen(type));
            return 0;
          }
        } else if ((ok == 1) && (npar == 3)) {
          if (i == 2) {
            *par1 = atoi(buf_split);
          }
          if (i == 3) {
            *par2 = atof(buf_split);
          }
          if (i == 4) {
            strncpy(type, buf_split, strlen(type));
            return 0;
          }
        }
      }
      buf_split = strtok(NULL, "#");
    }
  }
  fclose(parfile);
}


x86 assembly (clang, -O0):
<checkSumstatPar>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0xac(%rbp)
lea    0xe10(%rip),%rdi
lea    0xe15(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    122f <checkSumstatPar+0x6f>
lea    0xdfc(%rip),%rdi
call   1080 <printf@plt>
lea    0xe0c(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    148a <checkSumstatPar+0x2ca>
jmp    1234 <checkSumstatPar+0x74>
lea    -0xa0(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x64,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1481 <checkSumstatPar+0x2c1>
lea    -0xa0(%rbp),%rdi
call   1090 <choppy@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x2f,%eax
jne    128a <checkSumstatPar+0xca>
movb   $0x2f,-0x9f(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1285 <checkSumstatPar+0xc5>
jmp    128a <checkSumstatPar+0xca>
jmp    1234 <checkSumstatPar+0x74>
lea    -0xa0(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0xb0(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     147c <checkSumstatPar+0x2bc>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb8(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    131b <checkSumstatPar+0x15b>
movl   $0x1,-0xac(%rbp)
jmp    1460 <checkSumstatPar+0x2a0>
cmpl   $0x1,-0xac(%rbp)
jne    13a8 <checkSumstatPar+0x1e8>
cmpl   $0x2,-0x2c(%rbp)
jne    13a8 <checkSumstatPar+0x1e8>
cmpl   $0x2,-0xb0(%rbp)
jne    1353 <checkSumstatPar+0x193>
mov    -0xa8(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x3,-0xb0(%rbp)
jne    13a3 <checkSumstatPar+0x1e3>
mov    -0x28(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd0(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    148a <checkSumstatPar+0x2ca>
jmp    145b <checkSumstatPar+0x29b>
cmpl   $0x1,-0xac(%rbp)
jne    1456 <checkSumstatPar+0x296>
cmpl   $0x3,-0x2c(%rbp)
jne    1456 <checkSumstatPar+0x296>
cmpl   $0x2,-0xb0(%rbp)
jne    13e0 <checkSumstatPar+0x220>
mov    -0xa8(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x3,-0xb0(%rbp)
jne    1401 <checkSumstatPar+0x241>
mov    -0xa8(%rbp),%rdi
call   1050 <atof@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
cmpl   $0x4,-0xb0(%rbp)
jne    1451 <checkSumstatPar+0x291>
mov    -0x28(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    148a <checkSumstatPar+0x2ca>
jmp    1456 <checkSumstatPar+0x296>
jmp    145b <checkSumstatPar+0x29b>
jmp    1460 <checkSumstatPar+0x2a0>
xor    %eax,%eax
mov    %eax,%edi
lea    0xbdf(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xa8(%rbp)
jmp    12ae <checkSumstatPar+0xee>
jmp    1234 <checkSumstatPar+0x74>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkSumstatPar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8d,0x4(%rsp)
mov    %rcx,%r14
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
lea    0xe13(%rip),%rdi
lea    0xe18(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1351 <checkSumstatPar+0x191>
mov    %rax,%rbp
mov    %r14,0x8(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1335 <checkSumstatPar+0x175>
xor    %r15d,%r15d
lea    0x20(%rsp),%r14
nopl   (%rax)
mov    %r14,%rdi
call   1090 <choppy@plt>
cmpb   $0x2f,0x20(%rsp)
jne    125e <checkSumstatPar+0x9e>
movb   $0x2f,0x21(%rsp)
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbp,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
jne    1230 <checkSumstatPar+0x70>
jmp    1335 <checkSumstatPar+0x175>
mov    %r14,%rdi
lea    0xdc6(%rip),%rsi
call   10d0 <strtok@plt>
test   %rax,%rax
je     1244 <checkSumstatPar+0x84>
mov    %rax,%r12
xor    %r13d,%r13d
jmp    12af <checkSumstatPar+0xef>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10e0 <atoi@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
mov    $0x1,%r15d
xor    %edi,%edi
lea    0xd90(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,%r12
add    $0x1,%r13d
test   %rax,%rax
je     1244 <checkSumstatPar+0x84>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     128f <checkSumstatPar+0xcf>
cmpl   $0x2,0x4(%rsp)
jne    12f0 <checkSumstatPar+0x130>
cmp    $0x1,%r15d
jne    12f0 <checkSumstatPar+0x130>
cmp    $0x1,%r13d
je     1280 <checkSumstatPar+0xc0>
mov    $0x1,%r15d
cmp    $0x2,%r13d
jne    1295 <checkSumstatPar+0xd5>
jmp    136b <checkSumstatPar+0x1ab>
nopl   (%rax)
cmpl   $0x3,0x4(%rsp)
jne    1295 <checkSumstatPar+0xd5>
cmp    $0x1,%r15d
jne    1295 <checkSumstatPar+0xd5>
cmp    $0x1,%r13d
je     1280 <checkSumstatPar+0xc0>
cmp    $0x2,%r13d
je     131f <checkSumstatPar+0x15f>
mov    $0x1,%r15d
cmp    $0x3,%r13d
jne    1295 <checkSumstatPar+0xd5>
jmp    136b <checkSumstatPar+0x1ab>
mov    %r12,%rdi
call   1060 <atof@plt>
mov    0x18(%rsp),%rax
movss  %xmm0,(%rax)
jmp    128f <checkSumstatPar+0xcf>
mov    %rbp,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd8(%rip),%rdi
call   1050 <puts@plt>
lea    0xcaa(%rip),%rdi
call   10c0 <perror@plt>
jmp    133d <checkSumstatPar+0x17d>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
jmp    133d <checkSumstatPar+0x17d>

LLVM IR (-O0):
@.str = [14 x i8] c"./sumstat.par\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"ERROR: opening input file!\0A\00"
@.str.3 = [32 x i8] c"Impossible to open sumstat.par\0A\00"
@.str.4 = [2 x i8] c"#\00"
define i32 @checkSumstatPar(i8* %0, i32* %1, float* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca float*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca [100 x i8]
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %7
store i32* %1, i32** %8
store float* %2, float** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 0, i32* %15
%17 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %12
%18 = load i32*, i32** %12
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %116
23: ; preds = %5
br label %24
24: ; preds = %112, %38, %23
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%26 = load i32*, i32** %12
%27 = call i32* @fgets(i8* %25, i32 100, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %113
29: ; preds = %24
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%31 = call i32 @choppy(i8* %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 1
store i8 47, i8* %37
br i1 true, label %38, label %39
38: ; preds = %36
br label %24
39: ; preds = %36, %29
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%41 = call i8* @strtok(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %41, i8** %14
store i32 0, i32* %16
br label %42
42: ; preds = %110, %39
%43 = load i8*, i8** %14
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %112
45: ; preds = %42
%46 = load i32, i32* %16
%47 = add nsw i32 %46, 1
store i32 %47, i32* %16
%48 = load i8*, i8** %14
%49 = load i8*, i8** %7
%50 = load i8*, i8** %7
%51 = call i32 @strlen(i8* %50)
%52 = call i64 @strncmp(i8* %48, i8* %49, i32 %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %45
store i32 1, i32* %15
br label %110
55: ; preds = %45
%56 = load i32, i32* %15
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %78
58: ; preds = %55
%59 = load i32, i32* %11
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %78
61: ; preds = %58
%62 = load i32, i32* %16
%63 = icmp eq i32 %62, 2
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load i8*, i8** %14
%66 = call i32 @atoi(i8* %65)
%67 = load i32*, i32** %8
store i32 %66, i32* %67
br label %68
68: ; preds = %64, %61
%69 = load i32, i32* %16
%70 = icmp eq i32 %69, 3
br i1 %70, label %71, label %77
71: ; preds = %68
%72 = load i8*, i8** %10
%73 = load i8*, i8** %14
%74 = load i8*, i8** %10
%75 = call i32 @strlen(i8* %74)
%76 = call i32 @strncpy(i8* %72, i8* %73, i32 %75)
store i32 0, i32* %6
br label %116
77: ; preds = %68
br label %109
78: ; preds = %58, %55
%79 = load i32, i32* %15
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %108
81: ; preds = %78
%82 = load i32, i32* %11
%83 = icmp eq i32 %82, 3
br i1 %83, label %84, label %108
84: ; preds = %81
%85 = load i32, i32* %16
%86 = icmp eq i32 %85, 2
br i1 %86, label %87, label %91
87: ; preds = %84
%88 = load i8*, i8** %14
%89 = call i32 @atoi(i8* %88)
%90 = load i32*, i32** %8
store i32 %89, i32* %90
br label %91
91: ; preds = %87, %84
%92 = load i32, i32* %16
%93 = icmp eq i32 %92, 3
br i1 %93, label %94, label %98
94: ; preds = %91
%95 = load i8*, i8** %14
%96 = call float @atof(i8* %95)
%97 = load float*, float** %9
store float %96, float* %97
br label %98
98: ; preds = %94, %91
%99 = load i32, i32* %16
%100 = icmp eq i32 %99, 4
br i1 %100, label %101, label %107
101: ; preds = %98
%102 = load i8*, i8** %10
%103 = load i8*, i8** %14
%104 = load i8*, i8** %10
%105 = call i32 @strlen(i8* %104)
%106 = call i32 @strncpy(i8* %102, i8* %103, i32 %105)
store i32 0, i32* %6
br label %116
107: ; preds = %98
br label %108
108: ; preds = %107, %81, %78
br label %109
109: ; preds = %108, %77
br label %110
110: ; preds = %109, %54
%111 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %111, i8** %14
br label %42
112: ; preds = %42
br label %24
113: ; preds = %24
%114 = load i32*, i32** %12
%115 = call i32 @fclose(i32* %114)
br label %116
116: ; preds = %113, %101, %71, %20
%117 = load i32, i32* %6
ret i32 %117
}

LLVM IR (-O2):
@.str = [14 x i8] c"./sumstat.par\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [32 x i8] c"Impossible to open sumstat.par\0A\00"
@.str.4 = [2 x i8] c"#\00"
@str = [27 x i8] c"ERROR: opening input file!\00"
define i32 @checkSumstatPar(i8* %0, i32* nocapture writeonly %1, float* nocapture writeonly %2, i8* %3, i32 %4) {
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = call i32* @fgets(i8* %7, i32 100, i32* %8)
%12 = icmp eq i32* %11, null
br i1 %12, label %67, label %13
13: ; preds = %10
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 1
%15 = icmp eq i32 %4, 2
%16 = icmp eq i32 %4, 3
br label %24
17: ; preds = %5
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %69
20: ; preds = %63, %33
%21 = phi i32 [ %25, %33 ], [ %64, %63 ]
%22 = call i32* @fgets(i8* %7, i32 100, i32* %8)
%23 = icmp eq i32* %22, null
br i1 %23, label %67, label %24
24: ; preds = %13, %20
%25 = phi i32 [ 0, %13 ], [ %21, %20 ]
br label %26
26: ; preds = %24, %30
%27 = call i32 @choppy(i8* %7)
%28 = load i8, i8* %7
%29 = icmp eq i8 %28, 47
br i1 %29, label %30, label %33
30: ; preds = %26
store i8 47, i8* %14
%31 = call i32* @fgets(i8* %7, i32 100, i32* %8)
%32 = icmp eq i32* %31, null
br i1 %32, label %67, label %26
33: ; preds = %26
%34 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %20, label %36
36: ; preds = %33, %63
%37 = phi i32 [ %40, %63 ], [ 0, %33 ]
%38 = phi i32 [ %64, %63 ], [ %25, %33 ]
%39 = phi i8* [ %65, %63 ], [ %34, %33 ]
%40 = add nuw nsw i32 %37, 1
%41 = call i32 @strlen(i8* %0)
%42 = call i64 @strncmp(i8* %39, i8* %0, i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %63, label %44
44: ; preds = %36
%45 = icmp eq i32 %38, 1
%46 = and i1 %15, %45
br i1 %46, label %47, label %53
47: ; preds = %44
switch i32 %37, label %63 [
i32 1, label %48
i32 2, label %50
]
48: ; preds = %47
%49 = call i32 @atoi(i8* %39)
store i32 %49, i32* %1
br label %63
50: ; preds = %47
%51 = call i32 @strlen(i8* %3)
%52 = call i32 @strncpy(i8* %3, i8* %39, i32 %51)
br label %69
53: ; preds = %44
%54 = and i1 %16, %45
br i1 %54, label %55, label %63
55: ; preds = %53
switch i32 %37, label %63 [
i32 1, label %56
i32 2, label %58
i32 3, label %60
]
56: ; preds = %55
%57 = call i32 @atoi(i8* %39)
store i32 %57, i32* %1
br label %63
58: ; preds = %55
%59 = call float @atof(i8* %39)
store float %59, float* %2
br label %63
60: ; preds = %55
%61 = call i32 @strlen(i8* %3)
%62 = call i32 @strncpy(i8* %3, i8* %39, i32 %61)
br label %69
63: ; preds = %58, %56, %48, %55, %47, %36, %53
%64 = phi i32 [ 1, %48 ], [ 1, %58 ], [ %38, %53 ], [ 1, %36 ], [ 1, %47 ], [ 1, %56 ], [ 1, %55 ]
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%66 = icmp eq i8* %65, null
br i1 %66, label %20, label %36
67: ; preds = %20, %30, %10
%68 = call i32 @fclose(i32* %8)
br label %69
69: ; preds = %67, %60, %50, %17
ret i32 0
}