#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 */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
uint8_t asc_get_profilelevel(uint8_t asc_aot, uint8_t channels, uint32_t rate) {
  uint8_t profilelevel;
  switch (asc_aot) {
  case 2:
    profilelevel = 0x50;
    break;
  case 5:
    profilelevel = 0x58;
    break;
  case 23:
    return 0x38;
  case 29:
    profilelevel = 0x60;
    break;
  default:
    return 0xf;
  }
  if (rate > 48000)
    return profilelevel + 3;
  if (channels > 2)
    return profilelevel + 2;
  if (rate > 24000)
    return profilelevel + 1;
  return profilelevel;
}


x86 assembly (clang, -O0):
<asc_get_profilelevel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1b,%eax
ja     1166 <asc_get_profilelevel+0x66>
mov    -0x20(%rbp),%rax
lea    0xed3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x50,-0x14(%rbp)
jmp    1172 <asc_get_profilelevel+0x72>
movl   $0x58,-0x14(%rbp)
jmp    1172 <asc_get_profilelevel+0x72>
movl   $0x38,-0x4(%rbp)
jmp    11c6 <asc_get_profilelevel+0xc6>
movl   $0x60,-0x14(%rbp)
jmp    1172 <asc_get_profilelevel+0x72>
movl   $0xf,-0x4(%rbp)
jmp    11c6 <asc_get_profilelevel+0xc6>
cmpl   $0xbb80,-0x10(%rbp)
jle    118d <asc_get_profilelevel+0x8d>
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <asc_get_profilelevel+0xc6>
cmpl   $0x2,-0xc(%rbp)
jle    11a5 <asc_get_profilelevel+0xa5>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <asc_get_profilelevel+0xc6>
cmpl   $0x5dc0,-0x10(%rbp)
jle    11c0 <asc_get_profilelevel+0xc0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <asc_get_profilelevel+0xc6>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<asc_get_profilelevel>:
add    $0xfffffffe,%edi
cmp    $0x1b,%edi
ja     1134 <asc_get_profilelevel+0x34>
mov    $0x38,%eax
mov    $0x50,%ecx
lea    0xee7(%rip),%r8
movslq (%r8,%rdi,4),%rdi
add    %r8,%rdi
jmp    *%rdi
mov    $0x58,%ecx
cmp    $0xbb81,%edx
jl     1147 <asc_get_profilelevel+0x47>
or     $0x3,%ecx
jmp    115e <asc_get_profilelevel+0x5e>
mov    $0xf,%eax
ret
mov    $0x60,%ecx
cmp    $0xbb81,%edx
jge    112f <asc_get_profilelevel+0x2f>
cmp    $0x3,%esi
jl     1151 <asc_get_profilelevel+0x51>
or     $0x2,%ecx
jmp    115e <asc_get_profilelevel+0x5e>
xor    %eax,%eax
cmp    $0x5dc1,%edx
setge  %al
or     %eax,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @asc_get_profilelevel(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
switch i32 %9, label %14 [
i32 2, label %10
i32 5, label %11
i32 23, label %12
i32 29, label %13
]
10: ; preds = %3
store i32 80, i32* %8
br label %15
11: ; preds = %3
store i32 88, i32* %8
br label %15
12: ; preds = %3
store i32 56, i32* %4
br label %35
13: ; preds = %3
store i32 96, i32* %8
br label %15
14: ; preds = %3
store i32 15, i32* %4
br label %35
15: ; preds = %13, %11, %10
%16 = load i32, i32* %7
%17 = icmp sgt i32 %16, 48000
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 3
store i32 %20, i32* %4
br label %35
21: ; preds = %15
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 2
store i32 %26, i32* %4
br label %35
27: ; preds = %21
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 24000
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %35
33: ; preds = %27
%34 = load i32, i32* %8
store i32 %34, i32* %4
br label %35
35: ; preds = %33, %30, %24, %18, %14, %12
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @asc_get_profilelevel(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %6 [
i32 2, label %7
i32 5, label %4
i32 23, label %20
i32 29, label %5
]
4: ; preds = %3
br label %7
5: ; preds = %3
br label %7
6: ; preds = %3
br label %20
7: ; preds = %3, %5, %4
%8 = phi i32 [ 96, %5 ], [ 88, %4 ], [ 80, %3 ]
%9 = icmp sgt i32 %2, 48000
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = or i32 %8, 3
br label %20
12: ; preds = %7
%13 = icmp sgt i32 %1, 2
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = or i32 %8, 2
br label %20
16: ; preds = %12
%17 = icmp sgt i32 %2, 24000
%18 = zext i1 %17 to i32
%19 = or i32 %8, %18
br label %20
20: ; preds = %16, %3, %14, %10, %6
%21 = phi i32 [ 15, %6 ], [ %11, %10 ], [ %15, %14 ], [ 56, %3 ], [ %19, %16 ]
ret i32 %21
}