#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*/ LC_NUMERIC;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ parseConfigurationLine(void *, char const *, int, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(char *, char *);
char *strdup(int /*<<< orphan*/);
int parseConfigurationFile(void *inst, const char *fname) {
  int lineNumber = 0;
  char lineBuf[2048];
  FILE *fp;
  if ((fp = fopen(fname, "r")) == NULL) {
    perror(fname);
    return -1;
  } else {
    char *oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
    if (strcmp(oldlocale, "C")) {
      setlocale(LC_NUMERIC, "C");
    } else {
      free(oldlocale);
      oldlocale = NULL;
    };
    while (fgets(lineBuf, 2048, fp) != NULL) {
      lineNumber += 1;
      parseConfigurationLine(inst, fname, lineNumber, lineBuf);
    }
    if (oldlocale) {
      setlocale(LC_NUMERIC, oldlocale);
      free(oldlocale);
    };
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<parseConfigurationFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmp    $0x0,%rax
jne    11e0 <parseConfigurationFile+0x50>
mov    -0x18(%rbp),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12dc <parseConfigurationFile+0x14c>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <setlocale@plt>
mov    %eax,%edi
call   10b0 <strdup@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1237 <parseConfigurationFile+0xa7>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
call   1070 <setlocale@plt>
jmp    124e <parseConfigurationFile+0xbe>
mov    -0x830(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x830(%rbp)
jmp    1253 <parseConfigurationFile+0xc3>
lea    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rdx
mov    $0x800,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     129a <parseConfigurationFile+0x10a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x820(%rbp),%rcx
call   1080 <parseConfigurationLine@plt>
jmp    1253 <parseConfigurationFile+0xc3>
cmpq   $0x0,-0x830(%rbp)
je     12c9 <parseConfigurationFile+0x139>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    -0x830(%rbp),%rsi
call   1070 <setlocale@plt>
mov    -0x830(%rbp),%rdi
call   1030 <free@plt>
mov    -0x828(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseConfigurationFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe52(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1292 <parseConfigurationFile+0x102>
mov    %rax,%r13
mov    0x2e1f(%rip),%rbx
mov    (%rbx),%edi
xor    %esi,%esi
call   1070 <setlocale@plt>
mov    %eax,%edi
call   10b0 <strdup@plt>
mov    %rax,%r12
lea    0xe1f(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1200 <parseConfigurationFile+0x70>
mov    (%rbx),%edi
lea    0xe09(%rip),%rsi
call   1070 <setlocale@plt>
jmp    120b <parseConfigurationFile+0x7b>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
mov    %rsp,%rdi
mov    $0x800,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1258 <parseConfigurationFile+0xc8>
mov    $0x1,%ebp
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1080 <parseConfigurationLine@plt>
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    1230 <parseConfigurationFile+0xa0>
test   %r12,%r12
je     1276 <parseConfigurationFile+0xe6>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
call   1070 <setlocale@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%eax
jmp    1280 <parseConfigurationFile+0xf0>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@LC_NUMERIC = global i32 0
@.str.1 = [2 x i8] c"C\00"
define i32 @parseConfigurationFile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [2048 x i8]
%8 = alloca i32*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%10 = load i8*, i8** %5
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @perror(i8* %14)
store i32 -1, i32* %3
br label %56
16: ; preds = %2
%17 = load i32, i32* @LC_NUMERIC
%18 = call i32 @setlocale(i32 %17, i8* null)
%19 = call i8* @strdup(i32 %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* @LC_NUMERIC
%25 = call i32 @setlocale(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
26: ; preds = %16
%27 = load i8*, i8** %9
%28 = call i32 @free(i8* %27)
store i8* null, i8** %9
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %35, %29
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%32 = load i32*, i32** %8
%33 = call i32* @fgets(i8* %31, i32 2048, i32* %32)
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
%38 = load i8*, i8** %4
%39 = load i8*, i8** %5
%40 = load i32, i32* %6
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%42 = call i32 @parseConfigurationLine(i8* %38, i8* %39, i32 %40, i8* %41)
br label %30
43: ; preds = %30
%44 = load i8*, i8** %9
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* @LC_NUMERIC
%48 = load i8*, i8** %9
%49 = call i32 @setlocale(i32 %47, i8* %48)
%50 = load i8*, i8** %9
%51 = call i32 @free(i8* %50)
br label %52
52: ; preds = %46, %43
%53 = load i32*, i32** %8
%54 = call i32 @fclose(i32* %53)
br label %55
55: ; preds = %52
store i32 0, i32* %3
br label %56
56: ; preds = %55, %13
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@LC_NUMERIC = global i32 0
@.str.1 = [2 x i8] c"C\00"
define i32 @parseConfigurationFile(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* %1)
br label %38
9: ; preds = %2
%10 = load i32, i32* @LC_NUMERIC
%11 = tail call i32 @setlocale(i32 %10, i8* null)
%12 = tail call i8* @strdup(i32 %11)
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = load i32, i32* @LC_NUMERIC
%17 = tail call i32 @setlocale(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %9
%19 = tail call i32 @free(i8* %12)
br label %20
20: ; preds = %18, %15
%21 = phi i8* [ %12, %15 ], [ null, %18 ]
%22 = call i32* @fgets(i8* %4, i32 2048, i32* %5)
%23 = icmp eq i32* %22, null
br i1 %23, label %30, label %24
24: ; preds = %20, %24
%25 = phi i32 [ %26, %24 ], [ 0, %20 ]
%26 = add nuw nsw i32 %25, 1
%27 = call i32 @parseConfigurationLine(i8* %0, i8* %1, i32 %26, i8* %4)
%28 = call i32* @fgets(i8* %4, i32 2048, i32* %5)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %24
30: ; preds = %24, %20
%31 = icmp eq i8* %21, null
br i1 %31, label %36, label %32
32: ; preds = %30
%33 = load i32, i32* @LC_NUMERIC
%34 = call i32 @setlocale(i32 %33, i8* %21)
%35 = call i32 @free(i8* %21)
br label %36
36: ; preds = %32, %30
%37 = call i32 @fclose(i32* %5)
br label %38
38: ; preds = %36, %7
%39 = phi i32 [ -1, %7 ], [ 0, %36 ]
ret i32 %39
}