#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 /*<<< orphan*/ uint32_t;
typedef enum fe_type { ____Placeholder_fe_type } fe_type;

/* Variables and functions */
int check_frontend_multi(int, int, int /*<<< orphan*/ *);
int check_frontend_v3(int, int);
int dvbfe_get_version(int, int *, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ stderr;
int check_frontend(int fd, enum fe_type type, uint32_t *mstd) {
  int major, minor, ret;
  ret = dvbfe_get_version(fd, &major, &minor);
  if (ret)
    goto exit;
  fprintf(stderr, "Version: %d.%d  ", major, minor);
  if ((major == 5) && (minor > 8)) {
    ret = check_frontend_multi(fd, type, mstd);
    if (ret)
      goto exit;
  } else {
    ret = check_frontend_v3(fd, type);
    if (ret)
      goto exit;
  }
exit:
  return ret;
}


x86 assembly (clang, -O0):
<check_frontend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <dvbfe_get_version@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1174 <check_frontend+0x34>
jmp    11f0 <check_frontend+0xb0>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x5,-0x14(%rbp)
jne    11c9 <check_frontend+0x89>
cmpl   $0x8,-0x18(%rbp)
jle    11c9 <check_frontend+0x89>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <check_frontend_multi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11c4 <check_frontend+0x84>
jmp    11f0 <check_frontend+0xb0>
jmp    11eb <check_frontend+0xab>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <check_frontend_v3@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11e6 <check_frontend+0xa6>
jmp    11f0 <check_frontend+0xb0>
jmp    11eb <check_frontend+0xab>
jmp    11f0 <check_frontend+0xb0>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_frontend>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <dvbfe_get_version@plt>
test   %eax,%eax
jne    11a4 <check_frontend+0x64>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe86(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x5,0xc(%rsp)
jne    119b <check_frontend+0x5b>
cmpl   $0x9,0x8(%rsp)
jl     119b <check_frontend+0x5b>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1040 <check_frontend_multi@plt>
jmp    11a4 <check_frontend+0x64>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <check_frontend_v3@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Version: %d.%d \00"
define i32 @check_frontend(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i32, i32* %4
%11 = call i32 @dvbfe_get_version(i32 %10, i32* %7, i32* %8)
store i32 %11, i32* %9
%12 = load i32, i32* %9
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
br label %43
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 5
br i1 %21, label %22, label %34
22: ; preds = %15
%23 = load i32, i32* %8
%24 = icmp sgt i32 %23, 8
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i32*, i32** %6
%29 = call i32 @check_frontend_multi(i32 %26, i32 %27, i32* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
br label %43
33: ; preds = %25
br label %42
34: ; preds = %22, %15
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = call i32 @check_frontend_v3(i32 %35, i32 %36)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
br label %43
41: ; preds = %34
br label %42
42: ; preds = %41, %33
br label %43
43: ; preds = %42, %40, %32, %14
%44 = load i32, i32* %9
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Version: %d.%d \00"
define i32 @check_frontend(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call i32 @dvbfe_get_version(i32 %0, i32* %4, i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 5
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 8
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 @check_frontend_multi(i32 %0, i32 %1, i32* %2)
br label %24
22: ; preds = %10
%23 = call i32 @check_frontend_v3(i32 %0, i32 %1)
br label %24
24: ; preds = %22, %20, %3
%25 = phi i32 [ %8, %3 ], [ %21, %20 ], [ %23, %22 ]
ret i32 %25
}