#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*/ errexit(int);
double pow(int, double);
char *strstr(char *, char *);
double strtod(char *, char **);
int getparam(char *s, double *v, int msk) {
  char *p, *q;
  char c;
  double x;
  int u = 0;
  x = strtod(s, &p);
  if (p == s)
    errexit(4);
  c = *p;
  p++;
  switch (c) {
  case 'K':
    x *= 1024.;
    break;
  case 'k':
    x *= 1000.;
    break;
  case 'd':
    x *= 0.1;
    break;
  case 'c':
    x *= 0.01;
    break;
  case 'm':
    x *= 0.001;
    break;
  default:
    p--;
  };
  q = strstr(" s Hz hz h f B b % rad eg m pt ", p);
  if (!q && *p != 0)
    errexit(4);
  switch (*q) {
  case ' ':
    u = 1;
    break;
  case 's':
    u = 2;
    break;
  case 'H':;
  case 'h':
    u = 4;
    break;
  case 'f':
    u = 4;
    x *= 11025.;
    break;
  case 'B':;
  case 'b':
    u = 8;
    x = pow(10., x);
    break;
  case '%':
    u = 8;
    x *= 0.01;
    break;
  case 'r':
    u = 16;
    x /= 2 * 3.14159265359;
    break;
  case 'e':
    u = 16;
    x /= 36.;
    break;
  case 'm':
    u = 32;
    break;
  case 'p':
    u = 64;
    break;
  default:
    errexit(4);
  };
  if ((u & msk) == 0)
    errexit(4);
  *v = x;
  return u;
}


