#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 */

/* Variables and functions */
double M_PI;
int abs(int);
double atan2(int, int);
int pow(int, int);
int sqrt(int);
double obsFunction(int o, int s[], int a) {
  int numberOfObservations = 73;
  double obsProbs[3] = {.4, .2, .1};
  if (a != 4) {
    if (o == (numberOfObservations - 1))
      return 1.0;
    else
      return 0.0;
  }
  int xr = s[3] - s[1];
  int yr = s[4] - s[2];
  if (sqrt(pow(xr, 2) + pow(yr, 2)) * 20 < 150 / sqrt(3)) {
    if (o == (numberOfObservations - 1))
      return 1.0;
    else
      return 0.0;
  }
  if (o == (numberOfObservations - 1)) {
    return 0.0;
  }
  int alpha = ((int)(atan2(yr, xr) * (180.0 / M_PI))) % 360 / 5;
  int minVal;
  int maxVal;
  int obsDifference = abs(alpha - o);
  if (obsDifference > (numberOfObservations - 3 * 1)) {
    if (o < alpha) {
      minVal = o;
      maxVal = alpha;
    } else {
      minVal = alpha;
      maxVal = o;
    }
    return obsProbs[o - maxVal + minVal];
  } else if (obsDifference > 1 * 3) {
    return 0.0;
  } else {
    return obsProbs[obsDifference];
  }
}


