#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 */
float ath(float);
int floor(float);
float freq2bark(float);
float freqbin2freq(float, int, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int, ...);
int caculate_cb_info(float fs, int psd_len, float *psd_ath, int cb_hopbin[25],
                     float *psd_bark) {
  int k;
  float f;
  int band;
  band = 0;
  memset(cb_hopbin, 0, sizeof(int) * 25);
  for (k = 0; k < psd_len; k++) {
    f = freqbin2freq(fs, psd_len * 2, k);
    psd_ath[k] = ath(f);
    psd_bark[k] = freq2bark(f);
    if ((floor(psd_bark[k]) > band) && (band < 25)) {
      cb_hopbin[band] = k;
      printf("the hopbin of band[%d] = %d\n", band, k);
      band++;
    }
    printf("the %d freqbin's bark value psd_bark[%d] = %f\n", k, k,
           psd_bark[k]);
  }
  return band;
}


x86 assembly (clang, -O0):
<caculate_cb_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126f <caculate_cb_info+0x10f>
movss  -0x4(%rbp),%xmm0
mov    -0x8(%rbp),%edi
shl    $0x1,%edi
mov    -0x24(%rbp),%esi
call   1060 <freqbin2freq@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
call   1080 <ath@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x28(%rbp),%xmm0
call   1030 <freq2bark@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1070 <floor@plt>
cmp    -0x2c(%rbp),%eax
jle    123c <caculate_cb_info+0xdc>
cmpl   $0x19,-0x2c(%rbp)
jge    123c <caculate_cb_info+0xdc>
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119a <caculate_cb_info+0x3a>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<caculate_cb_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rsi,%r15
mov    %edi,%r12d
movss  %xmm0,0x8(%rsp)
xor    %ebp,%ebp
mov    %rdx,0x10(%rsp)
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
test   %r12d,%r12d
jle    123f <caculate_cb_info+0xdf>
mov    %r12d,%r13d
add    %r12d,%r12d
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11d7 <caculate_cb_info+0x77>
nopl   0x0(%rax)
movss  (%rbx,%r14,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    %r14d,%esi
mov    %r14d,%edx
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r13
je     123f <caculate_cb_info+0xdf>
movss  0x8(%rsp),%xmm0
mov    %r12d,%edi
mov    %r14d,%esi
call   1060 <freqbin2freq@plt>
movss  %xmm0,0xc(%rsp)
call   1080 <ath@plt>
movss  %xmm0,(%r15,%r14,4)
movss  0xc(%rsp),%xmm0
call   1030 <freq2bark@plt>
movss  %xmm0,(%rbx,%r14,4)
call   1070 <floor@plt>
cmp    $0x18,%ebp
jg     11b0 <caculate_cb_info+0x50>
cmp    %ebp,%eax
jle    11b0 <caculate_cb_info+0x50>
movslq %ebp,%rax
mov    0x10(%rsp),%rcx
mov    %r14d,(%rcx,%rax,4)
lea    0xdd5(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    11b0 <caculate_cb_info+0x50>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"the hopbin of band[%d] = %d\0A\00"
@.str.1 = [47 x i8] c"the %d freqbin's bark value psd_bark[%d] = %f\0A\00"
define i32 @caculate_cb_info(float %0, i32 %1, float* %2, i32* %3, float* %4) {
%6 = alloca float
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32*
%10 = alloca float*
%11 = alloca i32
%12 = alloca float
%13 = alloca i32
store float %0, float* %6
store i32 %1, i32* %7
store float* %2, float** %8
store i32* %3, i32** %9
store float* %4, float** %10
store i32 0, i32* %13
%14 = load i32*, i32** %9
%15 = call i32 @memset(i32* %14, i32 0, i32 100)
store i32 0, i32* %11
br label %16
16: ; preds = %70, %5
%17 = load i32, i32* %11
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %73
20: ; preds = %16
%21 = load float, float* %6
%22 = load i32, i32* %7
%23 = mul nsw i32 %22, 2
%24 = load i32, i32* %11
%25 = call float @freqbin2freq(float %21, i32 %23, i32 %24)
store float %25, float* %12
%26 = load float, float* %12
%27 = call float @ath(float %26)
%28 = load float*, float** %8
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
store float %27, float* %31
%32 = load float, float* %12
%33 = call float @freq2bark(float %32)
%34 = load float*, float** %10
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
store float %33, float* %37
%38 = load float*, float** %10
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = call i32 @floor(float %42)
%44 = load i32, i32* %13
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %60
46: ; preds = %20
%47 = load i32, i32* %13
%48 = icmp slt i32 %47, 25
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load i32, i32* %11
%51 = load i32*, i32** %9
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 %50, i32* %54
%55 = load i32, i32* %13
%56 = load i32, i32* %11
%57 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %55, i32 %56)
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 1
store i32 %59, i32* %13
br label %60
60: ; preds = %49, %46, %20
%61 = load i32, i32* %11
%62 = load i32, i32* %11
%63 = load float*, float** %10
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %61, i32 %62, double %68)
br label %70
70: ; preds = %60
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %16
73: ; preds = %16
%74 = load i32, i32* %13
ret i32 %74
}

LLVM IR (-O2):
@.str = [29 x i8] c"the hopbin of band[%d] = %d\0A\00"
@.str.1 = [47 x i8] c"the %d freqbin's bark value psd_bark[%d] = %f\0A\00"
define i32 @caculate_cb_info(float %0, i32 %1, float* nocapture writeonly %2, i32* %3, float* nocapture %4) {
%6 = tail call i32 @memset(i32* %3, i32 0, i32 100)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = shl nuw nsw i32 %1, 1
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %29
%12 = phi i64 [ 0, %8 ], [ %34, %29 ]
%13 = phi i32 [ 0, %8 ], [ %30, %29 ]
%14 = trunc i64 %12 to i32
%15 = tail call float @freqbin2freq(float %0, i32 %9, i32 %14)
%16 = tail call float @ath(float %15)
%17 = getelementptr inbounds float, float* %2, i64 %12
store float %16, float* %17
%18 = tail call float @freq2bark(float %15)
%19 = getelementptr inbounds float, float* %4, i64 %12
store float %18, float* %19
%20 = tail call i32 @floor(float %18)
%21 = icmp sgt i32 %20, %13
%22 = icmp slt i32 %13, 25
%23 = and i1 %22, %21
br i1 %23, label %24, label %29
24: ; preds = %11
%25 = sext i32 %13 to i64
%26 = getelementptr inbounds i32, i32* %3, i64 %25
store i32 %14, i32* %26
%27 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%28 = add nsw i32 %13, 1
br label %29
29: ; preds = %24, %11
%30 = phi i32 [ %28, %24 ], [ %13, %11 ]
%31 = load float, float* %19
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %14, double %32)
%34 = add nuw nsw i64 %12, 1
%35 = icmp eq i64 %34, %10
br i1 %35, label %36, label %11
36: ; preds = %29, %5
%37 = phi i32 [ 0, %5 ], [ %30, %29 ]
ret i32 %37
}