#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*/ assert(int);
int f;
int find_mixer(char *const, char **);
scalar_t__ isalpha(char);
int uint_arg(char *, char const *, int, int, int);
int /*<<< orphan*/ zz_log_err(char *, char *, char const *, char *const);
int uint_spr(char *const arg, const char *name, int *prate, int *pmixer) {
  int rate = 48000;
  char *end = arg;
  if (isalpha(arg[0])) {
    int f = f = find_mixer(arg, &end);
    ((void)0);
    if (f <= 0) {
      zz_log_err(""
                 "%s sampling method -- %s=%s\n",
                 !f ? "invalid" : "ambiguous", name, arg);
    } else {
      ((void)0);
      *pmixer = f - 1;
    }
  }
  if (end && *end) {
    rate = uint_arg(end, name, 4000, 96000, 10);
    ((void)0);
  }
  if (rate != -1)
    *prate = rate;
  assert(*pmixer >= 0);
  assert(*prate >= 4000);
  assert(*prate <= 96000);
  return rate;
}


x86 assembly (clang, -O0):
<uint_spr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0xbb80,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11f3 <uint_spr+0xa3>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <find_mixer@plt>
mov    %eax,-0x34(%rbp)
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jg     11e2 <uint_spr+0x92>
cmpl   $0x0,-0x34(%rbp)
setne  %cl
xor    $0xff,%cl
lea    0xe6a(%rip),%rsi
lea    0xe5b(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe28(%rip),%rdi
call   1030 <zz_log_err@plt>
jmp    11ee <uint_spr+0x9e>
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11f3 <uint_spr+0xa3>
cmpq   $0x0,-0x30(%rbp)
je     122e <uint_spr+0xde>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     122e <uint_spr+0xde>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xfa0,%edx
mov    $0x17700,%ecx
mov    $0xa,%r8d
call   1070 <uint_arg@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     1241 <uint_spr+0xf1>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0xfa0,(%rax)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x17700,(%rax)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uint_spr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rdi,(%rsp)
movsbl (%rdi),%edi
call   1050 <isalpha@plt>
test   %rax,%rax
je     11b9 <uint_spr+0x69>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <find_mixer@plt>
test   %eax,%eax
jle    118c <uint_spr+0x3c>
add    $0xffffffff,%eax
mov    %eax,(%r14)
jmp    11b0 <uint_spr+0x60>
lea    0xe8a(%rip),%rax
lea    0xe8b(%rip),%rsi
cmove  %rax,%rsi
lea    0xe5b(%rip),%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1030 <zz_log_err@plt>
mov    (%rsp),%rbx
test   %rbx,%rbx
je     11e7 <uint_spr+0x97>
cmpb   $0x0,(%rbx)
je     11e7 <uint_spr+0x97>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xfa0,%edx
mov    $0x17700,%ecx
mov    $0xa,%r8d
call   1070 <uint_arg@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11ec <uint_spr+0x9c>
mov    $0xffffffff,%ebx
jmp    11f0 <uint_spr+0xa0>
mov    $0xbb80,%ebx
mov    %ebx,(%r12)
mov    (%r14),%edi
not    %edi
shr    $0x1f,%edi
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0xfa0,(%r12)
setge  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x17701,(%r12)
setl   %dil
call   1040 <assert@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"%s sampling method -- %s=%s\0A\00"
@.str.1 = [8 x i8] c"invalid\00"
@.str.2 = [10 x i8] c"ambiguous\00"
@f = global i32 0
define i32 @uint_spr(i8* %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 48000, i32* %9
%12 = load i8*, i8** %5
store i8* %12, i8** %10
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = call i64 @isalpha(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %37
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = call i32 @find_mixer(i8* %19, i8** %10)
store i32 %20, i32* %11
store i32 %20, i32* %11
%21 = load i32, i32* %11
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%29 = load i8*, i8** %6
%30 = load i8*, i8** %5
%31 = call i32 @zz_log_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29, i8* %30)
br label %36
32: ; preds = %18
%33 = load i32, i32* %11
%34 = sub nsw i32 %33, 1
%35 = load i32*, i32** %8
store i32 %34, i32* %35
br label %36
36: ; preds = %32, %23
br label %37
37: ; preds = %36, %4
%38 = load i8*, i8** %10
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i8*, i8** %10
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = load i8*, i8** %10
%47 = load i8*, i8** %6
%48 = call i32 @uint_arg(i8* %46, i8* %47, i32 4000, i32 96000, i32 10)
store i32 %48, i32* %9
br label %49
49: ; preds = %45, %40, %37
%50 = load i32, i32* %9
%51 = icmp ne i32 %50, -1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %9
%54 = load i32*, i32** %7
store i32 %53, i32* %54
br label %55
55: ; preds = %52, %49
%56 = load i32*, i32** %8
%57 = load i32, i32* %56
%58 = icmp sge i32 %57, 0
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i32*, i32** %7
%62 = load i32, i32* %61
%63 = icmp sge i32 %62, 4000
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i32*, i32** %7
%67 = load i32, i32* %66
%68 = icmp sle i32 %67, 96000
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = load i32, i32* %9
ret i32 %71
}

LLVM IR (-O2):
@.str = [29 x i8] c"%s sampling method -- %s=%s\0A\00"
@.str.1 = [8 x i8] c"invalid\00"
@.str.2 = [10 x i8] c"ambiguous\00"
@f = global i32 0
define i32 @uint_spr(i8* %0, i8* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
store i8* %0, i8** %5
%7 = load i8, i8* %0
%8 = tail call i64 @isalpha(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %4
%11 = call i32 @find_mixer(i8* %0, i8** %5)
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = icmp eq i32 %11, 0
%15 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @zz_log_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %1, i8* %0)
br label %19
17: ; preds = %10
%18 = add nsw i32 %11, -1
store i32 %18, i32* %3
br label %19
19: ; preds = %13, %17
%20 = load i8*, i8** %5
%21 = icmp eq i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %4, %19
%23 = phi i8* [ %20, %19 ], [ %0, %4 ]
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = call i32 @uint_arg(i8* %23, i8* %1, i32 4000, i32 96000, i32 10)
%28 = icmp eq i32 %27, -1
br i1 %28, label %31, label %29
29: ; preds = %19, %22, %26
%30 = phi i32 [ %27, %26 ], [ 48000, %22 ], [ 48000, %19 ]
store i32 %30, i32* %2
br label %31
31: ; preds = %29, %26
%32 = phi i32 [ %30, %29 ], [ -1, %26 ]
%33 = load i32, i32* %3
%34 = xor i32 %33, -1
%35 = lshr i32 %34, 31
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %2
%38 = icmp sgt i32 %37, 3999
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i32, i32* %2
%42 = icmp slt i32 %41, 96001
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret i32 %32
}