#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int data;
};
struct dtv_property {
  TYPE_1__ u;
  int /*<<< orphan*/ cmd;
};
struct dtv_properties {
  int num;
  struct dtv_property *props;
};

/* Variables and functions */
int /*<<< orphan*/ DTV_FREQUENCY;
int /*<<< orphan*/ FE_GET_PROPERTY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ get_isdbtype(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct dtv_properties *);
int /*<<< orphan*/ stderr;
void frontend_show_frequency(int fefd) {
  struct dtv_properties props;
  struct dtv_property prop[1];
  prop[0].cmd = DTV_FREQUENCY;
  props.num = 1;
  props.props = prop;
  if (ioctl(fefd, FE_GET_PROPERTY, &props) != 0) {
    return;
  }
  if (get_isdbtype(fefd) == 0) {
    fprintf(stderr, "Info: Tuned %d KHz.\n", prop[0].u.data / 1000);
  } else {
    fprintf(stderr, "Info: Tuned %d MHz.\n", prop[0].u.data / 1000);
  }
  return;
}


x86 assembly (clang, -O0):
<frontend_show_frequency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
je     117a <frontend_show_frequency+0x4a>
jmp    11da <frontend_show_frequency+0xaa>
mov    -0x4(%rbp),%edi
call   1050 <get_isdbtype@plt>
cmp    $0x0,%rax
jne    11b3 <frontend_show_frequency+0x83>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe57(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11d5 <frontend_show_frequency+0xa5>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe45(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11da <frontend_show_frequency+0xaa>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frontend_show_frequency>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movl   $0x1,0x10(%rsp)
lea    0x8(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   1030 <ioctl@plt>
test   %rax,%rax
jne    11b1 <frontend_show_frequency+0x81>
mov    %ebx,%edi
call   1050 <get_isdbtype@plt>
movslq 0x8(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rdx
add    %ecx,%edx
test   %rax,%rax
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rax
lea    0xe6d(%rip),%rsi
cmove  %rax,%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.dtv_properties = type { i32, %struct.dtv_property* }
%struct.dtv_property = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@DTV_FREQUENCY = global i32 0
@FE_GET_PROPERTY = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"Info: Tuned %d KHz.\0A\00"
@.str.1 = [21 x i8] c"Info: Tuned %d MHz.\0A\00"
define void @frontend_show_frequency(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.dtv_properties
%4 = alloca [1 x %struct.dtv_property]
store i32 %0, i32* %2
%5 = load i32, i32* @DTV_FREQUENCY
%6 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %4, i64 0, i64 0
%7 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %6, i32 0, i32 1
store i32 %5, i32* %7
%8 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %3, i32 0, i32 0
store i32 1, i32* %8
%9 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %4, i64 0, i64 0
%10 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %3, i32 0, i32 1
store %struct.dtv_property* %9, %struct.dtv_property** %10
%11 = load i32, i32* %2
%12 = load i32, i32* @FE_GET_PROPERTY
%13 = call i64 @ioctl(i32 %11, i32 %12, %struct.dtv_properties* %3)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
br label %37
16: ; preds = %1
%17 = load i32, i32* %2
%18 = call i64 @get_isdbtype(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %4, i64 0, i64 0
%23 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1000
%27 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %36
28: ; preds = %16
%29 = load i32, i32* @stderr
%30 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %4, i64 0, i64 0
%31 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %30, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = sdiv i32 %33, 1000
%35 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %28, %20
br label %37
37: ; preds = %36, %15
ret void
}

LLVM IR (-O2):
%struct.dtv_properties = type { i32, %struct.dtv_property* }
%struct.dtv_property = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@DTV_FREQUENCY = global i32 0
@FE_GET_PROPERTY = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"Info: Tuned %d KHz.\0A\00"
@.str.1 = [21 x i8] c"Info: Tuned %d MHz.\0A\00"
define void @frontend_show_frequency(i32 %0) {
%2 = alloca %struct.dtv_properties
%3 = alloca [1 x %struct.dtv_property]
%4 = bitcast %struct.dtv_properties* %2 to i8*
%5 = bitcast [1 x %struct.dtv_property]* %3 to i8*
%6 = load i32, i32* @DTV_FREQUENCY
%7 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %3, i64 0, i64 0, i32 1
store i32 %6, i32* %8
%9 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %2, i64 0, i32 0
store i32 1, i32* %9
%10 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %2, i64 0, i32 1
store %struct.dtv_property* %7, %struct.dtv_property** %10
%11 = load i32, i32* @FE_GET_PROPERTY
%12 = call i64 @ioctl(i32 %0, i32 %11, %struct.dtv_properties* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %1
%15 = call i64 @get_isdbtype(i32 %0)
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* @stderr
%18 = getelementptr inbounds [1 x %struct.dtv_property], [1 x %struct.dtv_property]* %3, i64 0, i64 0, i32 0, i32 0
%19 = load i32, i32* %18
%20 = sdiv i32 %19, 1000
%21 = select i1 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0)
%22 = call i32 @fprintf(i32 %17, i8* %21, i32 %20)
br label %23
23: ; preds = %14, %1
ret void
}