#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*/ exit(int);
double fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fshift(float *, float *, int, double, float);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
double strtod(char *, char **);
int main(int argc, char *argv[]) {
  int numread;
  double shift;
  float indata[16384], outdata[16384 + 1], overlap = 0.0;
  char *infilenm = NULL, *outfilenm = NULL;
  FILE *infile = NULL, *outfile = NULL, *textout = NULL;
  textout = (argc == 3) ? stderr : stdout;
  if (argc == 3 || argc == 4) {
    shift = strtod(argv[1], (char **)NULL);
    if (shift <= -1.0 || shift >= 1.0) {
      fprintf(textout, "\nbins_to_shift must be between -1.0 and 1.0.");
      fprintf(textout, "  Exiting.\n\n");
      exit(-1);
    }
    infilenm = (char *)malloc(strlen(argv[2]) + 1);
    strcpy(infilenm, argv[2]);
    fprintf(textout, "\nShifting data from \"%s\" by %f bin.\n\n", infilenm,
            shift);
    if (NULL == (infile = fopen(infilenm, "rb"))) {
      fprintf(textout, "\nCan't open \"%s\".  Exiting.\n\n", infilenm);
      exit(-1);
    }
    if (argc == 4) {
      outfilenm = (char *)malloc(strlen(argv[3]) + 1);
      strcpy(outfilenm, argv[3]);
      fprintf(textout, "Shifted data will be placed in \"%s\".\n\n", outfilenm);
      if (NULL == (outfile = fopen(outfilenm, "wb"))) {
        fprintf(textout, "\nCan't open \"%s\".  Exiting.\n\n", outfilenm);
        exit(-1);
      }
    } else {
      outfile = stdout;
    }
  } else {
    printf("\nUsage:  shiftdata bins_to_shift infile [outfile]\n\n");
    printf("   This routine is used to shift a file of single\n");
    printf("   precision floating point data to the left or right\n");
    printf("   by up to 1 bin.  This allows you to patch two time\n");
    printf("   series together with the correct phase, assuming\n");
    printf("   that the data point durations are the same.\n");
    printf("   The arguments are:\n");
    printf("      bins_to_shift (double):  The amount to shift the\n");
    printf("         data.  Negative shifts left, positive shifts\n");
    printf("         right.  For example, if I have the time series\n");
    printf("         {1.0, 2,0, 1.0} and I give a bins_to_shift of\n");
    printf("         -0.3, my new time series would look like\n");
    printf("         {0.3, 1.3, 1.7, 0.7}.  Notice that my time\n");
    printf("         series increased in length by one and that I\n");
    printf("         added some noise due to the fact that I am\n");
    printf("         performing a type of two-bin average.\n");
    printf("      infile (string):  The data file to shift.\n");
    printf("      outfile (string):  An optional output file.  The\n");
    printf("         default behavior sends the raw output to STDOUT\n\n");
    exit(0);
  }
  do {
    numread = fread(indata, sizeof(float), 16384, infile);
    fshift(indata, outdata, numread, shift, overlap);
    overlap = outdata[numread];
    fwrite(outdata, sizeof(float), (unsigned long)numread, outfile);
  } while (numread == 16384);
  if (fabs(shift) > 1.0e-7)
    fwrite(&overlap, sizeof(float), 1, outfile);
  free(infilenm);
  fclose(infile);
  if (argc == 4) {
    fclose(outfile);
    free(outfilenm);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20034(%rbp)
ff
movq   $0x0,-0x20040(%rbp)
movq   $0x0,-0x20048(%rbp)
movq   $0x0,-0x20050(%rbp)
movq   $0x0,-0x20058(%rbp)
movq   $0x0,-0x20060(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    124b <main+0x7b>
mov    0x2da4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20068(%rbp)
jmp    125c <main+0x8c>
mov    0x2d86(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20068(%rbp)
mov    -0x20068(%rbp),%rax
mov    %rax,-0x20060(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     127e <main+0xae>
cmpl   $0x4,-0x8(%rbp)
jne    1458 <main+0x288>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xd64(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    12be <main+0xee>
movsd  -0x20(%rbp),%xmm0
movsd  0xd54(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12f2 <main+0x122>
mov    -0x20060(%rbp),%rdi
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20060(%rbp),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x20040(%rbp)
mov    -0x20040(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x20060(%rbp),%rdi
mov    -0x20040(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
lea    0xd1d(%rip),%rsi
mov    $0x1,%al
call   10a0 <fprintf@plt>
mov    -0x20040(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20050(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1395 <main+0x1c5>
mov    -0x20060(%rbp),%rdi
mov    -0x20040(%rbp),%rdx
lea    0xd02(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1442 <main+0x272>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x20048(%rbp)
mov    -0x20048(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x20060(%rbp),%rdi
mov    -0x20048(%rbp),%rdx
lea    0xcbc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20048(%rbp),%rdi
lea    0xcce(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20058(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    143d <main+0x26d>
mov    -0x20060(%rbp),%rdi
mov    -0x20048(%rbp),%rdx
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    1453 <main+0x283>
mov    0x2b8f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20058(%rbp)
jmp    1543 <main+0x373>
lea    0xc6f(%rip),%rdi
call   1090 <printf@plt>
lea    0xc97(%rip),%rdi
call   1090 <printf@plt>
lea    0xcbe(%rip),%rdi
call   1090 <printf@plt>
lea    0xce9(%rip),%rdi
call   1090 <printf@plt>
lea    0xd14(%rip),%rdi
call   1090 <printf@plt>
lea    0xd3d(%rip),%rdi
call   1090 <printf@plt>
lea    0xd61(%rip),%rdi
call   1090 <printf@plt>
lea    0xd6c(%rip),%rdi
call   1090 <printf@plt>
lea    0xd98(%rip),%rdi
call   1090 <printf@plt>
lea    0xdc3(%rip),%rdi
call   1090 <printf@plt>
lea    0xdf0(%rip),%rdi
call   1090 <printf@plt>
lea    0xe1c(%rip),%rdi
call   1090 <printf@plt>
lea    0xe43(%rip),%rdi
call   1090 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1090 <printf@plt>
lea    0xe97(%rip),%rdi
call   1090 <printf@plt>
lea    0xec0(%rip),%rdi
call   1090 <printf@plt>
lea    0xee4(%rip),%rdi
call   1090 <printf@plt>
lea    0xf09(%rip),%rdi
call   1090 <printf@plt>
lea    0xf35(%rip),%rdi
call   1090 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    1548 <main+0x378>
lea    -0x10020(%rbp),%rdi
mov    -0x20050(%rbp),%rcx
mov    $0x4,%esi
mov    $0x4000,%edx
call   1050 <fread@plt>
mov    %eax,-0x14(%rbp)
lea    -0x10020(%rbp),%rdi
lea    -0x20030(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
movss  -0x20034(%rbp),%xmm1
ff
call   10c0 <fshift@plt>
movslq -0x14(%rbp),%rax
movss  -0x20030(%rbp,%rax,4),%xmm0
fd ff
movss  %xmm0,-0x20034(%rbp)
ff
lea    -0x20030(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    %eax,%edx
mov    -0x20058(%rbp),%rcx
mov    $0x4,%esi
call   10f0 <fwrite@plt>
cmpl   $0x4000,-0x14(%rbp)
je     1548 <main+0x378>
movsd  -0x20(%rbp),%xmm0
movaps 0xa49(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xa2d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    160a <main+0x43a>
mov    -0x20058(%rbp),%rcx
lea    -0x20034(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
mov    -0x20040(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20050(%rbp),%rdi
call   1070 <fclose@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1644 <main+0x474>
mov    -0x20058(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20048(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20048,%rsp
mov    %rsi,%rbp
mov    %edi,%r12d
cmp    $0x3,%edi
jne    11f5 <main+0x25>
mov    0x2ded(%rip),%rax
jmp    11fc <main+0x2c>
mov    0x2ddc(%rip),%rax
lea    -0x3(%r12),%ecx
cmp    $0x1,%ecx
ja     12ae <main+0xde>
mov    (%rax),%r15
mov    0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <strtod@plt>
movsd  0xde0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1399 <main+0x1c9>
ucomisd 0xdd6(%rip),%xmm0
jae    1399 <main+0x1c9>
mov    0x10(%rbp),%rdi
movapd %xmm0,0x20(%rsp)
call   1090 <strlen@plt>
lea    0x1(%rax),%rdi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xdf7(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
movaps 0x20(%rsp),%xmm0
mov    $0x1,%al
call   10a0 <fprintf@plt>
lea    0xe04(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
jne    13d5 <main+0x205>
lea    0xdef(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
lea    0xe40(%rip),%rdi
call   1050 <puts@plt>
lea    0xe66(%rip),%rdi
call   1050 <puts@plt>
lea    0xe90(%rip),%rdi
call   1050 <puts@plt>
lea    0xeba(%rip),%rdi
call   1050 <puts@plt>
lea    0xee2(%rip),%rdi
call   1050 <puts@plt>
lea    0xf05(%rip),%rdi
call   1050 <puts@plt>
lea    0xf0f(%rip),%rdi
call   1050 <puts@plt>
lea    0xf3a(%rip),%rdi
call   1050 <puts@plt>
lea    0xf64(%rip),%rdi
call   1050 <puts@plt>
lea    0xf90(%rip),%rdi
call   1050 <puts@plt>
lea    0xfbb(%rip),%rdi
call   1050 <puts@plt>
lea    0xfe1(%rip),%rdi
call   1050 <puts@plt>
lea    0x1009(%rip),%rdi
call   1050 <puts@plt>
lea    0x1033(%rip),%rdi
call   1050 <puts@plt>
lea    0x105b(%rip),%rdi
call   1050 <puts@plt>
lea    0x107e(%rip),%rdi
call   1050 <puts@plt>
lea    0x10a2(%rip),%rdi
call   1050 <puts@plt>
lea    0x10cd(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xc90(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10f0 <fwrite@plt>
lea    0xcde(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10f0 <fwrite@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    %rax,%r13
cmp    $0x4,%r12d
jne    1439 <main+0x269>
mov    0x18(%rbp),%rdi
call   1090 <strlen@plt>
lea    0x1(%rax),%rdi
call   10b0 <malloc@plt>
mov    0x18(%rbp),%rsi
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xc9e(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xcb1(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
jne    1451 <main+0x281>
lea    0xc58(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
jmp    129d <main+0xcd>
mov    %rbx,0x18(%rsp)
mov    0x2b93(%rip),%rax
mov    (%rax),%r14
xor    %eax,%eax
mov    %rax,0x10(%rsp)
jmp    145e <main+0x28e>
mov    %rax,%r14
mov    %rbp,0x10(%rsp)
mov    %rbx,0x18(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0x10040(%rsp),%r15
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x4000,%edx
mov    %r13,%rcx
call   1060 <fread@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
movaps 0x20(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   10c0 <fshift@plt>
movslq %ebx,%rbx
movss  0x30(%rsp,%rbx,4),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
cmp    $0x4000,%ebx
je     1480 <main+0x2b0>
movapd 0x20(%rsp),%xmm1
andpd  0xb3a(%rip),%xmm1
movss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
ucomisd 0xb16(%rip),%xmm1
jbe    1513 <main+0x343>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1080 <fclose@plt>
cmp    $0x4,%r12d
mov    0x10(%rsp),%rbx
jne    1540 <main+0x370>
mov    %r14,%rdi
call   1080 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32* null
@stdout = global i32* null
@.str = [45 x i8] c"\0Abins_to_shift must be between -1.0 and 1.0.\00"
@.str.1 = [13 x i8] c" Exiting.\0A\0A\00"
@.str.2 = [38 x i8] c"\0AShifting data from \22%s\22 by %f bin.\0A\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [30 x i8] c"\0ACan't open \22%s\22. Exiting.\0A\0A\00"
@.str.5 = [39 x i8] c"Shifted data will be placed in \22%s\22.\0A\0A\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [52 x i8] c"\0AUsage: shiftdata bins_to_shift infile [outfile]\0A\0A\00"
@.str.8 = [51 x i8] c" This routine is used to shift a file of single\0A\00"
@.str.9 = [55 x i8] c" precision floating point data to the left or right\0A\00"
@.str.10 = [55 x i8] c" by up to 1 bin. This allows you to patch two time\0A\00"
@.str.11 = [53 x i8] c" series together with the correct phase, assuming\0A\00"
@.str.12 = [48 x i8] c" that the data point durations are the same.\0A\00"
@.str.13 = [23 x i8] c" The arguments are:\0A\00"
@.str.14 = [56 x i8] c" bins_to_shift (double): The amount to shift the\0A\00"
@.str.15 = [55 x i8] c" data. Negative shifts left, positive shifts\0A\00"
@.str.16 = [57 x i8] c" right. For example, if I have the time series\0A\00"
@.str.17 = [56 x i8] c" {1.0, 2,0, 1.0} and I give a bins_to_shift of\0A\00"
@.str.18 = [51 x i8] c" -0.3, my new time series would look like\0A\00"
@.str.19 = [53 x i8] c" {0.3, 1.3, 1.7, 0.7}. Notice that my time\0A\00"
@.str.20 = [55 x i8] c" series increased in length by one and that I\0A\00"
@.str.21 = [53 x i8] c" added some noise due to the fact that I am\0A\00"
@.str.22 = [48 x i8] c" performing a type of two-bin average.\0A\00"
@.str.23 = [49 x i8] c" infile (string): The data file to shift.\0A\00"
@.str.24 = [56 x i8] c" outfile (string): An optional output file. The\0A\00"
@.str.25 = [59 x i8] c" default behavior sends the raw output to STDOUT\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca [16384 x float]
%9 = alloca [16385 x float]
%10 = alloca float
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32* null, i32** %13
store i32* null, i32** %14
store i32* null, i32** %15
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load i32*, i32** @stderr
br label %22
20: ; preds = %2
%21 = load i32*, i32** @stdout
br label %22
22: ; preds = %20, %18
%23 = phi i32* [ %19, %18 ], [ %21, %20 ]
store i32* %23, i32** %15
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 3
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %101
29: ; preds = %26, %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call double @strtod(i8* %32, i8** null)
store double %33, double* %7
%34 = load double, double* %7
%35 = fcmp ole double %34, -1.000000e+00
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = load double, double* %7
%38 = fcmp oge double %37, 1.000000e+00
br i1 %38, label %39, label %45
39: ; preds = %36, %29
%40 = load i32*, i32** %15
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%42 = load i32*, i32** %15
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %36
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i64 @strlen(i8* %48)
%50 = add nsw i64 %49, 1
%51 = call i64 @malloc(i64 %50)
%52 = inttoptr i64 %51 to i8*
store i8* %52, i8** %11
%53 = load i8*, i8** %11
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 @strcpy(i8* %53, i8* %56)
%58 = load i32*, i32** %15
%59 = load i8*, i8** %11
%60 = load double, double* %7
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %59, double %60)
%62 = load i8*, i8** %11
%63 = call i32* @fopen(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %63, i32** %13
%64 = icmp eq i32* null, %63
br i1 %64, label %65, label %70
65: ; preds = %45
%66 = load i32*, i32** %15
%67 = load i8*, i8** %11
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 -1)
unreachable
70: ; preds = %45
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 4
br i1 %72, label %73, label %98
73: ; preds = %70
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 3
%76 = load i8*, i8** %75
%77 = call i64 @strlen(i8* %76)
%78 = add nsw i64 %77, 1
%79 = call i64 @malloc(i64 %78)
%80 = inttoptr i64 %79 to i8*
store i8* %80, i8** %12
%81 = load i8*, i8** %12
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 3
%84 = load i8*, i8** %83
%85 = call i32 @strcpy(i8* %81, i8* %84)
%86 = load i32*, i32** %15
%87 = load i8*, i8** %12
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = load i8*, i8** %12
%90 = call i32* @fopen(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %90, i32** %14
%91 = icmp eq i32* null, %90
br i1 %91, label %92, label %97
92: ; preds = %73
%93 = load i32*, i32** %15
%94 = load i8*, i8** %12
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %94)
%96 = call i32 @exit(i32 -1)
unreachable
97: ; preds = %73
br label %100
98: ; preds = %70
%99 = load i32*, i32** @stdout
store i32* %99, i32** %14
br label %100
100: ; preds = %98, %97
br label %122
101: ; preds = %26
%102 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%103 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%104 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
%105 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%106 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
%107 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
%108 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%109 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.14, i64 0, i64 0))
%110 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.15, i64 0, i64 0))
%111 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.16, i64 0, i64 0))
%112 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.17, i64 0, i64 0))
%113 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.18, i64 0, i64 0))
%114 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.19, i64 0, i64 0))
%115 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.20, i64 0, i64 0))
%116 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.21, i64 0, i64 0))
%117 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.22, i64 0, i64 0))
%118 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.23, i64 0, i64 0))
%119 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.24, i64 0, i64 0))
%120 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.25, i64 0, i64 0))
%121 = call i32 @exit(i32 0)
unreachable
122: ; preds = %100
br label %123
123: ; preds = %143, %122
%124 = getelementptr inbounds [16384 x float], [16384 x float]* %8, i64 0, i64 0
%125 = load i32*, i32** %13
%126 = call i32 @fread(float* %124, i32 4, i32 16384, i32* %125)
store i32 %126, i32* %6
%127 = getelementptr inbounds [16384 x float], [16384 x float]* %8, i64 0, i64 0
%128 = getelementptr inbounds [16385 x float], [16385 x float]* %9, i64 0, i64 0
%129 = load i32, i32* %6
%130 = load double, double* %7
%131 = load float, float* %10
%132 = call i32 @fshift(float* %127, float* %128, i32 %129, double %130, float %131)
%133 = load i32, i32* %6
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [16385 x float], [16385 x float]* %9, i64 0, i64 %134
%136 = load float, float* %135
store float %136, float* %10
%137 = getelementptr inbounds [16385 x float], [16385 x float]* %9, i64 0, i64 0
%138 = load i32, i32* %6
%139 = sext i32 %138 to i64
%140 = trunc i64 %139 to i32
%141 = load i32*, i32** %14
%142 = call i32 @fwrite(float* %137, i32 4, i32 %140, i32* %141)
br label %143
143: ; preds = %123
%144 = load i32, i32* %6
%145 = icmp eq i32 %144, 16384
br i1 %145, label %123, label %146
146: ; preds = %143
%147 = load double, double* %7
%148 = call double @llvm.fabs.f64(double %147)
%149 = fcmp ogt double %148, 0x3E7AD7F29ABCAF48
br i1 %149, label %150, label %153
150: ; preds = %146
%151 = load i32*, i32** %14
%152 = call i32 @fwrite(float* %10, i32 4, i32 1, i32* %151)
br label %153
153: ; preds = %150, %146
%154 = load i8*, i8** %11
%155 = call i32 @free(i8* %154)
%156 = load i32*, i32** %13
%157 = call i32 @fclose(i32* %156)
%158 = load i32, i32* %4
%159 = icmp eq i32 %158, 4
br i1 %159, label %160, label %165
160: ; preds = %153
%161 = load i32*, i32** %14
%162 = call i32 @fclose(i32* %161)
%163 = load i8*, i8** %12
%164 = call i32 @free(i8* %163)
br label %165
165: ; preds = %160, %153
%166 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32* null
@stdout = global i32* null
@.str = [45 x i8] c"\0Abins_to_shift must be between -1.0 and 1.0.\00"
@.str.1 = [13 x i8] c" Exiting.\0A\0A\00"
@.str.2 = [38 x i8] c"\0AShifting data from \22%s\22 by %f bin.\0A\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [30 x i8] c"\0ACan't open \22%s\22. Exiting.\0A\0A\00"
@.str.5 = [39 x i8] c"Shifted data will be placed in \22%s\22.\0A\0A\00"
@.str.6 = [3 x i8] c"wb\00"
@str = [51 x i8] c"\0AUsage: shiftdata bins_to_shift infile [outfile]\0A\00"
@str.26 = [50 x i8] c" This routine is used to shift a file of single\00"
@str.27 = [54 x i8] c" precision floating point data to the left or right\00"
@str.28 = [54 x i8] c" by up to 1 bin. This allows you to patch two time\00"
@str.29 = [52 x i8] c" series together with the correct phase, assuming\00"
@str.30 = [47 x i8] c" that the data point durations are the same.\00"
@str.31 = [22 x i8] c" The arguments are:\00"
@str.32 = [55 x i8] c" bins_to_shift (double): The amount to shift the\00"
@str.33 = [54 x i8] c" data. Negative shifts left, positive shifts\00"
@str.34 = [56 x i8] c" right. For example, if I have the time series\00"
@str.35 = [55 x i8] c" {1.0, 2,0, 1.0} and I give a bins_to_shift of\00"
@str.36 = [50 x i8] c" -0.3, my new time series would look like\00"
@str.37 = [52 x i8] c" {0.3, 1.3, 1.7, 0.7}. Notice that my time\00"
@str.38 = [54 x i8] c" series increased in length by one and that I\00"
@str.39 = [52 x i8] c" added some noise due to the fact that I am\00"
@str.40 = [47 x i8] c" performing a type of two-bin average.\00"
@str.41 = [48 x i8] c" infile (string): The data file to shift.\00"
@str.42 = [55 x i8] c" outfile (string): An optional output file. The\00"
@str.43 = [58 x i8] c" default behavior sends the raw output to STDOUT\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16384 x float]
%4 = alloca [16385 x float]
%5 = alloca float
%6 = bitcast [16384 x float]* %3 to i8*
%7 = bitcast [16385 x float]* %4 to i8*
%8 = bitcast float* %5 to i8*
%9 = icmp eq i32 %0, 3
%10 = load i32*, i32** @stderr
%11 = load i32*, i32** @stdout
%12 = select i1 %9, i32* %10, i32* %11
%13 = icmp eq i32 %0, 4
%14 = add i32 %0, -3
%15 = icmp ult i32 %14, 2
br i1 %15, label %16, label %60
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call double @strtod(i8* nocapture %18, i8** null)
%20 = fcmp ole double %19, -1.000000e+00
%21 = fcmp oge double %19, 1.000000e+00
%22 = or i1 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = tail call i64 bitcast (i32 (float*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 44, i64 1, i32* %12)
%25 = tail call i64 bitcast (i32 (float*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 12, i64 1, i32* %12)
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %16
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i64 @strlen(i8* dereferenceable(1) %29)
%31 = add nsw i64 %30, 1
%32 = tail call i64 @malloc(i64 %31)
%33 = inttoptr i64 %32 to i8*
%34 = load i8*, i8** %28
%35 = tail call i32 @strcpy(i8* %33, i8* %34)
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %33, double %19)
%37 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %27
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%41 = tail call i32 @exit(i32 -1)
unreachable
42: ; preds = %27
br i1 %13, label %43, label %58
43: ; preds = %42
%44 = getelementptr inbounds i8*, i8** %1, i64 3
%45 = load i8*, i8** %44
%46 = tail call i64 @strlen(i8* dereferenceable(1) %45)
%47 = add nsw i64 %46, 1
%48 = tail call i64 @malloc(i64 %47)
%49 = inttoptr i64 %48 to i8*
%50 = load i8*, i8** %44
%51 = tail call i32 @strcpy(i8* %49, i8* %50)
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%53 = tail call i32* @fopen(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %81
55: ; preds = %43
%56 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%57 = tail call i32 @exit(i32 -1)
unreachable
58: ; preds = %42
%59 = load i32*, i32** @stdout
br label %81
60: ; preds = %2
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.26, i64 0, i64 0))
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.27, i64 0, i64 0))
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.28, i64 0, i64 0))
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.29, i64 0, i64 0))
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.30, i64 0, i64 0))
%67 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.31, i64 0, i64 0))
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.32, i64 0, i64 0))
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.33, i64 0, i64 0))
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.34, i64 0, i64 0))
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.35, i64 0, i64 0))
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.36, i64 0, i64 0))
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.37, i64 0, i64 0))
%74 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.38, i64 0, i64 0))
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.39, i64 0, i64 0))
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.40, i64 0, i64 0))
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.41, i64 0, i64 0))
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.42, i64 0, i64 0))
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.43, i64 0, i64 0))
%80 = tail call i32 @exit(i32 0)
unreachable
81: ; preds = %58, %43
%82 = phi i8* [ %49, %43 ], [ null, %58 ]
%83 = phi i32* [ %53, %43 ], [ %59, %58 ]
%84 = getelementptr inbounds [16384 x float], [16384 x float]* %3, i64 0, i64 0
%85 = getelementptr inbounds [16385 x float], [16385 x float]* %4, i64 0, i64 0
br label %86
86: ; preds = %86, %81
%87 = phi float [ %92, %86 ], [ 0.000000e+00, %81 ]
%88 = call i32 @fread(float* %84, i32 4, i32 16384, i32* %37)
%89 = call i32 @fshift(float* %84, float* %85, i32 %88, double %19, float %87)
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds [16385 x float], [16385 x float]* %4, i64 0, i64 %90
%92 = load float, float* %91
%93 = call i32 @fwrite(float* %85, i32 4, i32 %88, i32* %83)
%94 = icmp eq i32 %88, 16384
br i1 %94, label %86, label %95
95: ; preds = %86
store float %92, float* %5
%96 = call double @llvm.fabs.f64(double %19)
%97 = fcmp ogt double %96, 0x3E7AD7F29ABCAF48
br i1 %97, label %98, label %100
98: ; preds = %95
%99 = call i32 @fwrite(float* %5, i32 4, i32 1, i32* %83)
br label %100
100: ; preds = %98, %95
%101 = call i32 @free(i8* %33)
%102 = call i32 @fclose(i32* %37)
br i1 %13, label %103, label %106
103: ; preds = %100
%104 = call i32 @fclose(i32* %83)
%105 = call i32 @free(i8* %82)
br label %106
106: ; preds = %103, %100
%107 = call i32 @exit(i32 0)
unreachable
}