#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 dmdelay(float, float, double);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int *dmshift(float f1, double df, int nchans, int nbands, double dm,
             double refrf, double tsamp, float frequency[]) {
  int i, cpb, *shift;
  float fi;
  printf("%f\n", *(frequency));
  printf("1\n");
  shift = (int *)malloc(nchans * sizeof(int));
  fi = f1;
  printf("%f\n", fi);
  cpb = nchans / nbands;
  printf("%d %d %d\n", cpb, nchans, nbands);
  if (frequency[0] != 0.0)
    f1 = frequency[0];
  printf("%f\n", frequency[0]);
  for (i = 0; i < nchans; i++) {
    if (refrf > 0.0)
      f1 = refrf;
    printf("%d\n", i);
    if (frequency[0] != 0.0)
      fi = frequency[0];
    shift[i] = (int)(dmdelay(fi, f1, dm) / tsamp);
    fi += df;
    if (!((i + 1) % cpb))
      f1 += (double)cpb * df;
  }
  return shift;
}


x86 assembly (clang, -O0):
<dmshift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11fc <dmshift+0xcc>
jp     11fc <dmshift+0xcc>
jmp    1209 <dmshift+0xd9>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1325 <dmshift+0x1f5>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1256 <dmshift+0x126>
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    128b <dmshift+0x15b>
jp     128b <dmshift+0x15b>
jmp    1298 <dmshift+0x168>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1050 <dmdelay@plt>
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x10(%rbp),%xmm1
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x40(%rbp)
cmp    $0x0,%edx
jne    1312 <dmshift+0x1e2>
cvtsi2sdl -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1317 <dmshift+0x1e7>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    122a <dmshift+0xfa>
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmshift>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r14
movsd  %xmm4,0x50(%rsp)
movsd  %xmm3,0x38(%rsp)
movsd  %xmm2,0x48(%rsp)
mov    %esi,%ebx
mov    %edi,%r15d
movsd  %xmm1,0x30(%rsp)
movaps %xmm0,(%rsp)
movss  (%rdx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8f(%rip),%rbp
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r12
movaps (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15d,%eax
cltd
idiv   %ebx
mov    %eax,%r13d
lea    0xe4b(%rip),%rdi
mov    %eax,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
movss  (%r14),%xmm0
movaps %xmm0,0x20(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
test   %r15d,%r15d
jle    130f <dmshift+0x1cf>
xorps  %xmm1,%xmm1
movaps 0x20(%rsp),%xmm2
movaps %xmm2,%xmm0
cmpneqss %xmm1,%xmm0
andps  %xmm0,%xmm2
andnps (%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,0x1c(%rsp)
orps   %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
mov    %r15d,%ebp
lea    0xde6(%rip),%r15
mulsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x40(%rsp)
xor    %ebx,%ebx
jmp    1278 <dmshift+0x138>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x20(%rsp),%xmm1
movaps (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x30(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm1,%xmm0
cmp    %rbx,%rbp
je     130f <dmshift+0x1cf>
movsd  0x38(%rsp),%xmm1
ucomisd 0xd82(%rip),%xmm1
movss  0x1c(%rsp),%xmm1
ja     1291 <dmshift+0x151>
movaps %xmm0,%xmm1
movss  %xmm1,0x20(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  (%r14),%xmm1
movaps %xmm1,%xmm0
cmpneqss 0xd4c(%rip),%xmm0
andps  %xmm0,%xmm1
andnps (%rsp),%xmm0
orps   %xmm1,%xmm0
movaps %xmm0,(%rsp)
movss  0x20(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
call   1060 <dmdelay@plt>
divsd  0x50(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
mov    %ebx,%eax
cltd
idiv   %r13d
test   %edx,%edx
jne    1250 <dmshift+0x110>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x40(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
jmp    1256 <dmshift+0x116>
mov    %r12,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [3 x i8] c"1\0A\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32* @dmshift(float %0, double %1, i32 %2, i32 %3, double %4, double %5, double %6, float* %7) {
%9 = alloca float
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca float*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca float
store float %0, float* %9
store double %1, double* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
store float* %7, float** %16
%21 = load float*, float** %16
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %19
%32 = load float, float* %9
store float %32, float* %20
%33 = load float, float* %20
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %34)
%36 = load i32, i32* %11
%37 = load i32, i32* %12
%38 = sdiv i32 %36, %37
store i32 %38, i32* %18
%39 = load i32, i32* %18
%40 = load i32, i32* %11
%41 = load i32, i32* %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40, i32 %41)
%43 = load float*, float** %16
%44 = getelementptr inbounds float, float* %43, i64 0
%45 = load float, float* %44
%46 = fpext float %45 to double
%47 = fcmp une double %46, 0.000000e+00
br i1 %47, label %48, label %52
48: ; preds = %8
%49 = load float*, float** %16
%50 = getelementptr inbounds float, float* %49, i64 0
%51 = load float, float* %50
store float %51, float* %9
br label %52
52: ; preds = %48, %8
%53 = load float*, float** %16
%54 = getelementptr inbounds float, float* %53, i64 0
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %56)
store i32 0, i32* %17
br label %58
58: ; preds = %111, %52
%59 = load i32, i32* %17
%60 = load i32, i32* %11
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %114
62: ; preds = %58
%63 = load double, double* %14
%64 = fcmp ogt double %63, 0.000000e+00
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load double, double* %14
%67 = fptrunc double %66 to float
store float %67, float* %9
br label %68
68: ; preds = %65, %62
%69 = load i32, i32* %17
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %69)
%71 = load float*, float** %16
%72 = getelementptr inbounds float, float* %71, i64 0
%73 = load float, float* %72
%74 = fpext float %73 to double
%75 = fcmp une double %74, 0.000000e+00
br i1 %75, label %76, label %80
76: ; preds = %68
%77 = load float*, float** %16
%78 = getelementptr inbounds float, float* %77, i64 0
%79 = load float, float* %78
store float %79, float* %20
br label %80
80: ; preds = %76, %68
%81 = load float, float* %20
%82 = load float, float* %9
%83 = load double, double* %13
%84 = call double @dmdelay(float %81, float %82, double %83)
%85 = load double, double* %15
%86 = fdiv double %84, %85
%87 = fptosi double %86 to i32
%88 = load i32*, i32** %19
%89 = load i32, i32* %17
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
store i32 %87, i32* %91
%92 = load double, double* %10
%93 = load float, float* %20
%94 = fpext float %93 to double
%95 = fadd double %94, %92
%96 = fptrunc double %95 to float
store float %96, float* %20
%97 = load i32, i32* %17
%98 = add nsw i32 %97, 1
%99 = load i32, i32* %18
%100 = srem i32 %98, %99
%101 = icmp ne i32 %100, 0
br i1 %101, label %110, label %102
102: ; preds = %80
%103 = load i32, i32* %18
%104 = sitofp i32 %103 to double
%105 = load double, double* %10
%106 = load float, float* %9
%107 = fpext float %106 to double
%108 = call double @llvm.fmuladd.f64(double %104, double %105, double %107)
%109 = fptrunc double %108 to float
store float %109, float* %9
br label %110
110: ; preds = %102, %80
br label %111
111: ; preds = %110
%112 = load i32, i32* %17
%113 = add nsw i32 %112, 1
store i32 %113, i32* %17
br label %58
114: ; preds = %58
%115 = load i32*, i32** %19
ret i32* %115
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"1\00"
define i32* @dmshift(float %0, double %1, i32 %2, i32 %3, double %4, double %5, double %6, float* nocapture %7) {
%9 = load float, float* %7
%10 = fpext float %9 to double
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%13 = shl i32 %2, 2
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = fpext float %0 to double
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %16)
%18 = sdiv i32 %2, %3
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %2, i32 %3)
%20 = load float, float* %7
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %21)
%23 = icmp sgt i32 %2, 0
br i1 %23, label %24, label %57
24: ; preds = %8
%25 = fcmp une float %20, 0.000000e+00
%26 = select i1 %25, float %20, float %0
%27 = fcmp ogt double %5, 0.000000e+00
%28 = fptrunc double %5 to float
%29 = sitofp i32 %18 to double
%30 = zext i32 %2 to i64
br label %31
31: ; preds = %24, %31
%32 = phi i64 [ 0, %24 ], [ %48, %31 ]
%33 = phi float [ %0, %24 ], [ %47, %31 ]
%34 = phi float [ %26, %24 ], [ %55, %31 ]
%35 = select i1 %27, float %28, float %34
%36 = trunc i64 %32 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load float, float* %7
%39 = fcmp une float %38, 0.000000e+00
%40 = select i1 %39, float %38, float %33
%41 = tail call double @dmdelay(float %40, float %35, double %4)
%42 = fdiv double %41, %6
%43 = fptosi double %42 to i32
%44 = getelementptr inbounds i32, i32* %15, i64 %32
store i32 %43, i32* %44
%45 = fpext float %40 to double
%46 = fadd double %45, %1
%47 = fptrunc double %46 to float
%48 = add nuw nsw i64 %32, 1
%49 = trunc i64 %48 to i32
%50 = srem i32 %49, %18
%51 = icmp eq i32 %50, 0
%52 = fpext float %35 to double
%53 = tail call double @llvm.fmuladd.f64(double %29, double %1, double %52)
%54 = fptrunc double %53 to float
%55 = select i1 %51, float %54, float %35
%56 = icmp eq i64 %48, %30
br i1 %56, label %57, label %31
57: ; preds = %31, %8
ret i32* %15
}