#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 EOF;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void get_bool_param(char *p_file, char *p_name, bool *param, bool trace) {
  FILE *fp;
  char buff[255];
  char symb[3], val[6];
  if ((fp = fopen(p_file, "r")) == NULL) {
    printf("No such file\n");
    exit(1);
  }
  while (42) {
    int ret = fscanf(fp, "%s", buff);
    if (ret == 1) {
      if (buff[0] == '#') {
        fgets(buff, 255, fp);
      } else if (strcmp(buff, p_name) == 0) {
        if (fscanf(fp, "%s %s", symb, val) != 2) {
          printf("No match\n");
          fclose(fp);
          exit(1);
        } else if (strcmp(symb, ":=") != 0) {
          printf("No match\n");
          fclose(fp);
          exit(1);
        } else {
          if (strcmp(val, "true") == 0) {
            *param = true;
          }
          if (strcmp(val, "false") == 0) {
            *param = false;
          }
          if (trace) {
            printf("Read value %s = %s\n", p_name, val);
          }
          break;
        }
      }
    } else if (errno != 0) {
      perror("scanf:");
      fclose(fp);
      exit(1);
    } else if (ret == EOF) {
      printf("Couldn't find %s in %s.\n", p_name, p_file);
      break;
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<get_bool_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11d0 <get_bool_param+0x50>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11d5 <get_bool_param+0x55>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x140(%rbp)
cmpl   $0x1,-0x140(%rbp)
jne    134d <get_bool_param+0x1cd>
movsbl -0x130(%rbp),%eax
cmp    $0x23,%eax
jne    122b <get_bool_param+0xab>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
jmp    1348 <get_bool_param+0x1c8>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1343 <get_bool_param+0x1c3>
mov    -0x28(%rbp),%rdi
lea    -0x133(%rbp),%rdx
lea    -0x139(%rbp),%rcx
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
cmp    $0x2,%eax
je     128f <get_bool_param+0x10f>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    -0x133(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12cd <get_bool_param+0x14d>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    -0x139(%rbp),%rdi
lea    0xd48(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f4 <get_bool_param+0x174>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
lea    -0x139(%rbp),%rdi
lea    0xd26(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    131b <get_bool_param+0x19b>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x0,-0x1c(%rbp)
je     133e <get_bool_param+0x1be>
mov    -0x10(%rbp),%rsi
lea    -0x139(%rbp),%rdx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13bc <get_bool_param+0x23c>
jmp    1348 <get_bool_param+0x1c8>
jmp    13b7 <get_bool_param+0x237>
mov    0x2c84(%rip),%rax
cmpq   $0x0,(%rax)
je     137d <get_bool_param+0x1fd>
lea    0xcdd(%rip),%rdi
call   1090 <perror@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x140(%rbp),%eax
mov    0x2c5e(%rip),%rcx
cmp    (%rcx),%eax
jne    13ad <get_bool_param+0x22d>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13bc <get_bool_param+0x23c>
jmp    13b2 <get_bool_param+0x232>
jmp    13b7 <get_bool_param+0x237>
jmp    11d5 <get_bool_param+0x55>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bool_param>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %ecx,0xc(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,%r14
lea    0xe4c(%rip),%rsi
mov    %rdi,0x18(%rsp)
call   1090 <fopen@plt>
test   %rax,%rax
je     132a <get_bool_param+0x19a>
mov    %rax,%rbx
lea    0xe34(%rip),%rbp
lea    0x20(%rsp),%r15
mov    0x2dfb(%rip),%r12
mov    0x2e04(%rip),%r13
jmp    1200 <get_bool_param+0x70>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1230 <get_bool_param+0xa0>
cmpb   $0x23,0x20(%rsp)
je     11f0 <get_bool_param+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1200 <get_bool_param+0x70>
jmp    1255 <get_bool_param+0xc5>
xchg   %ax,%ax
cmpq   $0x0,(%r12)
jne    130c <get_bool_param+0x17c>
cmp    0x0(%r13),%eax
jne    1200 <get_bool_param+0x70>
lea    0xde9(%rip),%rdi
mov    %r14,%rsi
mov    0x18(%rsp),%rdx
jmp    12eb <get_bool_param+0x15b>
lea    0xda6(%rip),%rsi
lea    0x9(%rsp),%rdx
lea    0x3(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jne    1340 <get_bool_param+0x1b0>
lea    0xd88(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1340 <get_bool_param+0x1b0>
lea    0xd71(%rip),%rsi
lea    0x3(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12b4 <get_bool_param+0x124>
mov    0x10(%rsp),%rax
movl   $0x1,(%rax)
lea    0xd55(%rip),%rsi
lea    0x3(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12d5 <get_bool_param+0x145>
mov    0x10(%rsp),%rax
movl   $0x0,(%rax)
cmpl   $0x0,0xc(%rsp)
je     12f2 <get_bool_param+0x162>
lea    0xd33(%rip),%rdi
lea    0x3(%rsp),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd17(%rip),%rdi
call   10a0 <perror@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd22(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd03(%rip),%rdi
call   1030 <puts@plt>
jmp    1318 <get_bool_param+0x188>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"No such file\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"%s %s\00"
@.str.4 = [10 x i8] c"No match\0A\00"
@.str.5 = [3 x i8] c":=\00"
@.str.6 = [5 x i8] c"true\00"
@.str.7 = [6 x i8] c"false\00"
@.str.8 = [20 x i8] c"Read value %s = %s\0A\00"
@errno = global i64 0
@.str.9 = [7 x i8] c"scanf:\00"
@EOF = global i32 0
@.str.10 = [25 x i8] c"Couldn't find %s in %s.\0A\00"
define void @get_bool_param(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [255 x i8]
%11 = alloca [3 x i8]
%12 = alloca [6 x i8]
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %9
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %4
br label %21
21: ; preds = %20, %101
%22 = load i32*, i32** %9
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%24 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
store i32 %24, i32* %13
%25 = load i32, i32* %13
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %83
27: ; preds = %21
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 35
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%34 = load i32*, i32** %9
%35 = call i32 @fgets(i8* %33, i32 255, i32* %34)
br label %82
36: ; preds = %27
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%38 = load i8*, i8** %6
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %81
41: ; preds = %36
%42 = load i32*, i32** %9
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %12, i64 0, i64 0
%45 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %43, i8* %44)
%46 = icmp ne i32 %45, 2
br i1 %46, label %47, label %52
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32*, i32** %9
%50 = call i32 @fclose(i32* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %41
%53 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%58 = load i32*, i32** %9
%59 = call i32 @fclose(i32* %58)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %52
%62 = getelementptr inbounds [6 x i8], [6 x i8]* %12, i64 0, i64 0
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load i32*, i32** %7
store i32 1, i32* %66
br label %67
67: ; preds = %65, %61
%68 = getelementptr inbounds [6 x i8], [6 x i8]* %12, i64 0, i64 0
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = load i32*, i32** %7
store i32 0, i32* %72
br label %73
73: ; preds = %71, %67
%74 = load i32, i32* %8
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i8*, i8** %6
%78 = getelementptr inbounds [6 x i8], [6 x i8]* %12, i64 0, i64 0
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %77, i8* %78)
br label %80
80: ; preds = %76, %73
br label %102
81: ; preds = %36
br label %82
82: ; preds = %81, %32
br label %101
83: ; preds = %21
%84 = load i64, i64* @errno
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %83
%87 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%88 = load i32*, i32** %9
%89 = call i32 @fclose(i32* %88)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %83
%92 = load i32, i32* %13
%93 = load i32, i32* @EOF
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %99
95: ; preds = %91
%96 = load i8*, i8** %6
%97 = load i8*, i8** %5
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %96, i8* %97)
br label %102
99: ; preds = %91
br label %100
100: ; preds = %99
br label %101
101: ; preds = %100, %82
br label %21
102: ; preds = %95, %80
%103 = load i32*, i32** %9
%104 = call i32 @fclose(i32* %103)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"%s %s\00"
@.str.5 = [3 x i8] c":=\00"
@.str.6 = [5 x i8] c"true\00"
@.str.7 = [6 x i8] c"false\00"
@.str.8 = [20 x i8] c"Read value %s = %s\0A\00"
@errno = global i64 0
@.str.9 = [7 x i8] c"scanf:\00"
@EOF = global i32 0
@.str.10 = [25 x i8] c"Couldn't find %s in %s.\0A\00"
@str.11 = [9 x i8] c"No match\00"
@str.12 = [13 x i8] c"No such file\00"
define void @get_bool_param(i8* %0, i8* %1, i32* nocapture writeonly %2, i32 %3) {
%5 = alloca [255 x i8]
%6 = alloca [3 x i8]
%7 = alloca [6 x i8]
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%11 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %4, %27
%17 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %54
19: ; preds = %16
%20 = load i8, i8* %8
%21 = icmp eq i8 %20, 35
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @fgets(i8* %8, i32 255, i32* %11)
br label %27
24: ; preds = %19
%25 = call i64 @strcmp(i8* %8, i8* %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24, %22, %61
br label %16
28: ; preds = %24
%29 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %10)
%30 = icmp eq i32 %29, 2
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%33 = call i32 @fclose(i32* %11)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%40 = call i32 @fclose(i32* %11)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %35
%43 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
store i32 1, i32* %2
br label %46
46: ; preds = %45, %42
%47 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %2
br label %50
50: ; preds = %49, %46
%51 = icmp eq i32 %3, 0
br i1 %51, label %66, label %52
52: ; preds = %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %10)
br label %66
54: ; preds = %16
%55 = load i64, i64* @errno
%56 = icmp eq i64 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %54
%58 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%59 = call i32 @fclose(i32* %11)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %54
%62 = load i32, i32* @EOF
%63 = icmp eq i32 %17, %62
br i1 %63, label %64, label %27
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %1, i8* %0)
br label %66
66: ; preds = %64, %52, %50
%67 = call i32 @fclose(i32* %11)
ret void
}