#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 */
float atan2(float, float);
int cmp_barker(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread_bo(int *, int, int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int read_frm_hdr(FILE *fp, short int *aux, int *pol, float *sq_ang) {
  float rlos = 0., heading = 0., dx, dy, vnms, vems, pnms, pems, trgn, trge;
  int i, rval, word;
  float pi = 3.14159265358979323846;
  if ((rval = cmp_barker(fp)) < 0) {
    if (rval == -1)
      fprintf(stderr, "Unable to find barker sequence.\n");
    if (rval == -2)
      fprintf(stderr, "Unable to read input file.\n");
    return (-1);
  }
  if (4 != fread_bo(pol, 1, 4, fp, 4)) {
    fprintf(stderr, "Error reading frame header.\n");
    return (-1);
  }
  for (i = 0; i < 57; i++) {
    if (4 != fread_bo(&word, 1, 4, fp, 4)) {
      fprintf(stderr, "Error reading frame header.\n");
      return (-1);
    }
    aux[i] = (short int)(word & 0x0000ffff);
  }
  pnms = 2.0 * aux[7] + (aux[8] & 0x7fff) / 16384.;
  pems = 2.0 * aux[9] + (aux[10] & 0x7fff) / 16384.;
  vnms = aux[13] / 128. + (aux[14] & 0x7fff) / 4194300.;
  vems = aux[15] / 128. + (aux[16] & 0x7fff) / 4194300.;
  trgn = 2.0 * aux[19] + (aux[20] & 0x7fff) / 16384.;
  trge = 2.0 * aux[21] + (aux[22] & 0x7fff) / 16384.;
  heading = pi / 2. - atan2(vnms, vems);
  if (heading > 2. * pi)
    heading -= 2. * pi;
  if (heading < 0.)
    heading += 2. * pi;
  dy = trgn - pnms;
  dx = trge - pems;
  rlos = pi / 2. - atan2(dy, dx);
  if (rlos < 0.)
    rlos += 2. * pi;
  *sq_ang = rlos - heading;
  if (*sq_ang > pi)
    *sq_ang -= 2. * pi;
  if (*sq_ang < -pi)
    *sq_ang += 2. * pi;
  return (0);
}


x86 assembly (clang, -O0):
<read_frm_hdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xe90(%rip),%xmm0
movss  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cmp_barker@plt>
mov    %eax,-0x58(%rbp)
cmp    $0x0,%eax
jge    11d4 <read_frm_hdr+0x94>
cmpl   $0xffffffff,-0x58(%rbp)
jne    11a9 <read_frm_hdr+0x69>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0xfffffffe,-0x58(%rbp)
jne    11c8 <read_frm_hdr+0x88>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <read_frm_hdr+0x4c3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%r8d
mov    %r8d,%edx
call   1060 <fread_bo@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
je     121f <read_frm_hdr+0xdf>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <read_frm_hdr+0x4c3>
movl   $0x0,-0x54(%rbp)
cmpl   $0x39,-0x54(%rbp)
jge    12a0 <read_frm_hdr+0x160>
mov    -0x10(%rbp),%rcx
lea    -0x5c(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%r8d
mov    %r8d,%edx
call   1060 <fread_bo@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
je     127b <read_frm_hdr+0x13b>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <read_frm_hdr+0x4c3>
mov    -0x5c(%rbp),%eax
and    $0xffff,%eax
mov    %ax,%dx
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1226 <read_frm_hdr+0xe6>
mov    -0x18(%rbp),%rax
movswl 0xe(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x10(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd4b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x18(%rbp),%rax
movswl 0x12(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x14(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd11(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movswl 0x1a(%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  0xcf8(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x1c(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xcd3(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
movswl 0x1e(%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  0xcb6(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x20(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xc91(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movswl 0x26(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x28(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xc53(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movswl 0x2a(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movswl 0x2c(%rax),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xc19(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xbeb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
call   1040 <atan2@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x60(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xba0(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1499 <read_frm_hdr+0x359>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    14d2 <read_frm_hdr+0x392>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x4c(%rbp),%xmm0
subss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x50(%rbp),%xmm0
subss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xb07(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movss  -0x38(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
call   1040 <atan2@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    156b <read_frm_hdr+0x42b>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
subss  -0x30(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
ucomiss -0x60(%rbp),%xmm0
jbe    15b4 <read_frm_hdr+0x474>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x60(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    15fc <read_frm_hdr+0x4bc>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_frm_hdr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r13
call   1030 <cmp_barker@plt>
test   %eax,%eax
js     1407 <read_frm_hdr+0x2c7>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r13,%rcx
mov    $0x4,%r8d
call   1060 <fread_bo@plt>
cmp    $0x4,%eax
jne    13eb <read_frm_hdr+0x2ab>
xor    %ebx,%ebx
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r13,%rcx
mov    $0x4,%r8d
call   1060 <fread_bo@plt>
cmp    $0x4,%eax
jne    13eb <read_frm_hdr+0x2ab>
movzwl 0xc(%rsp),%eax
mov    %ax,(%r15,%rbx,2)
add    $0x1,%rbx
cmp    $0x39,%rbx
jne    11a0 <read_frm_hdr+0x60>
movswl 0x1a(%r15),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe17(%rip),%xmm1
mulsd  %xmm1,%xmm0
movzwl 0x1c(%r15),%eax
and    $0x7fff,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe05(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movswl 0x1e(%r15),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
mulsd  %xmm1,%xmm2
movzwl 0x20(%r15),%eax
and    $0x7fff,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
xorpd  %xmm2,%xmm2
xorpd  %xmm3,%xmm3
pinsrw $0x1,0x26(%r15),%xmm3
pinsrw $0x3,0xe(%r15),%xmm3
psrad  $0x10,%xmm3
cvtdq2pd %xmm3,%xmm3
movzwl 0x28(%r15),%eax
movd   %eax,%xmm4
pinsrw $0x1,0x10(%r15),%xmm4
movdqa 0xd9a(%rip),%xmm5
pand   %xmm5,%xmm4
punpcklwd %xmm2,%xmm4
cvtdq2pd %xmm4,%xmm4
movapd 0xd96(%rip),%xmm6
mulpd  %xmm6,%xmm4
addpd  %xmm3,%xmm3
addpd  %xmm4,%xmm3
cvtpd2ps %xmm3,%xmm3
movapd %xmm3,0x30(%rsp)
xorpd  %xmm3,%xmm3
pinsrw $0x1,0x2a(%r15),%xmm3
pinsrw $0x3,0x12(%r15),%xmm3
psrad  $0x10,%xmm3
cvtdq2pd %xmm3,%xmm3
movzwl 0x2c(%r15),%eax
movd   %eax,%xmm4
pinsrw $0x1,0x14(%r15),%xmm4
pand   %xmm5,%xmm4
punpcklwd %xmm2,%xmm4
cvtdq2pd %xmm4,%xmm2
mulpd  %xmm6,%xmm2
addpd  %xmm3,%xmm3
addpd  %xmm2,%xmm3
cvtpd2ps %xmm3,%xmm2
movapd %xmm2,0x20(%rsp)
call   1040 <atan2@plt>
movss  0xd36(%rip),%xmm1
subss  %xmm0,%xmm1
movss  0xd2e(%rip),%xmm2
movaps %xmm1,%xmm0
addss  %xmm2,%xmm0
movss  0xd23(%rip),%xmm3
movaps %xmm3,%xmm2
cmpltss %xmm1,%xmm2
andps  %xmm2,%xmm0
andnps %xmm1,%xmm2
orps   %xmm0,%xmm2
movaps %xmm2,%xmm0
addss  %xmm3,%xmm0
xorps  %xmm3,%xmm3
movaps %xmm2,%xmm1
cmpltss %xmm3,%xmm1
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x30(%rsp),%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
subss  %xmm0,%xmm1
movaps 0x20(%rsp),%xmm2
movaps %xmm2,%xmm0
shufps $0x55,%xmm2,%xmm0
subss  %xmm0,%xmm2
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1040 <atan2@plt>
movss  0xcb7(%rip),%xmm3
subss  %xmm0,%xmm3
movaps %xmm3,%xmm0
movss  0xcb0(%rip),%xmm2
addss  %xmm2,%xmm0
movaps %xmm3,%xmm1
cmpltss 0xcac(%rip),%xmm1
andps  %xmm1,%xmm0
andnps %xmm3,%xmm1
orps   %xmm0,%xmm1
subss  0x10(%rsp),%xmm1
movss  0xc85(%rip),%xmm3
addss  %xmm1,%xmm3
movss  0xc81(%rip),%xmm0
cmpltss %xmm1,%xmm0
andps  %xmm0,%xmm3
andnps %xmm1,%xmm0
orps   %xmm3,%xmm0
addss  %xmm0,%xmm2
movaps %xmm0,%xmm1
cmpltss 0xc67(%rip),%xmm1
andps  %xmm1,%xmm2
andnps %xmm0,%xmm1
orps   %xmm2,%xmm1
movss  %xmm1,(%r14)
xor    %ebx,%ebx
jmp    143d <read_frm_hdr+0x2fd>
mov    0x2bee(%rip),%rax
mov    (%rax),%edi
lea    0xc8a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    143d <read_frm_hdr+0x2fd>
mov    $0xffffffff,%ebx
cmp    $0xfffffffe,%eax
je     1428 <read_frm_hdr+0x2e8>
cmp    $0xffffffff,%eax
jne    143d <read_frm_hdr+0x2fd>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xc22(%rip),%rsi
jmp    1438 <read_frm_hdr+0x2f8>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
lea    0xc31(%rip),%rsi
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Unable to find barker sequence.\0A\00"
@.str.1 = [28 x i8] c"Unable to read input file.\0A\00"
@.str.2 = [29 x i8] c"Error reading frame header.\0A\00"
define i32 @read_frm_hdr(i32* %0, i16* %1, i32* %2, float* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i16*
%8 = alloca i32*
%9 = alloca float*
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca float
store i32* %0, i32** %6
store i16* %1, i16** %7
store i32* %2, i32** %8
store float* %3, float** %9
store float 0.000000e+00, float* %10
store float 0.000000e+00, float* %11
store float 0x400921FB60000000, float* %23
%24 = load i32*, i32** %6
%25 = call i32 @cmp_barker(i32* %24)
store i32 %25, i32* %21
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %4
%28 = load i32, i32* %21
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %21
%35 = icmp eq i32 %34, -2
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
store i32 -1, i32* %5
br label %248
40: ; preds = %4
%41 = load i32*, i32** %8
%42 = load i32*, i32** %6
%43 = call i32 @fread_bo(i32* %41, i32 1, i32 4, i32* %42, i32 4)
%44 = icmp ne i32 4, %43
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %248
48: ; preds = %40
store i32 0, i32* %20
br label %49
49: ; preds = %67, %48
%50 = load i32, i32* %20
%51 = icmp slt i32 %50, 57
br i1 %51, label %52, label %70
52: ; preds = %49
%53 = load i32*, i32** %6
%54 = call i32 @fread_bo(i32* %22, i32 1, i32 4, i32* %53, i32 4)
%55 = icmp ne i32 4, %54
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %248
59: ; preds = %52
%60 = load i32, i32* %22
%61 = and i32 %60, 65535
%62 = trunc i32 %61 to i16
%63 = load i16*, i16** %7
%64 = load i32, i32* %20
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i16, i16* %63, i64 %65
store i16 %62, i16* %66
br label %67
67: ; preds = %59
%68 = load i32, i32* %20
%69 = add nsw i32 %68, 1
store i32 %69, i32* %20
br label %49
70: ; preds = %49
%71 = load i16*, i16** %7
%72 = getelementptr inbounds i16, i16* %71, i64 7
%73 = load i16, i16* %72
%74 = sext i16 %73 to i32
%75 = sitofp i32 %74 to double
%76 = load i16*, i16** %7
%77 = getelementptr inbounds i16, i16* %76, i64 8
%78 = load i16, i16* %77
%79 = sext i16 %78 to i32
%80 = and i32 %79, 32767
%81 = sitofp i32 %80 to double
%82 = fdiv double %81, 1.638400e+04
%83 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %75, double %82)
%84 = fptrunc double %83 to float
store float %84, float* %16
%85 = load i16*, i16** %7
%86 = getelementptr inbounds i16, i16* %85, i64 9
%87 = load i16, i16* %86
%88 = sext i16 %87 to i32
%89 = sitofp i32 %88 to double
%90 = load i16*, i16** %7
%91 = getelementptr inbounds i16, i16* %90, i64 10
%92 = load i16, i16* %91
%93 = sext i16 %92 to i32
%94 = and i32 %93, 32767
%95 = sitofp i32 %94 to double
%96 = fdiv double %95, 1.638400e+04
%97 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %89, double %96)
%98 = fptrunc double %97 to float
store float %98, float* %17
%99 = load i16*, i16** %7
%100 = getelementptr inbounds i16, i16* %99, i64 13
%101 = load i16, i16* %100
%102 = sext i16 %101 to i32
%103 = sitofp i32 %102 to double
%104 = fdiv double %103, 1.280000e+02
%105 = load i16*, i16** %7
%106 = getelementptr inbounds i16, i16* %105, i64 14
%107 = load i16, i16* %106
%108 = sext i16 %107 to i32
%109 = and i32 %108, 32767
%110 = sitofp i32 %109 to double
%111 = fdiv double %110, 4.194300e+06
%112 = fadd double %104, %111
%113 = fptrunc double %112 to float
store float %113, float* %14
%114 = load i16*, i16** %7
%115 = getelementptr inbounds i16, i16* %114, i64 15
%116 = load i16, i16* %115
%117 = sext i16 %116 to i32
%118 = sitofp i32 %117 to double
%119 = fdiv double %118, 1.280000e+02
%120 = load i16*, i16** %7
%121 = getelementptr inbounds i16, i16* %120, i64 16
%122 = load i16, i16* %121
%123 = sext i16 %122 to i32
%124 = and i32 %123, 32767
%125 = sitofp i32 %124 to double
%126 = fdiv double %125, 4.194300e+06
%127 = fadd double %119, %126
%128 = fptrunc double %127 to float
store float %128, float* %15
%129 = load i16*, i16** %7
%130 = getelementptr inbounds i16, i16* %129, i64 19
%131 = load i16, i16* %130
%132 = sext i16 %131 to i32
%133 = sitofp i32 %132 to double
%134 = load i16*, i16** %7
%135 = getelementptr inbounds i16, i16* %134, i64 20
%136 = load i16, i16* %135
%137 = sext i16 %136 to i32
%138 = and i32 %137, 32767
%139 = sitofp i32 %138 to double
%140 = fdiv double %139, 1.638400e+04
%141 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %133, double %140)
%142 = fptrunc double %141 to float
store float %142, float* %18
%143 = load i16*, i16** %7
%144 = getelementptr inbounds i16, i16* %143, i64 21
%145 = load i16, i16* %144
%146 = sext i16 %145 to i32
%147 = sitofp i32 %146 to double
%148 = load i16*, i16** %7
%149 = getelementptr inbounds i16, i16* %148, i64 22
%150 = load i16, i16* %149
%151 = sext i16 %150 to i32
%152 = and i32 %151, 32767
%153 = sitofp i32 %152 to double
%154 = fdiv double %153, 1.638400e+04
%155 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %147, double %154)
%156 = fptrunc double %155 to float
store float %156, float* %19
%157 = load float, float* %23
%158 = fpext float %157 to double
%159 = fdiv double %158, 2.000000e+00
%160 = load float, float* %14
%161 = load float, float* %15
%162 = call float @atan2(float %160, float %161)
%163 = fpext float %162 to double
%164 = fsub double %159, %163
%165 = fptrunc double %164 to float
store float %165, float* %11
%166 = load float, float* %11
%167 = fpext float %166 to double
%168 = load float, float* %23
%169 = fpext float %168 to double
%170 = fmul double 2.000000e+00, %169
%171 = fcmp ogt double %167, %170
br i1 %171, label %172, label %179
172: ; preds = %70
%173 = load float, float* %23
%174 = fpext float %173 to double
%175 = load float, float* %11
%176 = fpext float %175 to double
%177 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %174, double %176)
%178 = fptrunc double %177 to float
store float %178, float* %11
br label %179
179: ; preds = %172, %70
%180 = load float, float* %11
%181 = fpext float %180 to double
%182 = fcmp olt double %181, 0.000000e+00
br i1 %182, label %183, label %190
183: ; preds = %179
%184 = load float, float* %23
%185 = fpext float %184 to double
%186 = load float, float* %11
%187 = fpext float %186 to double
%188 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %185, double %187)
%189 = fptrunc double %188 to float
store float %189, float* %11
br label %190
190: ; preds = %183, %179
%191 = load float, float* %18
%192 = load float, float* %16
%193 = fsub float %191, %192
store float %193, float* %13
%194 = load float, float* %19
%195 = load float, float* %17
%196 = fsub float %194, %195
store float %196, float* %12
%197 = load float, float* %23
%198 = fpext float %197 to double
%199 = fdiv double %198, 2.000000e+00
%200 = load float, float* %13
%201 = load float, float* %12
%202 = call float @atan2(float %200, float %201)
%203 = fpext float %202 to double
%204 = fsub double %199, %203
%205 = fptrunc double %204 to float
store float %205, float* %10
%206 = load float, float* %10
%207 = fpext float %206 to double
%208 = fcmp olt double %207, 0.000000e+00
br i1 %208, label %209, label %216
209: ; preds = %190
%210 = load float, float* %23
%211 = fpext float %210 to double
%212 = load float, float* %10
%213 = fpext float %212 to double
%214 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %211, double %213)
%215 = fptrunc double %214 to float
store float %215, float* %10
br label %216
216: ; preds = %209, %190
%217 = load float, float* %10
%218 = load float, float* %11
%219 = fsub float %217, %218
%220 = load float*, float** %9
store float %219, float* %220
%221 = load float*, float** %9
%222 = load float, float* %221
%223 = load float, float* %23
%224 = fcmp ogt float %222, %223
br i1 %224, label %225, label %233
225: ; preds = %216
%226 = load float, float* %23
%227 = fpext float %226 to double
%228 = load float*, float** %9
%229 = load float, float* %228
%230 = fpext float %229 to double
%231 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %227, double %230)
%232 = fptrunc double %231 to float
store float %232, float* %228
br label %233
233: ; preds = %225, %216
%234 = load float*, float** %9
%235 = load float, float* %234
%236 = load float, float* %23
%237 = fneg float %236
%238 = fcmp olt float %235, %237
br i1 %238, label %239, label %247
239: ; preds = %233
%240 = load float, float* %23
%241 = fpext float %240 to double
%242 = load float*, float** %9
%243 = load float, float* %242
%244 = fpext float %243 to double
%245 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %241, double %244)
%246 = fptrunc double %245 to float
store float %246, float* %242
br label %247
247: ; preds = %239, %233
store i32 0, i32* %5
br label %248
248: ; preds = %247, %56, %45, %39
%249 = load i32, i32* %5
ret i32 %249
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Unable to find barker sequence.\0A\00"
@.str.1 = [28 x i8] c"Unable to read input file.\0A\00"
@.str.2 = [29 x i8] c"Error reading frame header.\0A\00"
define i32 @read_frm_hdr(i32* %0, i16* nocapture %1, i32* %2, float* nocapture writeonly %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @cmp_barker(i32* %0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %4
switch i32 %7, label %120 [
i32 -1, label %10
i32 -2, label %13
]
10: ; preds = %9
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %120
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %120
16: ; preds = %4
%17 = tail call i32 @fread_bo(i32* %2, i32 1, i32 4, i32* %0, i32 4)
%18 = icmp eq i32 %17, 4
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %120
22: ; preds = %16, %29
%23 = phi i64 [ %33, %29 ], [ 0, %16 ]
%24 = call i32 @fread_bo(i32* %5, i32 1, i32 4, i32* %0, i32 4)
%25 = icmp eq i32 %24, 4
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %120
29: ; preds = %22
%30 = load i32, i32* %5
%31 = trunc i32 %30 to i16
%32 = getelementptr inbounds i16, i16* %1, i64 %23
store i16 %31, i16* %32
%33 = add nuw nsw i64 %23, 1
%34 = icmp eq i64 %33, 57
br i1 %34, label %35, label %22
35: ; preds = %29
%36 = getelementptr inbounds i16, i16* %1, i64 7
%37 = load i16, i16* %36
%38 = getelementptr inbounds i16, i16* %1, i64 8
%39 = load i16, i16* %38
%40 = getelementptr inbounds i16, i16* %1, i64 9
%41 = load i16, i16* %40
%42 = getelementptr inbounds i16, i16* %1, i64 10
%43 = load i16, i16* %42
%44 = getelementptr inbounds i16, i16* %1, i64 13
%45 = load i16, i16* %44
%46 = sitofp i16 %45 to double
%47 = fmul double %46, 7.812500e-03
%48 = getelementptr inbounds i16, i16* %1, i64 14
%49 = load i16, i16* %48
%50 = and i16 %49, 32767
%51 = uitofp i16 %50 to double
%52 = fdiv double %51, 4.194300e+06
%53 = fadd double %47, %52
%54 = fptrunc double %53 to float
%55 = getelementptr inbounds i16, i16* %1, i64 15
%56 = load i16, i16* %55
%57 = sitofp i16 %56 to double
%58 = fmul double %57, 7.812500e-03
%59 = getelementptr inbounds i16, i16* %1, i64 16
%60 = load i16, i16* %59
%61 = and i16 %60, 32767
%62 = uitofp i16 %61 to double
%63 = fdiv double %62, 4.194300e+06
%64 = fadd double %58, %63
%65 = fptrunc double %64 to float
%66 = getelementptr inbounds i16, i16* %1, i64 19
%67 = load i16, i16* %66
%68 = insertelement <2 x i16> poison, i16 %67, i64 0
%69 = insertelement <2 x i16> %68, i16 %37, i64 1
%70 = sitofp <2 x i16> %69 to <2 x double>
%71 = getelementptr inbounds i16, i16* %1, i64 20
%72 = load i16, i16* %71
%73 = insertelement <2 x i16> poison, i16 %72, i64 0
%74 = insertelement <2 x i16> %73, i16 %39, i64 1
%75 = and <2 x i16> %74, <i16 32767, i16 32767>
%76 = uitofp <2 x i16> %75 to <2 x double>
%77 = fmul <2 x double> %76, <double 0x3F10000000000000, double 0x3F10000000000000>
%78 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %70, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %77)
%79 = fptrunc <2 x double> %78 to <2 x float>
%80 = getelementptr inbounds i16, i16* %1, i64 21
%81 = load i16, i16* %80
%82 = insertelement <2 x i16> poison, i16 %81, i64 0
%83 = insertelement <2 x i16> %82, i16 %41, i64 1
%84 = sitofp <2 x i16> %83 to <2 x double>
%85 = getelementptr inbounds i16, i16* %1, i64 22
%86 = load i16, i16* %85
%87 = insertelement <2 x i16> poison, i16 %86, i64 0
%88 = insertelement <2 x i16> %87, i16 %43, i64 1
%89 = and <2 x i16> %88, <i16 32767, i16 32767>
%90 = uitofp <2 x i16> %89 to <2 x double>
%91 = fmul <2 x double> %90, <double 0x3F10000000000000, double 0x3F10000000000000>
%92 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %84, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %91)
%93 = fptrunc <2 x double> %92 to <2 x float>
%94 = call float @atan2(float %54, float %65)
%95 = fsub float 0x3FF921FB60000000, %94
%96 = fcmp ogt float %95, 0x401921FB60000000
%97 = fadd float %95, 0xC01921FB60000000
%98 = select i1 %96, float %97, float %95
%99 = fcmp olt float %98, 0.000000e+00
%100 = fadd float %98, 0x401921FB60000000
%101 = select i1 %99, float %100, float %98
%102 = shufflevector <2 x float> %79, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%103 = fsub <2 x float> %79, %102
%104 = extractelement <2 x float> %103, i64 0
%105 = shufflevector <2 x float> %93, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%106 = fsub <2 x float> %93, %105
%107 = extractelement <2 x float> %106, i64 0
%108 = call float @atan2(float %104, float %107)
%109 = fsub float 0x3FF921FB60000000, %108
%110 = fcmp olt float %109, 0.000000e+00
%111 = fadd float %109, 0x401921FB60000000
%112 = select i1 %110, float %111, float %109
%113 = fsub float %112, %101
%114 = fcmp ogt float %113, 0x400921FB60000000
%115 = fadd float %113, 0xC01921FB60000000
%116 = select i1 %114, float %115, float %113
%117 = fcmp olt float %116, 0xC00921FB60000000
%118 = fadd float %116, 0x401921FB60000000
%119 = select i1 %117, float %118, float %116
store float %119, float* %3
br label %120
120: ; preds = %10, %13, %9, %35, %26, %19
%121 = phi i32 [ -1, %19 ], [ -1, %26 ], [ 0, %35 ], [ -1, %9 ], [ -1, %13 ], [ -1, %10 ]
ret i32 %121
}