#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(int);
int shine_mpeg_version(int);
int shine_check_config(int 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    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <shine_find_samplerate_index@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    115f <shine_check_config+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <shine_check_config+0x64>
mov    -0x10(%rbp),%edi
call   1050 <shine_mpeg_version@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <shine_find_bitrate_index@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    118e <shine_check_config+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <shine_check_config+0x64>
mov    -0x18(%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(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = load i32, i32* %4
%10 = call i32 @shine_find_samplerate_index(i32 %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(i32 %0, i32 %1) {
%3 = tail call i32 @shine_find_samplerate_index(i32 %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
}