#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 */
long double cov_deserialize(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
void cov_check(char *log, char *spec, char *result) {
  char line[80], estimate_hex[80], ideal_hex[80], delta_hex[80];
  long double estimate, ideal, delta, diff;
  FILE *log_file, *spec_file, *result_file;
  int ld_size;
  ld_size = 10;
  log_file = fopen(log, "rt");
  while (fgets(line, 80, log_file) != NULL) {
    if (line[0] != '#')
      strcpy(estimate_hex, line);
  }
  fclose(log_file);
  spec_file = fopen(spec, "rt");
  while (fgets(line, 80, spec_file) != NULL) {
    if (strncmp(line, "#ideal", 6) == 0) {
      fgets(ideal_hex, 80, spec_file);
    } else if (strncmp(line, "#delta", 6) == 0) {
      fgets(delta_hex, 80, spec_file);
    }
  }
  fclose(spec_file);
  estimate = cov_deserialize(estimate_hex, ld_size);
  ideal = cov_deserialize(ideal_hex, ld_size);
  delta = cov_deserialize(delta_hex, ld_size);
  if (estimate > ideal)
    diff = estimate - ideal;
  else
    diff = ideal - estimate;
  result_file = fopen(result, "w");
  if (delta >= diff)
    fprintf(result_file, "true\n");
  else
    fprintf(result_file, "false\n");
  fclose(result_file);
}


x86 assembly (clang, -O0):
<cov_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xa,-0x1bc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1a8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x1a8(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11e9 <cov_check+0x79>
movsbl -0x70(%rbp),%eax
cmp    $0x23,%eax
je     11e4 <cov_check+0x74>
lea    -0xc0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11a8 <cov_check+0x38>
mov    -0x1a8(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1b0(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x1b0(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12a8 <cov_check+0x138>
lea    -0x70(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1267 <cov_check+0xf7>
lea    -0x110(%rbp),%rdi
mov    -0x1b0(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
jmp    12a3 <cov_check+0x133>
lea    -0x70(%rbp),%rdi
lea    0xd98(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    129e <cov_check+0x12e>
lea    -0x160(%rbp),%rdi
mov    -0x1b0(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
jmp    12a3 <cov_check+0x133>
jmp    120c <cov_check+0x9c>
mov    -0x1b0(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1bc(%rbp),%esi
lea    -0xc0(%rbp),%rdi
call   1090 <cov_deserialize@plt>
fstpt  -0x170(%rbp)
mov    -0x1bc(%rbp),%esi
lea    -0x110(%rbp),%rdi
call   1090 <cov_deserialize@plt>
fstpt  -0x180(%rbp)
mov    -0x1bc(%rbp),%esi
lea    -0x160(%rbp),%rdi
call   1090 <cov_deserialize@plt>
fstpt  -0x190(%rbp)
fldt   -0x170(%rbp)
fldt   -0x180(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1332 <cov_check+0x1c2>
jmp    1319 <cov_check+0x1a9>
fldt   -0x170(%rbp)
fldt   -0x180(%rbp)
fsubrp %st,%st(1)
fstpt  -0x1a0(%rbp)
jmp    1346 <cov_check+0x1d6>
fldt   -0x180(%rbp)
fldt   -0x170(%rbp)
fsubrp %st,%st(1)
fstpt  -0x1a0(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xcc0(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1b8(%rbp)
fldt   -0x190(%rbp)
fldt   -0x1a0(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1392 <cov_check+0x222>
jmp    137a <cov_check+0x20a>
mov    -0x1b8(%rbp),%rdi
lea    0xc8b(%rip),%rsi
call   1070 <fprintf@plt>
jmp    13a5 <cov_check+0x235>
mov    -0x1b8(%rbp),%rdi
lea    0xc79(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x1b8(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cov_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,%r15
lea    0xe70(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0x30(%rsp),%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e9 <cov_check+0x79>
lea    0x30(%rsp),%r12
lea    0x120(%rsp),%r13
jmp    11d5 <cov_check+0x65>
xchg   %ax,%ax
mov    %r12,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e9 <cov_check+0x79>
cmpb   $0x23,0x30(%rsp)
je     11c0 <cov_check+0x50>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
jmp    11c0 <cov_check+0x50>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe08(%rip),%rsi
mov    %r15,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0x30(%rsp),%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1294 <cov_check+0x124>
lea    0xd0(%rsp),%rbp
lea    0xdda(%rip),%r15
lea    0x30(%rsp),%r12
lea    0x80(%rsp),%r14
lea    0xdcd(%rip),%r13
jmp    1262 <cov_check+0xf2>
nop
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r12,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1294 <cov_check+0x124>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rbp,%rdi
test   %rax,%rax
je     1240 <cov_check+0xd0>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %r14,%rdi
test   %rax,%rax
jne    124d <cov_check+0xdd>
jmp    1240 <cov_check+0xd0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0x120(%rsp),%rdi
mov    $0xa,%esi
call   1090 <cov_deserialize@plt>
fstpt  0x4(%rsp)
lea    0xd0(%rsp),%rdi
mov    $0xa,%esi
call   1090 <cov_deserialize@plt>
fstpt  0x18(%rsp)
lea    0x80(%rsp),%rdi
mov    $0xa,%esi
call   1090 <cov_deserialize@plt>
fstpt  0x24(%rsp)
fldt   0x4(%rsp)
fldt   0x18(%rsp)
fxch   %st(1)
fucomi %st(1),%st
fld    %st(0)
fsub   %st(2),%st
fxch   %st(2)
fsubp  %st,%st(1)
fcmovnbe %st(1),%st
fstp   %st(1)
fstpt  0x4(%rsp)
lea    0xd10(%rip),%rsi
mov    0x10(%rsp),%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
fldt   0x24(%rsp)
fldt   0x4(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jae    132c <cov_check+0x1bc>
lea    0xcf4(%rip),%rdi
mov    $0x6,%esi
jmp    1338 <cov_check+0x1c8>
lea    0xce0(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [7 x i8] c"#ideal\00"
@.str.2 = [7 x i8] c"#delta\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"true\0A\00"
@.str.5 = [7 x i8] c"false\0A\00"
define void @cov_check(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca [80 x i8]
%11 = alloca x86_fp80
%12 = alloca x86_fp80
%13 = alloca x86_fp80
%14 = alloca x86_fp80
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 10, i32* %18
%19 = load i8*, i8** %4
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %15
br label %21
21: ; preds = %35, %3
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%23 = load i32*, i32** %15
%24 = call i32* @fgets(i8* %22, i32 80, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 35
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %31, %26
br label %21
36: ; preds = %21
%37 = load i32*, i32** %15
%38 = call i32 @fclose(i32* %37)
%39 = load i8*, i8** %5
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %40, i32** %16
br label %41
41: ; preds = %63, %36
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%43 = load i32*, i32** %16
%44 = call i32* @fgets(i8* %42, i32 80, i32* %43)
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %64
46: ; preds = %41
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%52 = load i32*, i32** %16
%53 = call i32* @fgets(i8* %51, i32 80, i32* %52)
br label %63
54: ; preds = %46
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%56 = call i64 @strncmp(i8* %55, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%60 = load i32*, i32** %16
%61 = call i32* @fgets(i8* %59, i32 80, i32* %60)
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62, %50
br label %41
64: ; preds = %41
%65 = load i32*, i32** %16
%66 = call i32 @fclose(i32* %65)
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%68 = load i32, i32* %18
%69 = call x86_fp80 @cov_deserialize(i8* %67, i32 %68)
store x86_fp80 %69, x86_fp80* %11
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%71 = load i32, i32* %18
%72 = call x86_fp80 @cov_deserialize(i8* %70, i32 %71)
store x86_fp80 %72, x86_fp80* %12
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%74 = load i32, i32* %18
%75 = call x86_fp80 @cov_deserialize(i8* %73, i32 %74)
store x86_fp80 %75, x86_fp80* %13
%76 = load x86_fp80, x86_fp80* %11
%77 = load x86_fp80, x86_fp80* %12
%78 = fcmp ogt x86_fp80 %76, %77
br i1 %78, label %79, label %83
79: ; preds = %64
%80 = load x86_fp80, x86_fp80* %11
%81 = load x86_fp80, x86_fp80* %12
%82 = fsub x86_fp80 %80, %81
store x86_fp80 %82, x86_fp80* %14
br label %87
83: ; preds = %64
%84 = load x86_fp80, x86_fp80* %12
%85 = load x86_fp80, x86_fp80* %11
%86 = fsub x86_fp80 %84, %85
store x86_fp80 %86, x86_fp80* %14
br label %87
87: ; preds = %83, %79
%88 = load i8*, i8** %6
%89 = call i32* @fopen(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %89, i32** %17
%90 = load x86_fp80, x86_fp80* %13
%91 = load x86_fp80, x86_fp80* %14
%92 = fcmp oge x86_fp80 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %87
%94 = load i32*, i32** %17
%95 = call i32 @fprintf(i32* %94, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %99
96: ; preds = %87
%97 = load i32*, i32** %17
%98 = call i32 @fprintf(i32* %97, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %99
99: ; preds = %96, %93
%100 = load i32*, i32** %17
%101 = call i32 @fclose(i32* %100)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [7 x i8] c"#ideal\00"
@.str.2 = [7 x i8] c"#delta\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"true\0A\00"
@.str.5 = [7 x i8] c"false\0A\00"
define void @cov_check(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @fgets(i8* %8, i32 80, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %23, label %15
15: ; preds = %3, %20
%16 = load i8, i8* %8
%17 = icmp eq i8 %16, 35
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @strcpy(i8* %9, i8* %8)
br label %20
20: ; preds = %18, %15
%21 = call i32* @fgets(i8* %8, i32 80, i32* %12)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %15
23: ; preds = %20, %3
%24 = call i32 @fclose(i32* %12)
%25 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = call i32* @fgets(i8* %8, i32 80, i32* %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %40, label %28
28: ; preds = %23, %37
%29 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31, %28
%35 = phi i8* [ %10, %28 ], [ %11, %31 ]
%36 = call i32* @fgets(i8* %35, i32 80, i32* %25)
br label %37
37: ; preds = %34, %31
%38 = call i32* @fgets(i8* %8, i32 80, i32* %25)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %28
40: ; preds = %37, %23
%41 = call i32 @fclose(i32* %25)
%42 = call x86_fp80 @cov_deserialize(i8* %9, i32 10)
%43 = call x86_fp80 @cov_deserialize(i8* %10, i32 10)
%44 = call x86_fp80 @cov_deserialize(i8* %11, i32 10)
%45 = fcmp ogt x86_fp80 %42, %43
%46 = fsub x86_fp80 %42, %43
%47 = fsub x86_fp80 %43, %42
%48 = select i1 %45, x86_fp80 %46, x86_fp80 %47
%49 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%50 = fcmp ult x86_fp80 %44, %48
br i1 %50, label %53, label %51
51: ; preds = %40
%52 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 5, i64 1, i32* %49)
br label %55
53: ; preds = %40
%54 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 6, i64 1, i32* %49)
br label %55
55: ; preds = %53, %51
%56 = call i32 @fclose(i32* %49)
ret void
}