x86 assembly (clang, -O0):
<getparam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1184 <getparam+0x44>
mov    $0x4,%edi
call   1040 <errexit@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
movsbl -0x29(%rbp),%eax
add    $0xffffffb5,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x22,%eax
ja     1236 <getparam+0xf6>
mov    -0x48(%rbp),%rax
lea    0xe86(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe55(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1242 <getparam+0x102>
movsd  0xe36(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1242 <getparam+0x102>
movsd  0xe17(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1242 <getparam+0x102>
movsd  0xdf8(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1242 <getparam+0x102>
movsd  0xdd9(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1242 <getparam+0x102>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xfcf(%rip),%rdi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    127b <getparam+0x13b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127b <getparam+0x13b>
mov    $0x4,%edi
call   1040 <errexit@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x53,%eax
ja     138e <getparam+0x24e>
mov    -0x50(%rbp),%rax
lea    0xe2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x3c(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x2,-0x3c(%rbp)
jmp    1398 <getparam+0x258>
jmp    12c5 <getparam+0x185>
movl   $0x4,-0x3c(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x4,-0x3c(%rbp)
movsd  0xd58(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1398 <getparam+0x258>
jmp    12f4 <getparam+0x1b4>
movl   $0x8,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x8,-0x3c(%rbp)
movsd  0xce5(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x10,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xcea(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x10,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xcc0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x20,-0x3c(%rbp)
jmp    1398 <getparam+0x258>
movl   $0x40,-0x3c(%rbp)
jmp    1398 <getparam+0x258>
mov    $0x4,%edi
call   1040 <errexit@plt>
mov    -0x3c(%rbp),%eax
and    -0x14(%rbp),%eax
cmp    $0x0,%eax
jne    13b1 <getparam+0x271>
mov    $0x4,%edi
call   1040 <errexit@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getparam>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x10(%rsp),%rsi
call   1030 <strtod@plt>
mov    0x10(%rsp),%rbx
cmp    %rbp,%rbx
jne    117d <getparam+0x3d>
mov    $0x4,%edi
movsd  %xmm0,0x8(%rsp)
call   1040 <errexit@plt>
movsd  0x8(%rsp),%xmm0
movsbl (%rbx),%ecx
add    $0xffffffb5,%ecx
cmp    $0x22,%ecx
ja     11cf <getparam+0x8f>
lea    0x1(%rbx),%rax
lea    0xead(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mulsd  0xe7c(%rip),%xmm0
jmp    11cc <getparam+0x8c>
mulsd  0xe5a(%rip),%xmm0
jmp    11cc <getparam+0x8c>
mulsd  0xe58(%rip),%xmm0
jmp    11cc <getparam+0x8c>
mulsd  0xe56(%rip),%xmm0
jmp    11cc <getparam+0x8c>
mulsd  0xe34(%rip),%xmm0
mov    %rax,%rbx
movsd  %xmm0,0x8(%rsp)
lea    0x1040(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11fb <getparam+0xbb>
cmpb   $0x0,(%rbx)
je     11fb <getparam+0xbb>
mov    $0x4,%edi
call   1040 <errexit@plt>
movsbl 0x0(%rbp),%eax
add    $0xffffffe0,%eax
cmp    $0x53,%eax
movsd  0x8(%rsp),%xmm0
ja     122e <getparam+0xee>
mov    $0x1,%ebx
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xa,%edi
call   1050 <pow@plt>
jmp    124f <getparam+0x10f>
mov    $0x4,%edi
call   1040 <errexit@plt>
movsd  0x8(%rsp),%xmm0
xor    %ebx,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
mulsd  0xdb9(%rip),%xmm0
mov    $0x8,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
divsd  0xdc5(%rip),%xmm0
mov    $0x10,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
mulsd  0xdc1(%rip),%xmm0
mov    $0x4,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
mov    $0x20,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
mov    $0x40,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>
divsd  0xd8d(%rip),%xmm0
mov    $0x10,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
mov    $0x4,%edi
movsd  %xmm0,0x8(%rsp)
call   1040 <errexit@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%ebx
test   %r15d,%ebx
jne    12c3 <getparam+0x183>
jmp    12ad <getparam+0x16d>

LLVM IR (-O0):
@.str = [32 x i8] c" s Hz hz h f B b % rad eg m pt \00"
define i32 @getparam(i8* %0, double* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca double
%11 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %11
%12 = load i8*, i8** %4
%13 = call double @strtod(i8* %12, i8** %7)
store double %13, double* %10
%14 = load i8*, i8** %7
%15 = load i8*, i8** %4
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @errexit(i32 4)
br label %19
19: ; preds = %17, %3
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
store i8 %21, i8* %9
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %7
%24 = load i8, i8* %9
%25 = sext i8 %24 to i32
switch i32 %25, label %41 [
i32 75, label %26
i32 107, label %29
i32 100, label %32
i32 99, label %35
i32 109, label %38
]
26: ; preds = %19
%27 = load double, double* %10
%28 = fmul double %27, 1.024000e+03
store double %28, double* %10
br label %44
29: ; preds = %19
%30 = load double, double* %10
%31 = fmul double %30, 1.000000e+03
store double %31, double* %10
br label %44
32: ; preds = %19
%33 = load double, double* %10
%34 = fmul double %33, 1.000000e-01
store double %34, double* %10
br label %44
35: ; preds = %19
%36 = load double, double* %10
%37 = fmul double %36, 1.000000e-02
store double %37, double* %10
br label %44
38: ; preds = %19
%39 = load double, double* %10
%40 = fmul double %39, 1.000000e-03
store double %40, double* %10
br label %44
41: ; preds = %19
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i32 -1
store i8* %43, i8** %7
br label %44
44: ; preds = %41, %38, %35, %32, %29, %26
%45 = load i8*, i8** %7
%46 = call i8* @strstr(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %45)
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = icmp ne i8* %47, null
br i1 %48, label %56, label %49
49: ; preds = %44
%50 = load i8*, i8** %7
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @errexit(i32 4)
br label %56
56: ; preds = %54, %49, %44
%57 = load i8*, i8** %8
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
switch i32 %59, label %82 [
i32 32, label %60
i32 115, label %61
i32 72, label %62
i32 104, label %63
i32 102, label %64
i32 66, label %67
i32 98, label %68
i32 37, label %71
i32 114, label %74
i32 101, label %77
i32 109, label %80
i32 112, label %81
]
60: ; preds = %56
store i32 1, i32* %11
br label %84
61: ; preds = %56
store i32 2, i32* %11
br label %84
62: ; preds = %56
br label %63
63: ; preds = %56, %62
store i32 4, i32* %11
br label %84
64: ; preds = %56
store i32 4, i32* %11
%65 = load double, double* %10
%66 = fmul double %65, 1.102500e+04
store double %66, double* %10
br label %84
67: ; preds = %56
br label %68
68: ; preds = %56, %67
store i32 8, i32* %11
%69 = load double, double* %10
%70 = call double @pow(i32 10, double %69)
store double %70, double* %10
br label %84
71: ; preds = %56
store i32 8, i32* %11
%72 = load double, double* %10
%73 = fmul double %72, 1.000000e-02
store double %73, double* %10
br label %84
74: ; preds = %56
store i32 16, i32* %11
%75 = load double, double* %10
%76 = fdiv double %75, 0x401921FB54442EEA
store double %76, double* %10
br label %84
77: ; preds = %56
store i32 16, i32* %11
%78 = load double, double* %10
%79 = fdiv double %78, 3.600000e+01
store double %79, double* %10
br label %84
80: ; preds = %56
store i32 32, i32* %11
br label %84
81: ; preds = %56
store i32 64, i32* %11
br label %84
82: ; preds = %56
%83 = call i32 @errexit(i32 4)
br label %84
84: ; preds = %82, %81, %80, %77, %74, %71, %68, %64, %63, %61, %60
%85 = load i32, i32* %11
%86 = load i32, i32* %6
%87 = and i32 %85, %86
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %84
%90 = call i32 @errexit(i32 4)
br label %91
91: ; preds = %89, %84
%92 = load double, double* %10
%93 = load double*, double** %5
store double %92, double* %93
%94 = load i32, i32* %11
ret i32 %94
}

LLVM IR (-O2):
@.str = [32 x i8] c" s Hz hz h f B b % rad eg m pt \00"
define i32 @getparam(i8* %0, double* nocapture writeonly %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call double @strtod(i8* %0, i8** %4)
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, %0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @errexit(i32 4)
br label %11
11: ; preds = %9, %3
%12 = load i8, i8* %7
%13 = getelementptr inbounds i8, i8* %7, i64 1
%14 = sext i8 %12 to i32
switch i32 %14, label %25 [
i32 75, label %15
i32 107, label %17
i32 100, label %19
i32 99, label %21
i32 109, label %23
]
15: ; preds = %11
%16 = fmul double %6, 1.024000e+03
br label %25
17: ; preds = %11
%18 = fmul double %6, 1.000000e+03
br label %25
19: ; preds = %11
%20 = fmul double %6, 1.000000e-01
br label %25
21: ; preds = %11
%22 = fmul double %6, 1.000000e-02
br label %25
23: ; preds = %11
%24 = fmul double %6, 1.000000e-03
br label %25
25: ; preds = %11, %23, %21, %19, %17, %15
%26 = phi i8* [ %13, %23 ], [ %13, %21 ], [ %13, %19 ], [ %13, %17 ], [ %13, %15 ], [ %7, %11 ]
%27 = phi double [ %24, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %6, %11 ]
%28 = tail call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %26)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i8, i8* %26
%32 = icmp eq i8 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 @errexit(i32 4)
br label %35
35: ; preds = %33, %30, %25
%36 = load i8, i8* %28
%37 = sext i8 %36 to i32
switch i32 %37, label %52 [
i32 32, label %54
i32 115, label %38
i32 72, label %39
i32 104, label %39
i32 102, label %40
i32 66, label %42
i32 98, label %42
i32 37, label %44
i32 114, label %46
i32 101, label %48
i32 109, label %50
i32 112, label %51
]
38: ; preds = %35
br label %54
39: ; preds = %35, %35
br label %54
40: ; preds = %35
%41 = fmul double %27, 1.102500e+04
br label %54
42: ; preds = %35, %35
%43 = tail call double @pow(i32 10, double %27)
br label %54
44: ; preds = %35
%45 = fmul double %27, 1.000000e-02
br label %54
46: ; preds = %35
%47 = fdiv double %27, 0x401921FB54442EEA
br label %54
48: ; preds = %35
%49 = fdiv double %27, 3.600000e+01
br label %54
50: ; preds = %35
br label %54
51: ; preds = %35
br label %54
52: ; preds = %35
%53 = tail call i32 @errexit(i32 4)
br label %54
54: ; preds = %35, %52, %51, %50, %48, %46, %44, %42, %40, %39, %38
%55 = phi double [ %27, %52 ], [ %27, %51 ], [ %27, %50 ], [ %49, %48 ], [ %47, %46 ], [ %45, %44 ], [ %43, %42 ], [ %41, %40 ], [ %27, %39 ], [ %27, %38 ], [ %27, %35 ]
%56 = phi i32 [ 0, %52 ], [ 64, %51 ], [ 32, %50 ], [ 16, %48 ], [ 16, %46 ], [ 8, %44 ], [ 8, %42 ], [ 4, %40 ], [ 4, %39 ], [ 2, %38 ], [ 1, %35 ]
%57 = and i32 %56, %2
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = tail call i32 @errexit(i32 4)
br label %61
61: ; preds = %59, %54
store double %55, double* %1
ret i32 %56
}