#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 shine_find_bitrate_index(int, int);
int shine_find_samplerate_index(long);
int shine_mpeg_version(int);
int shine_check_config(long freq, int bitr) {
  int samplerate_index, bitrate_index, mpeg_version;
  samplerate_index = shine_find_samplerate_index(freq);
  if (samplerate_index < 0)
    return -1;
  mpeg_version = shine_mpeg_version(samplerate_index);
  bitrate_index = shine_find_bitrate_index(bitr, mpeg_version);
  if (bitrate_index < 0)
    return -1;
  return mpeg_version;
}


x86 assembly (clang, -O0):
<shine_check_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <shine_find_samplerate_index@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1161 <shine_check_config+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <shine_check_config+0x66>
mov    -0x18(%rbp),%edi
call   1050 <shine_mpeg_version@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <shine_find_bitrate_index@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1190 <shine_check_config+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <shine_check_config+0x66>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shine_check_config>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
call   1040 <shine_find_samplerate_index@plt>
test   %eax,%eax
js     115c <shine_check_config+0x2c>
mov    %eax,%edi
call   1050 <shine_mpeg_version@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <shine_find_bitrate_index@plt>
test   %eax,%eax
mov    $0xffffffff,%eax
cmovns %ebp,%eax
jmp    1161 <shine_check_config+0x31>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @shine_check_config(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
%9 = load i64, i64* %4
%10 = call i32 @shine_find_samplerate_index(i64 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %25
14: ; preds = %2
%15 = load i32, i32* %6
%16 = call i32 @shine_mpeg_version(i32 %15)
store i32 %16, i32* %8
%17 = load i32, i32* %5
%18 = load i32, i32* %8
%19 = call i32 @shine_find_bitrate_index(i32 %17, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 -1, i32* %3
br label %25
23: ; preds = %14
%24 = load i32, i32* %8
store i32 %24, i32* %3
br label %25
25: ; preds = %23, %22, %13
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @shine_check_config(i64 %0, i32 %1) {
%3 = tail call i32 @shine_find_samplerate_index(i64 %0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @shine_mpeg_version(i32 %3)
%7 = tail call i32 @shine_find_bitrate_index(i32 %1, i32 %6)
%8 = icmp sgt i32 %7, -1
%9 = select i1 %8, i32 %6, i32 -1
br label %10
10: ; preds = %5, %2
%11 = phi i32 [ -1, %2 ], [ %9, %5 ]
ret i32 %11
}