#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 uint32_t;
typedef int uint16_t;
typedef int fe_status_t;

/* Variables and functions */
int FE_HAS_LOCK;
int /*<<< orphan*/ FE_READ_BER;
int /*<<< orphan*/ FE_READ_SIGNAL_STRENGTH;
int /*<<< orphan*/ FE_READ_SNR;
int /*<<< orphan*/ FE_READ_STATUS;
int /*<<< orphan*/ FE_READ_UNCORRECTED_BLOCKS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int /*<<< orphan*/ stderr;
void print_frontend_stats(int fe_fd, int human_readable) {
  fe_status_t status;
  uint16_t snr, _signal;
  uint32_t ber, uncorrected_blocks;
  ioctl(fe_fd, FE_READ_STATUS, &status);
  ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &_signal);
  ioctl(fe_fd, FE_READ_SNR, &snr);
  ioctl(fe_fd, FE_READ_BER, &ber);
  ioctl(fe_fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks);
  if (human_readable) {
    printf("status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | ",
           status, (_signal * 100) / 0xffff, (snr * 100) / 0xffff, ber,
           uncorrected_blocks);
  } else {
    fprintf(stderr,
            "status %02x | signal %04x | snr %04x | ber %08x | unc %08x | ",
            status, _signal, snr, ber, uncorrected_blocks);
  }
  if (status & FE_HAS_LOCK)
    fprintf(stderr, "FE_HAS_LOCK");
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<print_frontend_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x4(%rbp),%edi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x4(%rbp),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x4(%rbp),%edi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x4(%rbp),%edi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdx
call   1040 <ioctl@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ed <print_frontend_stats+0xbd>
mov    -0xc(%rbp),%esi
imul   $0x64,-0x14(%rbp),%eax
mov    $0xffff,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
imul   $0x64,-0x10(%rbp),%eax
mov    $0xffff,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    1218 <print_frontend_stats+0xe8>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xe2e(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2dbe(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1244 <print_frontend_stats+0x114>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_frontend_stats>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
call   1040 <ioctl@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
lea    0x1c(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
test   %ebx,%ebx
je     11ff <print_frontend_stats+0xcf>
mov    0x14(%rsp),%esi
imul   $0x64,0x20(%rsp),%eax
movslq %eax,%rdx
imul   $0xffffffff80008001,%rdx,%rax
shr    $0x20,%rax
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0xf,%edx
add    %eax,%edx
imul   $0x64,0x24(%rsp),%eax
movslq %eax,%rcx
imul   $0xffffffff80008001,%rcx,%rax
shr    $0x20,%rax
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0xf,%ecx
add    %eax,%ecx
mov    0x1c(%rsp),%r8d
mov    0x18(%rsp),%r9d
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_frontend_stats+0xff>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
mov    0x14(%rsp),%edx
mov    0x20(%rsp),%ecx
mov    0x24(%rsp),%r8d
mov    0x1c(%rsp),%r9d
mov    0x18(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
test   %eax,0x14(%rsp)
je     1255 <print_frontend_stats+0x125>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FE_READ_STATUS = global i32 0
@FE_READ_SIGNAL_STRENGTH = global i32 0
@FE_READ_SNR = global i32 0
@FE_READ_BER = global i32 0
@FE_READ_UNCORRECTED_BLOCKS = global i32 0
@.str = [60 x i8] c"status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | \00"
@stderr = global i32 0
@.str.1 = [62 x i8] c"status %02x | signal %04x | snr %04x | ber %08x | unc %08x | \00"
@FE_HAS_LOCK = global i32 0
@.str.2 = [12 x i8] c"FE_HAS_LOCK\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_frontend_stats(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = load i32, i32* @FE_READ_STATUS
%12 = call i32 @ioctl(i32 %10, i32 %11, i32* %5)
%13 = load i32, i32* %3
%14 = load i32, i32* @FE_READ_SIGNAL_STRENGTH
%15 = call i32 @ioctl(i32 %13, i32 %14, i32* %7)
%16 = load i32, i32* %3
%17 = load i32, i32* @FE_READ_SNR
%18 = call i32 @ioctl(i32 %16, i32 %17, i32* %6)
%19 = load i32, i32* %3
%20 = load i32, i32* @FE_READ_BER
%21 = call i32 @ioctl(i32 %19, i32 %20, i32* %8)
%22 = load i32, i32* %3
%23 = load i32, i32* @FE_READ_UNCORRECTED_BLOCKS
%24 = call i32 @ioctl(i32 %22, i32 %23, i32* %9)
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %2
%28 = load i32, i32* %5
%29 = load i32, i32* %7
%30 = mul nsw i32 %29, 100
%31 = sdiv i32 %30, 65535
%32 = load i32, i32* %6
%33 = mul nsw i32 %32, 100
%34 = sdiv i32 %33, 65535
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %31, i32 %34, i32 %35, i32 %36)
br label %46
38: ; preds = %2
%39 = load i32, i32* @stderr
%40 = load i32, i32* %5
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %38, %27
%47 = load i32, i32* %5
%48 = load i32, i32* @FE_HAS_LOCK
%49 = and i32 %47, %48
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %51, %46
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@FE_READ_STATUS = global i32 0
@FE_READ_SIGNAL_STRENGTH = global i32 0
@FE_READ_SNR = global i32 0
@FE_READ_BER = global i32 0
@FE_READ_UNCORRECTED_BLOCKS = global i32 0
@.str = [60 x i8] c"status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | \00"
@stderr = global i32 0
@.str.1 = [62 x i8] c"status %02x | signal %04x | snr %04x | ber %08x | unc %08x | \00"
@FE_HAS_LOCK = global i32 0
@.str.2 = [12 x i8] c"FE_HAS_LOCK\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_frontend_stats(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* @FE_READ_STATUS
%14 = call i32 @ioctl(i32 %0, i32 %13, i32* %3)
%15 = load i32, i32* @FE_READ_SIGNAL_STRENGTH
%16 = call i32 @ioctl(i32 %0, i32 %15, i32* %5)
%17 = load i32, i32* @FE_READ_SNR
%18 = call i32 @ioctl(i32 %0, i32 %17, i32* %4)
%19 = load i32, i32* @FE_READ_BER
%20 = call i32 @ioctl(i32 %0, i32 %19, i32* %6)
%21 = load i32, i32* @FE_READ_UNCORRECTED_BLOCKS
%22 = call i32 @ioctl(i32 %0, i32 %21, i32* %7)
%23 = icmp eq i32 %1, 0
br i1 %23, label %35, label %24
24: ; preds = %2
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 100
%28 = sdiv i32 %27, 65535
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, 100
%31 = sdiv i32 %30, 65535
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28, i32 %31, i32 %32, i32 %33)
br label %43
35: ; preds = %2
%36 = load i32, i32* @stderr
%37 = load i32, i32* %3
%38 = load i32, i32* %5
%39 = load i32, i32* %4
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40, i32 %41)
br label %43
43: ; preds = %35, %24
%44 = load i32, i32* %3
%45 = load i32, i32* @FE_HAS_LOCK
%46 = and i32 %45, %44
%47 = icmp eq i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %48, %43
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}