#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 ntohs(unsigned short);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void dump_samprate(char *output, int maxlen, void *value, int len) {
  char tmp[256] = "";
  int sr;
  if (len == (int)sizeof(unsigned short)) {
    sr = ntohs(*((unsigned short *)value));
    if (sr & (1 << 0))
      strcat(tmp, ",8khz");
    if (sr & (1 << 1))
      strcat(tmp, ",11.025khz");
    if (sr & (1 << 2))
      strcat(tmp, ",16khz");
    if (sr & (1 << 3))
      strcat(tmp, ",22.05khz");
    if (sr & (1 << 4))
      strcat(tmp, ",44.1khz");
    if (sr & (1 << 5))
      strcat(tmp, ",48khz");
    if (strlen(tmp))
      strncpy(output, &tmp[1], maxlen - 1);
    else
      strncpy(output, "None specified!\n", maxlen - 1);
  } else
    snprintf(output, maxlen, "Invalid SHORT");
}


x86 assembly (clang, -O0):
<dump_samprate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmpl   $0x2,-0x1c(%rbp)
jne    12d6 <dump_samprate+0x176>
mov    -0x18(%rbp),%rax
movzwl (%rax),%edi
call   1070 <ntohs@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11cd <dump_samprate+0x6d>
lea    -0x120(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x124(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11f2 <dump_samprate+0x92>
lea    -0x120(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x124(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1217 <dump_samprate+0xb7>
lea    -0x120(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x124(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     123c <dump_samprate+0xdc>
lea    -0x120(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x124(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1261 <dump_samprate+0x101>
lea    -0x120(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x124(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1286 <dump_samprate+0x126>
lea    -0x120(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     12bb <dump_samprate+0x15b>
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rsi
add    $0x1,%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
jmp    12d1 <dump_samprate+0x171>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xd66(%rip),%rsi
call   1030 <strncpy@plt>
jmp    12e9 <dump_samprate+0x189>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xd5f(%rip),%rdx
call   1050 <snprintf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_samprate>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
cmp    $0x2,%ecx
jne    1210 <dump_samprate+0xd0>
movzwl (%rdx),%edi
call   1050 <ntohs@plt>
mov    %eax,%ebp
test   $0x1,%bpl
jne    122c <dump_samprate+0xec>
test   $0x2,%bpl
jne    1241 <dump_samprate+0x101>
test   $0x4,%bpl
jne    1256 <dump_samprate+0x116>
test   $0x8,%bpl
jne    126f <dump_samprate+0x12f>
test   $0x10,%bpl
jne    1288 <dump_samprate+0x148>
test   $0x20,%bpl
jne    12a1 <dump_samprate+0x161>
cmpb   $0x0,(%rsp)
je     12ba <dump_samprate+0x17a>
lea    0x1(%rsp),%rsi
add    $0xffffffff,%ebx
jmp    12c4 <dump_samprate+0x184>
lea    0xe2c(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <snprintf@plt>
lea    0xdcd(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
test   $0x2,%bpl
je     11d5 <dump_samprate+0x95>
lea    0xdbe(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
test   $0x4,%bpl
je     11db <dump_samprate+0x9b>
lea    0xdb4(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
test   $0x8,%bpl
je     11e5 <dump_samprate+0xa5>
lea    0xda2(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
test   $0x10,%bpl
je     11ef <dump_samprate+0xaf>
lea    0xd93(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
test   $0x20,%bpl
je     11f9 <dump_samprate+0xb9>
lea    0xd83(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
cmpb   $0x0,(%rsp)
jne    1203 <dump_samprate+0xc3>
add    $0xffffffff,%ebx
lea    0xd6e(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c",8khz\00"
@.str.1 = [11 x i8] c",11.025khz\00"
@.str.2 = [7 x i8] c",16khz\00"
@.str.3 = [10 x i8] c",22.05khz\00"
@.str.4 = [9 x i8] c",44.1khz\00"
@.str.5 = [7 x i8] c",48khz\00"
@.str.6 = [17 x i8] c"None specified!\0A\00"
@.str.7 = [14 x i8] c"Invalid SHORT\00"
define void @dump_samprate(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = bitcast [256 x i8]* %9 to i8*
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %76
14: ; preds = %4
%15 = load i8*, i8** %7
%16 = bitcast i8* %15 to i16*
%17 = load i16, i16* %16
%18 = call i32 @ntohs(i16 zeroext %17)
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %22, %14
%26 = load i32, i32* %10
%27 = and i32 %26, 2
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* %10
%34 = and i32 %33, 4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %36, %32
%40 = load i32, i32* %10
%41 = and i32 %40, 8
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %43, %39
%47 = load i32, i32* %10
%48 = and i32 %47, 16
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %53
53: ; preds = %50, %46
%54 = load i32, i32* %10
%55 = and i32 %54, 32
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%59 = call i32 @strcat(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %60
60: ; preds = %57, %53
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%62 = call i64 @strlen(i8* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %60
%65 = load i8*, i8** %5
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 1
%67 = load i32, i32* %6
%68 = sub nsw i32 %67, 1
%69 = call i32 @strncpy(i8* %65, i8* %66, i32 %68)
br label %75
70: ; preds = %60
%71 = load i8*, i8** %5
%72 = load i32, i32* %6
%73 = sub nsw i32 %72, 1
%74 = call i32 @strncpy(i8* %71, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %70, %64
br label %80
76: ; preds = %4
%77 = load i8*, i8** %5
%78 = load i32, i32* %6
%79 = call i32 @snprintf(i8* %77, i32 %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %80
80: ; preds = %76, %75
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c",8khz\00"
@.str.1 = [11 x i8] c",11.025khz\00"
@.str.2 = [7 x i8] c",16khz\00"
@.str.3 = [10 x i8] c",22.05khz\00"
@.str.4 = [9 x i8] c",44.1khz\00"
@.str.5 = [7 x i8] c",48khz\00"
@.str.6 = [17 x i8] c"None specified!\0A\00"
@.str.7 = [14 x i8] c"Invalid SHORT\00"
define void @dump_samprate(i8* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = icmp eq i32 %3, 2
br i1 %7, label %8, label %51
8: ; preds = %4
%9 = bitcast i8* %2 to i16*
%10 = load i16, i16* %9
%11 = tail call i32 @ntohs(i16 zeroext %10)
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
%17 = and i32 %11, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = and i32 %11, 4
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = and i32 %11, 8
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = and i32 %11, 16
%33 = icmp eq i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = and i32 %11, 32
%38 = icmp eq i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = load i8, i8* %6
%43 = icmp eq i8 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 1
%46 = add nsw i32 %1, -1
%47 = call i32 @strncpy(i8* %0, i8* %45, i32 %46)
br label %53
48: ; preds = %41
%49 = add nsw i32 %1, -1
%50 = call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %49)
br label %53
51: ; preds = %4
%52 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %53
53: ; preds = %44, %48, %51
ret void
}