#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_real_param(char *p_file, char *p_name, float *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 %f", 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 = %f\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_real_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_real_param+0x50>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11d5 <get_real_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    1301 <get_real_param+0x181>
movsbl -0x130(%rbp),%eax
cmp    $0x23,%eax
jne    122b <get_real_param+0xab>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
jmp    12fc <get_real_param+0x17c>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f7 <get_real_param+0x177>
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_real_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_real_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     12f2 <get_real_param+0x172>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd3b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1370 <get_real_param+0x1f0>
jmp    12fc <get_real_param+0x17c>
jmp    136b <get_real_param+0x1eb>
mov    0x2cd0(%rip),%rax
cmpq   $0x0,(%rax)
je     1331 <get_real_param+0x1b1>
lea    0xd21(%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    0x2caa(%rip),%rcx
cmp    (%rcx),%eax
jne    1361 <get_real_param+0x1e1>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1370 <get_real_param+0x1f0>
jmp    1366 <get_real_param+0x1e6>
jmp    136b <get_real_param+0x1eb>
jmp    11d5 <get_real_param+0x55>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_real_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     12ee <get_real_param+0x15e>
mov    %rax,%rbx
lea    0xe31(%rip),%rbp
lea    0x20(%rsp),%r12
mov    0x2dfb(%rip),%r15
mov    0x2e04(%rip),%r13
jmp    1200 <get_real_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_real_param+0xa0>
cmpb   $0x23,0x20(%rsp)
je     11f0 <get_real_param+0x60>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1200 <get_real_param+0x70>
jmp    1258 <get_real_param+0xc8>
xchg   %ax,%ax
cmpq   $0x0,(%r15)
jne    12d0 <get_real_param+0x140>
cmp    0x0(%r13),%eax
jne    1200 <get_real_param+0x70>
lea    0xde2(%rip),%rdi
mov    %r14,%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12b6 <get_real_param+0x126>
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    1304 <get_real_param+0x174>
lea    0xd85(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1304 <get_real_param+0x174>
cmpl   $0x0,0xc(%rsp)
je     12b6 <get_real_param+0x126>
movss  0x0(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd62(%rip),%rdi
mov    %r14,%rsi
mov    $0x1,%al
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    0xd4b(%rip),%rdi
call   10a0 <perror@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd56(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd37(%rip),%rdi
call   1030 <puts@plt>
jmp    12dc <get_real_param+0x14c>

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 %f\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 = %f\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_real_param(i8* %0, i8* %1, float* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca float*
%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 float* %2, float** %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, %90
%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 %72
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 %71
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 %70
40: ; preds = %35
%41 = load i32*, i32** %9
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%43 = load float*, float** %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, float* %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 %69
63: ; preds = %60
%64 = load i8*, i8** %6
%65 = load float*, float** %7
%66 = load float, float* %65
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %64, double %67)
br label %69
69: ; preds = %63, %60
br label %91
70: ; preds = %35
br label %71
71: ; preds = %70, %31
br label %90
72: ; preds = %20
%73 = load i64, i64* @errno
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %72
%76 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%77 = load i32*, i32** %9
%78 = call i32 @fclose(i32* %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %72
%81 = load i32, i32* %12
%82 = load i32, i32* @EOF
%83 = icmp eq i32 %81, %82
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = load i8*, i8** %6
%86 = load i8*, i8** %5
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %85, i8* %86)
br label %91
88: ; preds = %80
br label %89
89: ; preds = %88
br label %90
90: ; preds = %89, %71
br label %20
91: ; preds = %84, %69
%92 = load i32*, i32** %9
%93 = call i32 @fclose(i32* %92)
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 %f\00"
@.str.5 = [3 x i8] c":=\00"
@.str.6 = [20 x i8] c"Read value %s = %f\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_real_param(i8* %0, i8* %1, float* %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 %46
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, %53
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, float* %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 %58, label %42
42: ; preds = %40
%43 = load float, float* %2
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %1, double %44)
br label %58
46: ; preds = %14
%47 = load i64, i64* @errno
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 @fclose(i32* %9)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %46
%54 = load i32, i32* @EOF
%55 = icmp eq i32 %15, %54
br i1 %55, label %56, label %25
56: ; preds = %53
%57 = 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 %58
58: ; preds = %56, %42, %40
%59 = call i32 @fclose(i32* %9)
ret void
}