#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;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *, double *,
                          double *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void readCalibParams(char *fname, double ical[9]) {
  FILE *fp;
  int i, ch = EOF;
  if ((fp = fopen(fname, "r")) == NULL) {
    fprintf(stderr, "cannot open file %s, exiting\n", fname);
    exit(1);
  }
  while (!feof(fp) && (ch = fgetc(fp)) == '#') {
    char buf[2048];
    while (!feof(fp))
      if (!fgets(buf, 2048 - 1, fp) || buf[strlen(buf) - 1] == '\n')
        break;
  };
  if (feof(fp)) {
    ical[0] = ical[1] = ical[2] = ical[3] = ical[4] = ical[5] = ical[6] =
        ical[7] = ical[8] = 0.0;
    return;
  }
  ungetc(ch, fp);
  for (i = 0; i < 3; i++) {
    fscanf(fp, "%lf%lf%lf\n", ical, ical + 1, ical + 2);
    ical += 3;
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<readCalibParams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1200 <readCalibParams+0x60>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe11(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1205 <readCalibParams+0x65>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x821(%rbp)
jne    123b <readCalibParams+0x9b>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x23,%eax
sete   %al
mov    %al,-0x821(%rbp)
mov    -0x821(%rbp),%al
test   $0x1,%al
jne    124e <readCalibParams+0xae>
jmp    12c1 <readCalibParams+0x121>
jmp    1253 <readCalibParams+0xb3>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1272 <readCalibParams+0xd2>
jmp    12bc <readCalibParams+0x11c>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x7ff,%esi
call   1070 <fgets@plt>
cmp    $0x0,%eax
je     12b2 <readCalibParams+0x112>
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12b7 <readCalibParams+0x117>
jmp    12bc <readCalibParams+0x11c>
jmp    1253 <readCalibParams+0xb3>
jmp    1205 <readCalibParams+0x65>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1344 <readCalibParams+0x1a4>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    13a8 <readCalibParams+0x208>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   10a0 <ungetc@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    139f <readCalibParams+0x1ff>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x10(%rbp),%rcx
add    $0x8,%rcx
mov    -0x10(%rbp),%r8
add    $0x10,%r8
lea    0xca0(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1357 <readCalibParams+0x1b7>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readCalibParams>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e2e(%rip),%rax
mov    (%rax),%ebp
lea    0xe3d(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12e8 <readCalibParams+0x148>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    124d <readCalibParams+0xad>
mov    %rsp,%rbx
jmp    11fd <readCalibParams+0x5d>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    1248 <readCalibParams+0xa8>
mov    %r15,%rdi
call   1060 <fgetc@plt>
cmp    $0x23,%eax
jne    1244 <readCalibParams+0xa4>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    11f0 <readCalibParams+0x50>
mov    %rbx,%rdi
mov    $0x7ff,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %eax,%eax
je     11f0 <readCalibParams+0x50>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1210 <readCalibParams+0x70>
jmp    11f0 <readCalibParams+0x50>
mov    %eax,%ebp
jmp    124d <readCalibParams+0xad>
mov    $0x23,%ebp
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     127a <readCalibParams+0xda>
xorps  %xmm0,%xmm0
movups %xmm0,0x30(%r14)
movups %xmm0,0x20(%r14)
movups %xmm0,0x10(%r14)
movups %xmm0,(%r14)
movq   $0x0,0x40(%r14)
jmp    12da <readCalibParams+0x13a>
mov    %ebp,%edi
mov    %r15,%rsi
call   10a0 <ungetc@plt>
lea    0x8(%r14),%rcx
lea    0x10(%r14),%r8
lea    0xd8d(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
lea    0x18(%r14),%rdx
lea    0x20(%r14),%rcx
lea    0x28(%r14),%r8
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fscanf@plt>
lea    0x30(%r14),%rdx
lea    0x38(%r14),%rcx
add    $0x40,%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%r8
call   1050 <fscanf@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xd0a(%rip),%rsi
mov    %rbx,%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open file %s, exiting\0A\00"
@.str.2 = [11 x i8] c"%lf%lf%lf\0A\00"
define void @readCalibParams(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2048 x i8]
store i8* %0, i8** %3
store double* %1, double** %4
%9 = load i32, i32* @EOF
store i32 %9, i32* %7
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
br label %19
19: ; preds = %51, %18
%20 = load i32*, i32** %5
%21 = call i64 @feof(i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32*, i32** %5
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %7
%26 = icmp eq i32 %25, 35
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ false, %19 ], [ %26, %23 ]
br i1 %28, label %29, label %52
29: ; preds = %27
br label %30
30: ; preds = %50, %29
%31 = load i32*, i32** %5
%32 = call i64 @feof(i32* %31)
%33 = icmp ne i64 %32, 0
%34 = xor i1 %33, true
br i1 %34, label %35, label %51
35: ; preds = %30
%36 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%37 = load i32*, i32** %5
%38 = call i32 @fgets(i8* %36, i32 2047, i32* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %35
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 10
br i1 %48, label %49, label %50
49: ; preds = %40, %35
br label %51
50: ; preds = %40
br label %30
51: ; preds = %49, %30
br label %19
52: ; preds = %27
%53 = load i32*, i32** %5
%54 = call i64 @feof(i32* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %75
56: ; preds = %52
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 8
store double 0.000000e+00, double* %58
%59 = load double*, double** %4
%60 = getelementptr inbounds double, double* %59, i64 7
store double 0.000000e+00, double* %60
%61 = load double*, double** %4
%62 = getelementptr inbounds double, double* %61, i64 6
store double 0.000000e+00, double* %62
%63 = load double*, double** %4
%64 = getelementptr inbounds double, double* %63, i64 5
store double 0.000000e+00, double* %64
%65 = load double*, double** %4
%66 = getelementptr inbounds double, double* %65, i64 4
store double 0.000000e+00, double* %66
%67 = load double*, double** %4
%68 = getelementptr inbounds double, double* %67, i64 3
store double 0.000000e+00, double* %68
%69 = load double*, double** %4
%70 = getelementptr inbounds double, double* %69, i64 2
store double 0.000000e+00, double* %70
%71 = load double*, double** %4
%72 = getelementptr inbounds double, double* %71, i64 1
store double 0.000000e+00, double* %72
%73 = load double*, double** %4
%74 = getelementptr inbounds double, double* %73, i64 0
store double 0.000000e+00, double* %74
br label %98
75: ; preds = %52
%76 = load i32, i32* %7
%77 = load i32*, i32** %5
%78 = call i32 @ungetc(i32 %76, i32* %77)
store i32 0, i32* %6
br label %79
79: ; preds = %92, %75
%80 = load i32, i32* %6
%81 = icmp slt i32 %80, 3
br i1 %81, label %82, label %95
82: ; preds = %79
%83 = load i32*, i32** %5
%84 = load double*, double** %4
%85 = load double*, double** %4
%86 = getelementptr inbounds double, double* %85, i64 1
%87 = load double*, double** %4
%88 = getelementptr inbounds double, double* %87, i64 2
%89 = call i32 @fscanf(i32* %83, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %84, double* %86, double* %88)
%90 = load double*, double** %4
%91 = getelementptr inbounds double, double* %90, i64 3
store double* %91, double** %4
br label %92
92: ; preds = %82
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 1
store i32 %94, i32* %6
br label %79
95: ; preds = %79
%96 = load i32*, i32** %5
%97 = call i32 @fclose(i32* %96)
br label %98
98: ; preds = %95, %56
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open file %s, exiting\0A\00"
@.str.2 = [11 x i8] c"%lf%lf%lf\0A\00"
define void @readCalibParams(i8* %0, double* %1) {
%3 = alloca [2048 x i8]
%4 = load i32, i32* @EOF
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = call i64 @feof(i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %36
10: ; preds = %7
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
br label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10, %33
%17 = call i32 @fgetc(i32* %5)
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %36
19: ; preds = %16
br label %20
20: ; preds = %26, %19
%21 = call i64 @feof(i32* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = call i32 @fgets(i8* %11, i32 2047, i32* %5)
%25 = icmp eq i32 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = call i32 @strlen(i8* %11)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %20
33: ; preds = %23, %26, %20
%34 = call i64 @feof(i32* %5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %16, label %36
36: ; preds = %16, %33, %7
%37 = phi i32 [ %4, %7 ], [ 35, %33 ], [ %17, %16 ]
%38 = call i64 @feof(i32* %5)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = bitcast double* %1 to i8*
br label %56
42: ; preds = %36
%43 = call i32 @ungetc(i32 %37, i32* %5)
%44 = getelementptr inbounds double, double* %1, i64 1
%45 = getelementptr inbounds double, double* %1, i64 2
%46 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %1, double* %44, double* %45)
%47 = getelementptr inbounds double, double* %1, i64 3
%48 = getelementptr inbounds double, double* %1, i64 4
%49 = getelementptr inbounds double, double* %1, i64 5
%50 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %47, double* %48, double* %49)
%51 = getelementptr inbounds double, double* %1, i64 6
%52 = getelementptr inbounds double, double* %1, i64 7
%53 = getelementptr inbounds double, double* %1, i64 8
%54 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %51, double* %52, double* %53)
%55 = call i32 @fclose(i32* %5)
br label %56
56: ; preds = %42, %40
ret void
}