#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ stderr;
int resample_rate(double freq) {
  if (freq >= 1.e3)
    freq *= 1.e-3;
  switch ((int)freq) {
  case 8:
    return 8000;
  case 11:
    return 11025;
  case 12:
    return 12000;
  case 16:
    return 16000;
  case 22:
    return 22050;
  case 24:
    return 24000;
  case 32:
    return 32000;
  case 44:
    return 44100;
  case 48:
    return 48000;
  default:
    fprintf(stderr, "Illegal resample frequency: %.3f kHz\n", freq);
    return 0;
  }
}


x86 assembly (clang, -O0):
<resample_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1146 <resample_rate+0x36>
movsd  0xecc(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x28,%eax
ja     11dd <resample_rate+0xcd>
mov    -0x18(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1f40,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x2b11,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x2ee0,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x3e80,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x5622,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x5dc0,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0x7d00,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0xac44,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
movl   $0xbb80,-0x4(%rbp)
jmp    11fe <resample_rate+0xee>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
movsd  -0x10(%rbp),%xmm0
lea    0xec2(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resample_rate>:
push   %rax
movapd %xmm0,%xmm1
movsd  0xee3(%rip),%xmm2
mulsd  %xmm0,%xmm2
movsd  0xedf(%rip),%xmm0
cmpnlesd %xmm1,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    $0xfffffff8,%ecx
cmp    $0x28,%ecx
ja     1162 <resample_rate+0x52>
mov    $0x1f40,%eax
lea    0xebe(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x2b11,%eax
pop    %rcx
ret
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xf42(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x2ee0,%eax
pop    %rcx
ret
mov    $0x3e80,%eax
pop    %rcx
ret
mov    $0x5622,%eax
pop    %rcx
ret
mov    $0x5dc0,%eax
pop    %rcx
ret
mov    $0x7d00,%eax
pop    %rcx
ret
mov    $0xac44,%eax
pop    %rcx
ret
mov    $0xbb80,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Illegal resample frequency: %.3f kHz\0A\00"
define i32 @resample_rate(double %0) {
%2 = alloca i32
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 1.000000e+03
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load double, double* %3
%8 = fmul double %7, 1.000000e-03
store double %8, double* %3
br label %9
9: ; preds = %6, %1
%10 = load double, double* %3
%11 = fptosi double %10 to i32
switch i32 %11, label %21 [
i32 8, label %12
i32 11, label %13
i32 12, label %14
i32 16, label %15
i32 22, label %16
i32 24, label %17
i32 32, label %18
i32 44, label %19
i32 48, label %20
]
12: ; preds = %9
store i32 8000, i32* %2
br label %25
13: ; preds = %9
store i32 11025, i32* %2
br label %25
14: ; preds = %9
store i32 12000, i32* %2
br label %25
15: ; preds = %9
store i32 16000, i32* %2
br label %25
16: ; preds = %9
store i32 22050, i32* %2
br label %25
17: ; preds = %9
store i32 24000, i32* %2
br label %25
18: ; preds = %9
store i32 32000, i32* %2
br label %25
19: ; preds = %9
store i32 44100, i32* %2
br label %25
20: ; preds = %9
store i32 48000, i32* %2
br label %25
21: ; preds = %9
%22 = load i32, i32* @stderr
%23 = load double, double* %3
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %23)
store i32 0, i32* %2
br label %25
25: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Illegal resample frequency: %.3f kHz\0A\00"
define i32 @resample_rate(double %0) {
%2 = fcmp ult double %0, 1.000000e+03
%3 = fmul double %0, 1.000000e-03
%4 = select i1 %2, double %0, double %3
%5 = fptosi double %4 to i32
switch i32 %5, label %14 [
i32 8, label %17
i32 11, label %6
i32 12, label %7
i32 16, label %8
i32 22, label %9
i32 24, label %10
i32 32, label %11
i32 44, label %12
i32 48, label %13
]
6: ; preds = %1
br label %17
7: ; preds = %1
br label %17
8: ; preds = %1
br label %17
9: ; preds = %1
br label %17
10: ; preds = %1
br label %17
11: ; preds = %1
br label %17
12: ; preds = %1
br label %17
13: ; preds = %1
br label %17
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %4)
br label %17
17: ; preds = %1, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = phi i32 [ 0, %14 ], [ 48000, %13 ], [ 44100, %12 ], [ 32000, %11 ], [ 24000, %10 ], [ 22050, %9 ], [ 16000, %8 ], [ 12000, %7 ], [ 11025, %6 ], [ 8000, %1 ]
ret i32 %18
}