#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_int_param(char *p_file, char *p_name, int *param, bool trace) {
  FILE *fp;
  char buff[255];
  char symb[3];
  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 %d", symb, param) != 2) {
          printf("No match\n");
          fclose(fp);
          exit(1);
        } else if (strcmp(symb, ":=") != 0) {
          printf("No match\n");
          fclose(fp);
          exit(1);
        } else {
          if (trace) {
            printf("Read value %s = %d\n", p_name, *param);
          }
          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_int_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_int_param+0x50>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11d5 <get_int_param+0x55>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x138(%rbp)
cmpl   $0x1,-0x138(%rbp)
jne    12fb <get_int_param+0x17b>
movsbl -0x130(%rbp),%eax
cmp    $0x23,%eax
jne    122b <get_int_param+0xab>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
jmp    12f6 <get_int_param+0x176>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f1 <get_int_param+0x171>
mov    -0x28(%rbp),%rdi
lea    -0x133(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
cmp    $0x2,%eax
je     128c <get_int_param+0x10c>
lea    0xda7(%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    0xd89(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12ca <get_int_param+0x14a>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
je     12ec <get_int_param+0x16c>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    136a <get_int_param+0x1ea>
jmp    12f6 <get_int_param+0x176>
jmp    1365 <get_int_param+0x1e5>
mov    0x2cd6(%rip),%rax
cmpq   $0x0,(%rax)
je     132b <get_int_param+0x1ab>
lea    0xd27(%rip),%rdi
call   1090 <perror@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x138(%rbp),%eax
mov    0x2cb0(%rip),%rcx
cmp    (%rcx),%eax
jne    135b <get_int_param+0x1db>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    136a <get_int_param+0x1ea>
jmp    1360 <get_int_param+0x1e0>
jmp    1365 <get_int_param+0x1e5>
jmp    11d5 <get_int_param+0x55>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int_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     12e4 <get_int_param+0x154>
mov    %rax,%rbx
lea    0xe31(%rip),%rbp
lea    0x20(%rsp),%r12
mov    0x2dfb(%rip),%r15
mov    0x2e04(%rip),%r13
jmp    1200 <get_int_param+0x70>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1230 <get_int_param+0xa0>
cmpb   $0x23,0x20(%rsp)
je     11f0 <get_int_param+0x60>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1200 <get_int_param+0x70>
jmp    1258 <get_int_param+0xc8>
xchg   %ax,%ax
cmpq   $0x0,(%r15)
jne    12c6 <get_int_param+0x136>
cmp    0x0(%r13),%eax
jne    1200 <get_int_param+0x70>
lea    0xde2(%rip),%rdi
mov    %r14,%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ac <get_int_param+0x11c>
lea    0xda6(%rip),%rsi
lea    0x9(%rsp),%rdx
mov    %rbx,%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rcx
xor    %eax,%eax
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jne    12fa <get_int_param+0x16a>
lea    0xd89(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12fa <get_int_param+0x16a>
cmpl   $0x0,0xc(%rsp)
je     12ac <get_int_param+0x11c>
mov    0x0(%rbp),%edx
lea    0xd6c(%rip),%rdi
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    0xd55(%rip),%rdi
call   10a0 <perror@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd60(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd41(%rip),%rdi
call   1030 <puts@plt>
jmp    12d2 <get_int_param+0x142>

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