x86 assembly (clang, -O0):
<obsFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x49,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x4,-0x1c(%rbp)
je     11b4 <obsFunction+0x74>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11a7 <obsFunction+0x67>
movsd  0xe6b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    0x4(%rcx),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    0x8(%rcx),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,-0x60(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    -0x60(%rbp),%edi
add    %eax,%edi
call   1060 <sqrt@plt>
imul   $0x14,%eax,%eax
mov    %eax,-0x5c(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0x96,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jge    1254 <obsFunction+0x114>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1247 <obsFunction+0x107>
movsd  0xdcb(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1272 <obsFunction+0x132>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
mov    -0x48(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1040 <atan2@plt>
movsd  0xd7b(%rip),%xmm1
mov    0x2d5c(%rip),%rax
divsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jle    1310 <obsFunction+0x1d0>
mov    -0xc(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    12e9 <obsFunction+0x1a9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    12f5 <obsFunction+0x1b5>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x54(%rbp),%eax
add    -0x50(%rbp),%eax
cltq
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
cmpl   $0x3,-0x58(%rbp)
jle    1327 <obsFunction+0x1e7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1336 <obsFunction+0x1f6>
movslq -0x58(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obsFunction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
cmp    $0x4,%edx
jne    1190 <obsFunction+0x60>
mov    0xc(%rsi),%r15d
mov    0x10(%rsi),%ebx
sub    0x4(%rsi),%r15d
sub    0x8(%rsi),%ebx
mov    %r15d,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
add    %eax,%ebp
mov    %ebp,%edi
call   1050 <sqrt@plt>
shl    $0x2,%eax
lea    (%rax,%rax,4),%ebp
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x96,%eax
xor    %edx,%edx
idiv   %ecx
cmp    %eax,%ebp
jge    11ac <obsFunction+0x7c>
cmp    $0x48,%r14d
je     119f <obsFunction+0x6f>
xorpd  %xmm0,%xmm0
jmp    124a <obsFunction+0x11a>
movsd  0xe59(%rip),%xmm0
jmp    124a <obsFunction+0x11a>
xorpd  %xmm0,%xmm0
cmp    $0x48,%r14d
je     124a <obsFunction+0x11a>
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <atan2@plt>
mov    0x2e1d(%rip),%rax
movsd  0xe35(%rip),%xmm1
divsd  (%rax),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x8,%ecx
add    %edx,%ecx
imul   $0x168,%ecx,%ecx
sub    %ecx,%eax
cwtl
imul   $0x6667,%eax,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x11,%eax
add    %ecx,%eax
mov    %eax,%edx
sub    %r14d,%edx
mov    %edx,%ecx
neg    %ecx
cmovs  %edx,%ecx
cmp    $0x47,%ecx
jb     1233 <obsFunction+0x103>
lea    (%r14,%r14,1),%ecx
sub    %eax,%ecx
cmp    %r14d,%eax
cmovle %eax,%ecx
movslq %ecx,%rax
jmp    123e <obsFunction+0x10e>
cmp    $0x3,%ecx
xorpd  %xmm0,%xmm0
ja     124a <obsFunction+0x11a>
mov    %ecx,%eax
lea    0xdcb(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.obsFunction.obsProbs = [3 x double] [double 4.000000e-01, double 2.000000e-01, double 1.000000e-01]
@M_PI = global double 0.000000e+00
define double @obsFunction(i32 %0, i32* %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x double]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 73, i32* %8
%16 = bitcast [3 x double]* %9 to i8*
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 4
br i1 %18, label %19, label %26
19: ; preds = %3
%20 = load i32, i32* %5
%21 = load i32, i32* %8
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %25
24: ; preds = %19
store double 1.000000e+00, double* %4
br label %110
25: ; preds = %19
store double 0.000000e+00, double* %4
br label %110
26: ; preds = %3
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 3
%29 = load i32, i32* %28
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
%33 = sub nsw i32 %29, %32
store i32 %33, i32* %10
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 4
%36 = load i32, i32* %35
%37 = load i32*, i32** %6
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = sub nsw i32 %36, %39
store i32 %40, i32* %11
%41 = load i32, i32* %10
%42 = call i32 @pow(i32 %41, i32 2)
%43 = load i32, i32* %11
%44 = call i32 @pow(i32 %43, i32 2)
%45 = add nsw i32 %42, %44
%46 = call i32 @sqrt(i32 %45)
%47 = mul nsw i32 %46, 20
%48 = call i32 @sqrt(i32 3)
%49 = sdiv i32 150, %48
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %58
51: ; preds = %26
%52 = load i32, i32* %5
%53 = load i32, i32* %8
%54 = sub nsw i32 %53, 1
%55 = icmp eq i32 %52, %54
br i1 %55, label %56, label %57
56: ; preds = %51
store double 1.000000e+00, double* %4
br label %110
57: ; preds = %51
store double 0.000000e+00, double* %4
br label %110
58: ; preds = %26
%59 = load i32, i32* %5
%60 = load i32, i32* %8
%61 = sub nsw i32 %60, 1
%62 = icmp eq i32 %59, %61
br i1 %62, label %63, label %64
63: ; preds = %58
store double 0.000000e+00, double* %4
br label %110
64: ; preds = %58
%65 = load i32, i32* %11
%66 = load i32, i32* %10
%67 = call double @atan2(i32 %65, i32 %66)
%68 = load double, double* @M_PI
%69 = fdiv double 1.800000e+02, %68
%70 = fmul double %67, %69
%71 = fptosi double %70 to i32
%72 = srem i32 %71, 360
%73 = sdiv i32 %72, 5
store i32 %73, i32* %12
%74 = load i32, i32* %12
%75 = load i32, i32* %5
%76 = sub nsw i32 %74, %75
%77 = call i32 @abs(i32 %76)
store i32 %77, i32* %15
%78 = load i32, i32* %15
%79 = load i32, i32* %8
%80 = sub nsw i32 %79, 3
%81 = icmp sgt i32 %78, %80
br i1 %81, label %82, label %101
82: ; preds = %64
%83 = load i32, i32* %5
%84 = load i32, i32* %12
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i32, i32* %5
store i32 %87, i32* %13
%88 = load i32, i32* %12
store i32 %88, i32* %14
br label %92
89: ; preds = %82
%90 = load i32, i32* %12
store i32 %90, i32* %13
%91 = load i32, i32* %5
store i32 %91, i32* %14
br label %92
92: ; preds = %89, %86
%93 = load i32, i32* %5
%94 = load i32, i32* %14
%95 = sub nsw i32 %93, %94
%96 = load i32, i32* %13
%97 = add nsw i32 %95, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %98
%100 = load double, double* %99
store double %100, double* %4
br label %110
101: ; preds = %64
%102 = load i32, i32* %15
%103 = icmp sgt i32 %102, 3
br i1 %103, label %104, label %105
104: ; preds = %101
store double 0.000000e+00, double* %4
br label %110
105: ; preds = %101
%106 = load i32, i32* %15
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %107
%109 = load double, double* %108
store double %109, double* %4
br label %110
110: ; preds = %105, %104, %92, %63, %57, %56, %25, %24
%111 = load double, double* %4
ret double %111
}

LLVM IR (-O2):
@__const.obsFunction.obsProbs = [3 x double] [double 4.000000e-01, double 2.000000e-01, double 1.000000e-01]
@M_PI = global double 0.000000e+00
define double @obsFunction(i32 %0, i32* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 4
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = icmp eq i32 %0, 72
%7 = select i1 %6, double 1.000000e+00, double 0.000000e+00
br label %58
8: ; preds = %3
%9 = getelementptr inbounds i32, i32* %1, i64 3
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %1, i64 1
%12 = load i32, i32* %11
%13 = sub nsw i32 %10, %12
%14 = getelementptr inbounds i32, i32* %1, i64 4
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %1, i64 2
%17 = load i32, i32* %16
%18 = sub nsw i32 %15, %17
%19 = tail call i32 @pow(i32 %13, i32 2)
%20 = tail call i32 @pow(i32 %18, i32 2)
%21 = add nsw i32 %20, %19
%22 = tail call i32 @sqrt(i32 %21)
%23 = mul nsw i32 %22, 20
%24 = tail call i32 @sqrt(i32 3)
%25 = sdiv i32 150, %24
%26 = icmp slt i32 %23, %25
%27 = icmp eq i32 %0, 72
br i1 %26, label %28, label %30
28: ; preds = %8
%29 = select i1 %27, double 1.000000e+00, double 0.000000e+00
br label %58
30: ; preds = %8
br i1 %27, label %58, label %31
31: ; preds = %30
%32 = tail call double @atan2(i32 %18, i32 %13)
%33 = load double, double* @M_PI
%34 = fdiv double 1.800000e+02, %33
%35 = fmul double %32, %34
%36 = fptosi double %35 to i32
%37 = srem i32 %36, 360
%38 = trunc i32 %37 to i16
%39 = sdiv i16 %38, 5
%40 = sext i16 %39 to i32
%41 = sub nsw i32 %40, %0
%42 = tail call i32 @llvm.abs.i32(i32 %41, i1 true)
%43 = icmp ugt i32 %42, 70
br i1 %43, label %44, label %52
44: ; preds = %31
%45 = icmp sgt i32 %40, %0
%46 = shl i32 %0, 1
%47 = sub i32 %46, %40
%48 = select i1 %45, i32 %47, i32 %40
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [3 x double], [3 x double]* @__const.obsFunction.obsProbs, i64 0, i64 %49
%51 = load double, double* %50
br label %58
52: ; preds = %31
%53 = icmp ugt i32 %42, 3
br i1 %53, label %58, label %54
54: ; preds = %52
%55 = zext i32 %42 to i64
%56 = getelementptr inbounds [3 x double], [3 x double]* @__const.obsFunction.obsProbs, i64 0, i64 %55
%57 = load double, double* %56
br label %58
58: ; preds = %28, %30, %52, %54, %44, %5
%59 = phi double [ %7, %5 ], [ %29, %28 ], [ 0.000000e+00, %30 ], [ %51, %44 ], [ %57, %54 ], [ 0.000000e+00, %52 ]
ret double %59
}