#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*/ ShowErrorMessage(char *, ...);
int /*<<< orphan*/ ShowWarningMessage(char *, char *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int strspn(char *, char *);
void rdsvar(FILE *infile, char varname[], void *address, int parmtype, int crit,
            int *present) {
  int foundit, namelen, check1, check2, gotit;
  char buffer[1000] = "\0";
  namelen = strlen(varname);
  foundit = 0;
  rewind(infile);
  fgets(buffer, 999, infile);
  do {
    check1 = 0;
    check2 = 0;
    while (buffer[check1++] == varname[check2++])
      ;
    if (check1 > (namelen)) {
      foundit++;
      switch (parmtype) {
      case 3:
        gotit = sscanf(&buffer[check1], " %lf", (double *)address);
        break;
      case 4:
        gotit = sscanf(&buffer[check1], " %lf", (double *)address);
        break;
      case 1:
        gotit = sscanf(&buffer[check1], " %d", (int *)address);
        break;
      case 2:
        gotit = sscanf(&buffer[check1], " %ld", (long int *)address);
        break;
      case 5:
        check1 += strspn(&buffer[check1], " ,");
        for (check2 = strlen(&buffer[check1]) - 1;
             isspace(buffer[check1 + check2]) != 0; check2--)
          ;
        if (strlen(&buffer[check1]) < 2)
          buffer[check1] = '\0';
        buffer[check1 + check2 + 1] = '\0';
        strcpy((char *)address, &buffer[check1]);
        gotit = 1;
        break;
      default:
        ShowErrorMessage("Invalid parameter type request %d: \n", parmtype);
      }
      if (!gotit) {
        ShowWarningMessage(
            "WARNING: found bad value for variable %s. Value ignored\n",
            varname);
        foundit--;
      }
    }
    fgets(buffer, 999, infile);
  } while (!(feof(infile)));
  if (!foundit) {
    if (crit)
      ShowErrorMessage("Unable to find %s in input file.\n", varname);
  }
  if (foundit > 1) {
    ShowWarningMessage("WARNING variable: %s appears more than once in the "
                       "input file. Final value taken\n",
                       varname);
  }
  *present = foundit;
  return;
}


x86 assembly (clang, -O0):
<rdsvar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e7,%esi
call   10a0 <fgets@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x34(%rbp)
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
mov    -0x10(%rbp),%rcx
mov    -0x38(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x38(%rbp)
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    125c <rdsvar+0xac>
jmp    1224 <rdsvar+0x74>
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    1441 <rdsvar+0x291>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x438(%rbp)
sub    $0x4,%eax
ja     1408 <rdsvar+0x258>
mov    -0x438(%rbp),%rax
lea    0xd69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
jmp    1419 <rdsvar+0x269>
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xd33(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
jmp    1419 <rdsvar+0x269>
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
jmp    1419 <rdsvar+0x269>
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
jmp    1419 <rdsvar+0x269>
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
lea    0xccd(%rip),%rsi
call   1080 <strspn@plt>
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
cltq
movsbl -0x430(%rbp,%rax,1),%edi
ff
call   1090 <isspace@plt>
cmp    $0x0,%eax
je     13aa <rdsvar+0x1fa>
jmp    139c <rdsvar+0x1ec>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    1379 <rdsvar+0x1c9>
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rdi
add    %rax,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jge    13d2 <rdsvar+0x222>
movslq -0x34(%rbp),%rax
movb   $0x0,-0x430(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
movslq -0x34(%rbp),%rax
lea    -0x430(%rbp),%rsi
add    %rax,%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x3c(%rbp)
jmp    1419 <rdsvar+0x269>
mov    -0x1c(%rbp),%esi
lea    0xc13(%rip),%rdi
mov    $0x0,%al
call   10d0 <ShowErrorMessage@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    143c <rdsvar+0x28c>
mov    -0x10(%rbp),%rsi
lea    0xc1c(%rip),%rdi
call   1030 <ShowWarningMessage@plt>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1441 <rdsvar+0x291>
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e7,%esi
call   10a0 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1216 <rdsvar+0x66>
cmpl   $0x0,-0x2c(%rbp)
jne    149a <rdsvar+0x2ea>
cmpl   $0x0,-0x20(%rbp)
je     1495 <rdsvar+0x2e5>
mov    -0x10(%rbp),%rsi
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   10d0 <ShowErrorMessage@plt>
jmp    149a <rdsvar+0x2ea>
cmpl   $0x1,-0x2c(%rbp)
jle    14b4 <rdsvar+0x304>
mov    -0x10(%rbp),%rsi
lea    0xbf6(%rip),%rdi
call   1030 <ShowWarningMessage@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdsvar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r9,0x20(%rsp)
mov    %r8d,0x10(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x30(%rsp),%rbp
mov    $0x3e8,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    %rbp,%rdi
mov    $0x3e7,%esi
mov    %rbx,0x28(%rsp)
mov    %rbx,%rdx
call   10a0 <fgets@plt>
xor    %ebx,%ebx
jmp    1249 <rdsvar+0x99>
nopl   0x0(%rax)
mov    %ebp,%ebx
lea    0x30(%rsp),%rdi
mov    $0x3e7,%esi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdx
call   10a0 <fgets@plt>
mov    %rbp,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    13c9 <rdsvar+0x219>
mov    %ebx,%ebp
mov    $0x2,%ecx
mov    $0x1,%edx
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rax
mov    %ecx,%r15d
mov    %edx,%r14d
add    $0x1,%r12
movzbl 0x30(%rsp,%rax,1),%ebx
lea    0x1(%r15),%ecx
lea    0x1(%r14),%edx
cmp    0x0(%r13,%rax,1),%bl
je     1260 <rdsvar+0xb0>
cmp    %eax,0x14(%rsp)
jg     1220 <rdsvar+0x70>
lea    0x1(%rbp),%ebx
mov    0x18(%rsp),%rax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     12bb <rdsvar+0x10b>
lea    0xd62(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r12d,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
lea    0xd5b(%rip),%rsi
jmp    12fa <rdsvar+0x14a>
lea    0xd63(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   10d0 <ShowErrorMessage@plt>
mov    0x4(%rsp),%eax
jmp    1306 <rdsvar+0x156>
mov    %r12d,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
lea    0xd33(%rip),%rsi
jmp    12fa <rdsvar+0x14a>
mov    %r12d,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
lea    0xd23(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    1222 <rdsvar+0x72>
lea    0xd31(%rip),%rdi
mov    %r13,%rsi
call   1030 <ShowWarningMessage@plt>
movl   $0x0,0x4(%rsp)
jmp    1220 <rdsvar+0x70>
mov    %r12d,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
lea    0xce2(%rip),%rsi
call   1080 <strspn@plt>
mov    %eax,%ebp
add    %eax,%r12d
movslq %r12d,%rax
lea    (%rsp,%rax,1),%r12
add    $0x30,%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
add    %eax,%r15d
add    %ebp,%r15d
movslq %ebp,%rcx
add    %rax,%rcx
lea    0x2f(%rsp),%rax
add    %rax,%rcx
movslq %r14d,%rbp
add    %rcx,%rbp
nopl   0x0(%rax)
movsbl 0x0(%rbp),%edi
call   1090 <isspace@plt>
add    $0xffffffff,%r15d
add    $0xffffffffffffffff,%rbp
test   %eax,%eax
jne    1380 <rdsvar+0x1d0>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jg     13a7 <rdsvar+0x1f7>
movb   $0x0,(%r12)
movslq %r15d,%rax
movb   $0x0,0x30(%rsp,%rax,1)
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
movl   $0x1,0x4(%rsp)
jmp    1222 <rdsvar+0x72>
cmpl   $0x0,0x10(%rsp)
je     13e7 <rdsvar+0x237>
test   %ebx,%ebx
jne    13e7 <rdsvar+0x237>
lea    0xca8(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10d0 <ShowErrorMessage@plt>
jmp    13fb <rdsvar+0x24b>
cmp    $0x2,%ebx
jl     13fb <rdsvar+0x24b>
lea    0xcb2(%rip),%rdi
mov    %r13,%rsi
call   1030 <ShowWarningMessage@plt>
mov    0x20(%rsp),%rax
mov    %ebx,(%rax)
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" %lf\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [5 x i8] c" %ld\00"
@.str.3 = [3 x i8] c" ,\00"
@.str.4 = [37 x i8] c"Invalid parameter type request %d: \0A\00"
@.str.5 = [57 x i8] c"WARNING: found bad value for variable %s. Value ignored\0A\00"
@.str.6 = [34 x i8] c"Unable to find %s in input file.\0A\00"
@.str.7 = [82 x i8] c"WARNING variable: %s appears more than once in the input file. Final value taken\0A\00"
define void @rdsvar(i32* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32* %5) {
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [1000 x i8]
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32* %5, i32** %12
%19 = bitcast [1000 x i8]* %18 to i8*
%20 = load i8*, i8** %8
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %14
store i32 0, i32* %13
%22 = load i32*, i32** %7
%23 = call i32 @rewind(i32* %22)
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%25 = load i32*, i32** %7
%26 = call i32 @fgets(i8* %24, i32 999, i32* %25)
br label %27
27: ; preds = %143, %6
store i32 0, i32* %15
store i32 0, i32* %16
br label %28
28: ; preds = %43, %27
%29 = load i32, i32* %15
%30 = add nsw i32 %29, 1
store i32 %30, i32* %15
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i8*, i8** %8
%36 = load i32, i32* %16
%37 = add nsw i32 %36, 1
store i32 %37, i32* %16
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %34, %41
br i1 %42, label %43, label %44
43: ; preds = %28
br label %28
44: ; preds = %28
%45 = load i32, i32* %15
%46 = load i32, i32* %14
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %139
48: ; preds = %44
%49 = load i32, i32* %13
%50 = add nsw i32 %49, 1
store i32 %50, i32* %13
%51 = load i32, i32* %10
switch i32 %51, label %127 [
i32 3, label %52
i32 4, label %59
i32 1, label %66
i32 2, label %73
i32 5, label %80
]
52: ; preds = %48
%53 = load i32, i32* %15
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %54
%56 = load i8*, i8** %9
%57 = bitcast i8* %56 to double*
%58 = call i32 (i8*, i8*, ...) @sscanf(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %57)
store i32 %58, i32* %17
br label %130
59: ; preds = %48
%60 = load i32, i32* %15
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %61
%63 = load i8*, i8** %9
%64 = bitcast i8* %63 to double*
%65 = call i32 (i8*, i8*, ...) @sscanf(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %64)
store i32 %65, i32* %17
br label %130
66: ; preds = %48
%67 = load i32, i32* %15
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %68
%70 = load i8*, i8** %9
%71 = bitcast i8* %70 to i32*
%72 = call i32 (i8*, i8*, ...) @sscanf(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %71)
store i32 %72, i32* %17
br label %130
73: ; preds = %48
%74 = load i32, i32* %15
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %75
%77 = load i8*, i8** %9
%78 = bitcast i8* %77 to i64*
%79 = call i32 (i8*, i8*, ...) @sscanf(i8* %76, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %78)
store i32 %79, i32* %17
br label %130
80: ; preds = %48
%81 = load i32, i32* %15
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %82
%84 = call i32 @strspn(i8* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%85 = load i32, i32* %15
%86 = add nsw i32 %85, %84
store i32 %86, i32* %15
%87 = load i32, i32* %15
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %88
%90 = call i32 @strlen(i8* %89)
%91 = sub nsw i32 %90, 1
store i32 %91, i32* %16
br label %92
92: ; preds = %102, %80
%93 = load i32, i32* %15
%94 = load i32, i32* %16
%95 = add nsw i32 %93, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = call i32 @isspace(i8 signext %98)
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %92
br label %102
102: ; preds = %101
%103 = load i32, i32* %16
%104 = add nsw i32 %103, -1
store i32 %104, i32* %16
br label %92
105: ; preds = %92
%106 = load i32, i32* %15
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %107
%109 = call i32 @strlen(i8* %108)
%110 = icmp slt i32 %109, 2
br i1 %110, label %111, label %115
111: ; preds = %105
%112 = load i32, i32* %15
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %113
store i8 0, i8* %114
br label %115
115: ; preds = %111, %105
%116 = load i32, i32* %15
%117 = load i32, i32* %16
%118 = add nsw i32 %116, %117
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %120
store i8 0, i8* %121
%122 = load i8*, i8** %9
%123 = load i32, i32* %15
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 %124
%126 = call i32 @strcpy(i8* %122, i8* %125)
store i32 1, i32* %17
br label %130
127: ; preds = %48
%128 = load i32, i32* %10
%129 = call i32 (i8*, ...) @ShowErrorMessage(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %127, %115, %73, %66, %59, %52
%131 = load i32, i32* %17
%132 = icmp ne i32 %131, 0
br i1 %132, label %138, label %133
133: ; preds = %130
%134 = load i8*, i8** %8
%135 = call i32 @ShowWarningMessage(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* %134)
%136 = load i32, i32* %13
%137 = add nsw i32 %136, -1
store i32 %137, i32* %13
br label %138
138: ; preds = %133, %130
br label %139
139: ; preds = %138, %44
%140 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%141 = load i32*, i32** %7
%142 = call i32 @fgets(i8* %140, i32 999, i32* %141)
br label %143
143: ; preds = %139
%144 = load i32*, i32** %7
%145 = call i32 @feof(i32* %144)
%146 = icmp ne i32 %145, 0
%147 = xor i1 %146, true
br i1 %147, label %27, label %148
148: ; preds = %143
%149 = load i32, i32* %13
%150 = icmp ne i32 %149, 0
br i1 %150, label %158, label %151
151: ; preds = %148
%152 = load i32, i32* %11
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %157
154: ; preds = %151
%155 = load i8*, i8** %8
%156 = call i32 (i8*, ...) @ShowErrorMessage(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %155)
br label %157
157: ; preds = %154, %151
br label %158
158: ; preds = %157, %148
%159 = load i32, i32* %13
%160 = icmp sgt i32 %159, 1
br i1 %160, label %161, label %164
161: ; preds = %158
%162 = load i8*, i8** %8
%163 = call i32 @ShowWarningMessage(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.7, i64 0, i64 0), i8* %162)
br label %164
164: ; preds = %161, %158
%165 = load i32, i32* %13
%166 = load i32*, i32** %12
store i32 %165, i32* %166
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" %lf\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [5 x i8] c" %ld\00"
@.str.3 = [3 x i8] c" ,\00"
@.str.4 = [37 x i8] c"Invalid parameter type request %d: \0A\00"
@.str.5 = [57 x i8] c"WARNING: found bad value for variable %s. Value ignored\0A\00"
@.str.6 = [34 x i8] c"Unable to find %s in input file.\0A\00"
@.str.7 = [82 x i8] c"WARNING variable: %s appears more than once in the input file. Final value taken\0A\00"
define void @rdsvar(i32* nocapture %0, i8* %1, i8* %2, i32 %3, i32 %4, i32* nocapture writeonly %5) {
%7 = alloca [1000 x i8]
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%9 = tail call i32 @strlen(i8* %1)
%10 = tail call i32 @rewind(i32* %0)
%11 = call i32 @fgets(i8* %8, i32 999, i32* %0)
br label %12
12: ; preds = %79, %6
%13 = phi i32 [ 0, %6 ], [ %80, %79 ]
%14 = phi i32 [ undef, %6 ], [ %81, %79 ]
br label %15
15: ; preds = %15, %12
%16 = phi i64 [ %17, %15 ], [ 0, %12 ]
%17 = add nuw i64 %16, 1
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %1, i64 %16
%21 = load i8, i8* %20
%22 = icmp eq i8 %19, %21
br i1 %22, label %15, label %23
23: ; preds = %15
%24 = trunc i64 %16 to i32
%25 = trunc i64 %17 to i32
%26 = icmp sgt i32 %9, %24
br i1 %26, label %79, label %27
27: ; preds = %23
%28 = add nsw i32 %13, 1
switch i32 %3, label %72 [
i32 3, label %29
i32 4, label %33
i32 1, label %37
i32 2, label %41
i32 5, label %45
]
29: ; preds = %27
%30 = and i64 %17, 4294967295
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %30
%32 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %74
33: ; preds = %27
%34 = and i64 %17, 4294967295
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %34
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %74
37: ; preds = %27
%38 = and i64 %17, 4294967295
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %38
%40 = call i32 (i8*, i8*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %74
41: ; preds = %27
%42 = and i64 %17, 4294967295
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %42
%44 = call i32 (i8*, i8*, ...) @sscanf(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %74
45: ; preds = %27
%46 = and i64 %17, 4294967295
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %46
%48 = call i32 @strspn(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%49 = add nsw i32 %48, %25
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %50
%52 = call i32 @strlen(i8* %51)
%53 = sext i32 %52 to i64
br label %54
54: ; preds = %54, %45
%55 = phi i64 [ %56, %54 ], [ %53, %45 ]
%56 = add i64 %55, -1
%57 = add nsw i64 %56, %50
%58 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @isspace(i8 signext %59)
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %54
62: ; preds = %54
%63 = trunc i64 %55 to i32
%64 = call i32 @strlen(i8* %51)
%65 = icmp slt i32 %64, 2
br i1 %65, label %66, label %67
66: ; preds = %62
store i8 0, i8* %51
br label %67
67: ; preds = %62, %66
%68 = add i32 %49, %63
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %69
store i8 0, i8* %70
%71 = call i32 @strcpy(i8* %2, i8* %51)
br label %79
72: ; preds = %27
%73 = call i32 (i8*, ...) @ShowErrorMessage(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %3)
br label %74
74: ; preds = %72, %41, %37, %33, %29
%75 = phi i32 [ %14, %72 ], [ %44, %41 ], [ %40, %37 ], [ %36, %33 ], [ %32, %29 ]
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 @ShowWarningMessage(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %79
79: ; preds = %67, %74, %77, %23
%80 = phi i32 [ %28, %74 ], [ %13, %77 ], [ %13, %23 ], [ %28, %67 ]
%81 = phi i32 [ %75, %74 ], [ 0, %77 ], [ %14, %23 ], [ 1, %67 ]
%82 = call i32 @fgets(i8* %8, i32 999, i32* %0)
%83 = call i32 @feof(i32* %0)
%84 = icmp eq i32 %83, 0
br i1 %84, label %12, label %85
85: ; preds = %79
%86 = icmp eq i32 %80, 0
%87 = icmp ne i32 %4, 0
%88 = and i1 %87, %86
br i1 %88, label %89, label %91
89: ; preds = %85
%90 = call i32 (i8*, ...) @ShowErrorMessage(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %1)
br label %95
91: ; preds = %85
%92 = icmp sgt i32 %80, 1
br i1 %92, label %93, label %95
93: ; preds = %91
%94 = call i32 @ShowWarningMessage(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.7, i64 0, i64 0), i8* %1)
br label %95
95: ; preds = %89, %93, %91
store i32 %80, i32* %5
ret void
}