#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
double nearLine(double, double, float, float, float, float);
double pythagoras(float, float);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *);
scalar_t__ strcmp(char *, char *);
int range(double lat, double lon, double d, FILE *in) {
  float newLat, newLon, oldLat, oldLon;
  char line[256], oldValid;
  while (!feof(in)) {
    oldValid = 'f';
    while ((fgets(line, 256, in) != NULL) && (strcmp(line, "front\n"))) {
      (void)sscanf(line, "%f %f", &newLat, &newLon);
      if (pythagoras(lat - newLat, lon - newLon) <= d)
        return 0;
      if (oldValid == 't') {
        if (pythagoras(newLat - oldLat, newLon - oldLon) > 0.01) {
          if (nearLine(lat, lon, newLat, newLon, oldLat, oldLon) <= d)
            return 0;
        }
      } else {
        oldLat = newLat;
        oldLon = newLon;
        oldValid = 't';
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119c <range+0x3c>
jmp    1315 <range+0x1b5>
movb   $0x66,-0x141(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x142(%rbp)
je     11ed <range+0x8d>
lea    -0x140(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x142(%rbp)
mov    -0x142(%rbp),%al
test   $0x1,%al
jne    1200 <range+0xa0>
jmp    1310 <range+0x1b0>
lea    -0x140(%rbp),%rdi
lea    0xe01(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1070 <sscanf@plt>
movsd  -0x10(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movsd  -0x18(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
call   1080 <pythagoras@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     126a <range+0x10a>
movl   $0x0,-0x4(%rbp)
jmp    131c <range+0x1bc>
movsbl -0x141(%rbp),%eax
cmp    $0x74,%eax
jne    12f0 <range+0x190>
movss  -0x2c(%rbp),%xmm0
subss  -0x34(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
subss  -0x38(%rbp),%xmm1
call   1080 <pythagoras@plt>
movsd  0xd65(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12eb <range+0x18b>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
movss  -0x30(%rbp),%xmm3
movss  -0x34(%rbp),%xmm4
movss  -0x38(%rbp),%xmm5
call   1060 <nearLine@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12e6 <range+0x186>
movl   $0x0,-0x4(%rbp)
jmp    131c <range+0x1bc>
jmp    12eb <range+0x18b>
jmp    130b <range+0x1ab>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movb   $0x74,-0x141(%rbp)
jmp    11a3 <range+0x43>
jmp    117e <range+0x1e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<range>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %rdi,%r14
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
call   1050 <feof@plt>
test   %eax,%eax
je     11aa <range+0x4a>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x30(%rsp),%rbx
lea    0xe52(%rip),%r15
lea    0x8(%rsp),%rbp
xor    %r12d,%r12d
jmp    11cc <range+0x6c>
mov    %r14,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    118f <range+0x2f>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     11c0 <range+0x60>
xor    %r13d,%r13d
jmp    121a <range+0xba>
cs nopw 0x0(%rax,%rax,1)
movss  0x8(%rsp),%xmm1
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    $0x1,%r13b
test   %rax,%rax
je     11c0 <range+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c0 <range+0x60>
mov    %rbx,%rdi
lea    0xddb(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbp,%rcx
call   1070 <sscanf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0x20(%rsp),%xmm2
subsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
call   1080 <pythagoras@plt>
movsd  0x28(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    1195 <range+0x35>
movss  0xc(%rsp),%xmm0
test   $0x1,%r13b
je     11f0 <range+0x90>
subss  0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
subss  0x14(%rsp),%xmm1
call   1080 <pythagoras@plt>
ucomisd 0xd45(%rip),%xmm0
jbe    1202 <range+0xa2>
movss  0xc(%rsp),%xmm2
movss  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movss  0x10(%rsp),%xmm4
movss  0x14(%rsp),%xmm5
call   1060 <nearLine@plt>
movsd  0x28(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     1202 <range+0xa2>
jmp    1195 <range+0x35>

LLVM IR (-O0):
@.str = [7 x i8] c"front\0A\00"
@.str.1 = [6 x i8] c"%f %f\00"
define i32 @range(double %0, double %1, double %2, i32* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32*
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca [256 x i8]
%15 = alloca i8
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i32* %3, i32** %9
br label %16
16: ; preds = %80, %4
%17 = load i32*, i32** %9
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %81
21: ; preds = %16
store i8 102, i8* %15
br label %22
22: ; preds = %79, %21
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%24 = load i32*, i32** %9
%25 = call i32* @fgets(i8* %23, i32 256, i32* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %27, %22
%32 = phi i1 [ false, %22 ], [ %30, %27 ]
br i1 %32, label %33, label %80
33: ; preds = %31
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%35 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %10, float* %11)
%36 = load double, double* %6
%37 = load float, float* %10
%38 = fpext float %37 to double
%39 = fsub double %36, %38
%40 = fptrunc double %39 to float
%41 = load double, double* %7
%42 = load float, float* %11
%43 = fpext float %42 to double
%44 = fsub double %41, %43
%45 = fptrunc double %44 to float
%46 = call double @pythagoras(float %40, float %45)
%47 = load double, double* %8
%48 = fcmp ole double %46, %47
br i1 %48, label %49, label %50
49: ; preds = %33
store i32 0, i32* %5
br label %82
50: ; preds = %33
%51 = load i8, i8* %15
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 116
br i1 %53, label %54, label %76
54: ; preds = %50
%55 = load float, float* %10
%56 = load float, float* %12
%57 = fsub float %55, %56
%58 = load float, float* %11
%59 = load float, float* %13
%60 = fsub float %58, %59
%61 = call double @pythagoras(float %57, float %60)
%62 = fcmp ogt double %61, 1.000000e-02
br i1 %62, label %63, label %75
63: ; preds = %54
%64 = load double, double* %6
%65 = load double, double* %7
%66 = load float, float* %10
%67 = load float, float* %11
%68 = load float, float* %12
%69 = load float, float* %13
%70 = call double @nearLine(double %64, double %65, float %66, float %67, float %68, float %69)
%71 = load double, double* %8
%72 = fcmp ole double %70, %71
br i1 %72, label %73, label %74
73: ; preds = %63
store i32 0, i32* %5
br label %82
74: ; preds = %63
br label %75
75: ; preds = %74, %54
br label %79
76: ; preds = %50
%77 = load float, float* %10
store float %77, float* %12
%78 = load float, float* %11
store float %78, float* %13
store i8 116, i8* %15
br label %79
79: ; preds = %76, %75
br label %22
80: ; preds = %31
br label %16
81: ; preds = %16
store i32 1, i32* %5
br label %82
82: ; preds = %81, %73, %49
%83 = load i32, i32* %5
ret i32 %83
}

LLVM IR (-O2):
@.str = [7 x i8] c"front\0A\00"
@.str.1 = [6 x i8] c"%f %f\00"
define i32 @range(double %0, double %1, double %2, i32* nocapture %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca [256 x i8]
%8 = bitcast float* %5 to i8*
%9 = bitcast float* %6 to i8*
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = call i32 @feof(i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %61
13: ; preds = %4, %56
%14 = phi float [ %58, %56 ], [ undef, %4 ]
%15 = phi float [ %57, %56 ], [ undef, %4 ]
%16 = call i32* @fgets(i8* %10, i32 256, i32* %3)
%17 = icmp eq i32* %16, null
br i1 %17, label %56, label %18
18: ; preds = %13, %51
%19 = phi i1 [ true, %51 ], [ false, %13 ]
%20 = phi float [ %53, %51 ], [ %14, %13 ]
%21 = phi float [ %52, %51 ], [ %15, %13 ]
%22 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %56, label %24
24: ; preds = %18
%25 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %5, float* %6)
%26 = load float, float* %5
%27 = fpext float %26 to double
%28 = fsub double %0, %27
%29 = fptrunc double %28 to float
%30 = load float, float* %6
%31 = fpext float %30 to double
%32 = fsub double %1, %31
%33 = fptrunc double %32 to float
%34 = call double @pythagoras(float %29, float %33)
%35 = fcmp ugt double %34, %2
br i1 %35, label %36, label %61
36: ; preds = %24
%37 = load float, float* %5
br i1 %19, label %38, label %49
38: ; preds = %36
%39 = fsub float %37, %21
%40 = load float, float* %6
%41 = fsub float %40, %20
%42 = call double @pythagoras(float %39, float %41)
%43 = fcmp ogt double %42, 1.000000e-02
br i1 %43, label %44, label %51
44: ; preds = %38
%45 = load float, float* %5
%46 = load float, float* %6
%47 = call double @nearLine(double %0, double %1, float %45, float %46, float %21, float %20)
%48 = fcmp ugt double %47, %2
br i1 %48, label %51, label %61
49: ; preds = %36
%50 = load float, float* %6
br label %51
51: ; preds = %38, %44, %49
%52 = phi float [ %21, %44 ], [ %21, %38 ], [ %37, %49 ]
%53 = phi float [ %20, %44 ], [ %20, %38 ], [ %50, %49 ]
%54 = call i32* @fgets(i8* %10, i32 256, i32* %3)
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %18
56: ; preds = %18, %51, %13
%57 = phi float [ %15, %13 ], [ %52, %51 ], [ %21, %18 ]
%58 = phi float [ %14, %13 ], [ %53, %51 ], [ %20, %18 ]
%59 = call i32 @feof(i32* %3)
%60 = icmp eq i32 %59, 0
br i1 %60, label %13, label %61
61: ; preds = %56, %44, %24, %4
%62 = phi i32 [ 1, %4 ], [ 0, %24 ], [ 0, %44 ], [ 1, %56 ]
ret i32 %62
}