#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_8__ TYPE_4__;
typedef struct TYPE_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int /*<<< orphan*/ hierarchy_information;
  int /*<<< orphan*/ guard_interval;
  int /*<<< orphan*/ transmission_mode;
  int /*<<< orphan*/ constellation;
  int /*<<< orphan*/ code_rate_LP;
  int /*<<< orphan*/ code_rate_HP;
  int /*<<< orphan*/ bandwidth;
};
struct TYPE_6__ {
  int symbol_rate;
  void *fec_inner;
};
struct TYPE_5__ {
  int symbol_rate;
  int /*<<< orphan*/ modulation;
  void *fec_inner;
};
struct TYPE_8__ {
  TYPE_3__ ofdm;
  TYPE_2__ qpsk;
  TYPE_1__ qam;
};
struct dvb_frontend_parameters {
  int frequency;
  TYPE_4__ u;
  void *inversion;
};
struct dvb_frontend_info {
  scalar_t__ type;
};

/* Variables and functions */
int /*<<< orphan*/ BANDWIDTH_8_MHZ;
int /*<<< orphan*/ FEC_1_2;
int /*<<< orphan*/ FEC_2_3;
void *FEC_AUTO;
int /*<<< orphan*/ FEDumpBER(int);
int /*<<< orphan*/ FEDumpInfo(struct dvb_frontend_info *);
int /*<<< orphan*/ FEDumpSNR(int);
int /*<<< orphan*/ FEDumpSignalStrength(int);
int /*<<< orphan*/ FEGetEvent(int);
int /*<<< orphan*/ FEGetFrontend(int);
int /*<<< orphan*/ FEGetInfo(int, struct dvb_frontend_info *);
int /*<<< orphan*/ FEGetStatus(int);
int /*<<< orphan*/ FESetFrontend(int, struct dvb_frontend_parameters *);
int /*<<< orphan*/ FESetTone(int, int /*<<< orphan*/);
int /*<<< orphan*/ FESetVoltage(int, int /*<<< orphan*/);
scalar_t__ FE_OFDM;
scalar_t__ FE_QAM;
scalar_t__ FE_QPSK;
int /*<<< orphan*/ GUARD_INTERVAL_1_8;
int /*<<< orphan*/ HIERARCHY_NONE;
void *INVERSION_OFF;
int O_NONBLOCK;
int O_RDWR;
int /*<<< orphan*/ QAM_16;
int /*<<< orphan*/ QAM_64;
int /*<<< orphan*/ SEC_TONE_ON;
int /*<<< orphan*/ SEC_VOLTAGE_13;
int /*<<< orphan*/ TRANSMISSION_MODE_2K;
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int fe_fd;
  struct dvb_frontend_info fe_info;
  struct dvb_frontend_parameters fe_param;
  if ((fe_fd = open("/dev/dvb/adapter0/frontend0", O_RDWR | O_NONBLOCK)) < 0) {
    perror("FRONTEND DEVICE");
    return -1;
  }
  FEGetInfo(fe_fd, &fe_info);
  FEDumpInfo(&fe_info);
  FEGetStatus(fe_fd);
  if (fe_info.type == FE_QAM) {
    fe_param.frequency = 394000000;
    fe_param.frequency = 458000000;
    fe_param.inversion = INVERSION_OFF;
    fe_param.u.qam.symbol_rate = 6900000;
    fe_param.u.qam.fec_inner = FEC_AUTO;
    fe_param.u.qam.modulation = QAM_64;
  } else if (fe_info.type == FE_QPSK) {
    fe_param.frequency = 12669500 - 10600000;
    fe_param.inversion = INVERSION_OFF;
    fe_param.u.qpsk.symbol_rate = 22000000;
    fe_param.u.qpsk.fec_inner = FEC_AUTO;
    FESetVoltage(fe_fd, SEC_VOLTAGE_13);
    FESetTone(fe_fd, SEC_TONE_ON);
  } else if (fe_info.type == FE_OFDM) {
    fe_param.frequency = 730000000;
    fe_param.inversion = INVERSION_OFF;
    fe_param.u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
    fe_param.u.ofdm.code_rate_HP = FEC_2_3;
    fe_param.u.ofdm.code_rate_LP = FEC_1_2;
    fe_param.u.ofdm.constellation = QAM_16;
    fe_param.u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
    fe_param.u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
    fe_param.u.ofdm.hierarchy_information = HIERARCHY_NONE;
  } else {
    printf("invalid fe_info.type\n");
    close(fe_fd);
    return -1;
  }
  FESetFrontend(fe_fd, &fe_param);
  FEDumpBER(fe_fd);
  FEDumpSNR(fe_fd);
  FEDumpSignalStrength(fe_fd);
  FEGetFrontend(fe_fd);
  FEGetStatus(fe_fd);
  FEGetEvent(fe_fd);
  close(fe_fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
mov    0x2dc1(%rip),%rax
or     (%rax),%esi
lea    0xde8(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1241 <main+0x51>
lea    0xdec(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1410 <main+0x220>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1070 <FEGetInfo@plt>
lea    -0x10(%rbp),%rdi
call   1040 <FEDumpInfo@plt>
mov    -0x8(%rbp),%edi
call   10d0 <FEGetStatus@plt>
mov    -0x10(%rbp),%rax
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%rax
jne    12b4 <main+0xc4>
movl   $0x177bf680,-0x60(%rbp)
movl   $0x1b4c8680,-0x60(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x694920,-0x28(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    13c5 <main+0x1d5>
mov    -0x10(%rbp),%rax
mov    0x2cb9(%rip),%rcx
cmp    (%rcx),%rax
jne    1319 <main+0x129>
movl   $0x1f93fc,-0x60(%rbp)
mov    0x2caa(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x14fb180,-0x38(%rbp)
mov    0x2cd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
call   10a0 <FESetVoltage@plt>
mov    -0x8(%rbp),%edi
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
call   1060 <FESetTone@plt>
jmp    13c0 <main+0x1d0>
mov    -0x10(%rbp),%rax
mov    0x2c8c(%rip),%rcx
cmp    (%rcx),%rax
jne    139b <main+0x1ab>
movl   $0x2b82ea80,-0x60(%rbp)
mov    0x2c45(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2c73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2c37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2bdf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2c5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
jmp    13bb <main+0x1cb>
lea    0xc8a(%rip),%rdi
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1410 <main+0x220>
jmp    13c0 <main+0x1d0>
jmp    13c5 <main+0x1d5>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1100 <FESetFrontend@plt>
mov    -0x8(%rbp),%edi
call   10c0 <FEDumpBER@plt>
mov    -0x8(%rbp),%edi
call   1110 <FEDumpSNR@plt>
mov    -0x8(%rbp),%edi
call   10b0 <FEDumpSignalStrength@plt>
mov    -0x8(%rbp),%edi
call   1030 <FEGetFrontend@plt>
mov    -0x8(%rbp),%edi
call   10d0 <FEGetStatus@plt>
mov    -0x8(%rbp),%edi
call   1050 <FEGetEvent@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    0x2de2(%rip),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xdf0(%rip),%rdi
call   10e0 <open@plt>
test   %eax,%eax
js     13cd <main+0x1dd>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1080 <FEGetInfo@plt>
mov    %r14,%rdi
call   1040 <FEDumpInfo@plt>
mov    %ebx,%edi
call   10d0 <FEGetStatus@plt>
mov    (%rsp),%rax
mov    0x2d2a(%rip),%rcx
cmp    (%rcx),%rax
jne    128b <main+0x9b>
movl   $0x1b4c8680,0x8(%rsp)
1b
mov    0x2d26(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x50(%rsp)
movl   $0x694920,0x40(%rsp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x48(%rsp)
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x44(%rsp)
jmp    136c <main+0x17c>
mov    0x2ce6(%rip),%rcx
cmp    (%rcx),%rax
jne    12ea <main+0xfa>
movl   $0x1f93fc,0x8(%rsp)
mov    0x2cda(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x50(%rsp)
movl   $0x14fb180,0x30(%rsp)
01
mov    0x2d03(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x38(%rsp)
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10a0 <FESetVoltage@plt>
mov    0x2cc4(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1070 <FESetTone@plt>
jmp    136c <main+0x17c>
mov    0x2cbf(%rip),%rcx
cmp    (%rcx),%rax
jne    13b3 <main+0x1c3>
movl   $0x2b82ea80,0x8(%rsp)
2b
mov    0x2c77(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x50(%rsp)
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
mov    0x2c66(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2c2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2c8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1100 <FESetFrontend@plt>
mov    %ebx,%edi
call   10c0 <FEDumpBER@plt>
mov    %ebx,%edi
call   1110 <FEDumpSNR@plt>
mov    %ebx,%edi
call   10b0 <FEDumpSignalStrength@plt>
mov    %ebx,%edi
call   1030 <FEGetFrontend@plt>
mov    %ebx,%edi
call   10d0 <FEGetStatus@plt>
mov    %ebx,%edi
call   1050 <FEGetEvent@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
lea    0xc72(%rip),%rdi
call   1060 <puts@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    $0xffffffff,%eax
jmp    13ab <main+0x1bb>
lea    0xc48(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
jmp    13ab <main+0x1bb>

LLVM IR (-O0):
%struct.dvb_frontend_info = type { i64 }
%struct.dvb_frontend_parameters = type { i32, %struct.TYPE_8__, i8* }
%struct.TYPE_8__ = type { %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_7__ = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_6__ = type { i32, i8* }
%struct.TYPE_5__ = type { i32, i32, i8* }
@.str = [28 x i8] c"/dev/dvb/adapter0/frontend0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [16 x i8] c"FRONTEND DEVICE\00"
@FE_QAM = global i64 0
@INVERSION_OFF = global i8* null
@FEC_AUTO = global i8* null
@QAM_64 = global i32 0
@FE_QPSK = global i64 0
@SEC_VOLTAGE_13 = global i32 0
@SEC_TONE_ON = global i32 0
@FE_OFDM = global i64 0
@BANDWIDTH_8_MHZ = global i32 0
@FEC_2_3 = global i32 0
@FEC_1_2 = global i32 0
@QAM_16 = global i32 0
@TRANSMISSION_MODE_2K = global i32 0
@GUARD_INTERVAL_1_8 = global i32 0
@HIERARCHY_NONE = global i32 0
@.str.2 = [22 x i8] c"invalid fe_info.type\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.dvb_frontend_info
%4 = alloca %struct.dvb_frontend_parameters
store i32 0, i32* %1
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %5, %6
%8 = call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 %8, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %120
12: ; preds = %0
%13 = load i32, i32* %2
%14 = call i32 @FEGetInfo(i32 %13, %struct.dvb_frontend_info* %3)
%15 = call i32 @FEDumpInfo(%struct.dvb_frontend_info* %3)
%16 = load i32, i32* %2
%17 = call i32 @FEGetStatus(i32 %16)
%18 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %3, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @FE_QAM
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %12
%23 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 0
store i32 394000000, i32* %23
%24 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 0
store i32 458000000, i32* %24
%25 = load i8*, i8** @INVERSION_OFF
%26 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 2
store i8* %25, i8** %26
%27 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %27, i32 0, i32 2
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %28, i32 0, i32 0
store i32 6900000, i32* %29
%30 = load i8*, i8** @FEC_AUTO
%31 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %31, i32 0, i32 2
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %32, i32 0, i32 2
store i8* %30, i8** %33
%34 = load i32, i32* @QAM_64
%35 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %35, i32 0, i32 2
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i32 0, i32 1
store i32 %34, i32* %37
br label %103
38: ; preds = %12
%39 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %3, i32 0, i32 0
%40 = load i64, i64* %39
%41 = load i64, i64* @FE_QPSK
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %60
43: ; preds = %38
%44 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 0
store i32 2069500, i32* %44
%45 = load i8*, i8** @INVERSION_OFF
%46 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 2
store i8* %45, i8** %46
%47 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%48 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %47, i32 0, i32 1
%49 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %48, i32 0, i32 0
store i32 22000000, i32* %49
%50 = load i8*, i8** @FEC_AUTO
%51 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%52 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %51, i32 0, i32 1
%53 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %52, i32 0, i32 1
store i8* %50, i8** %53
%54 = load i32, i32* %2
%55 = load i32, i32* @SEC_VOLTAGE_13
%56 = call i32 @FESetVoltage(i32 %54, i32 %55)
%57 = load i32, i32* %2
%58 = load i32, i32* @SEC_TONE_ON
%59 = call i32 @FESetTone(i32 %57, i32 %58)
br label %102
60: ; preds = %38
%61 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %3, i32 0, i32 0
%62 = load i64, i64* %61
%63 = load i64, i64* @FE_OFDM
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %97
65: ; preds = %60
%66 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 0
store i32 730000000, i32* %66
%67 = load i8*, i8** @INVERSION_OFF
%68 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 2
store i8* %67, i8** %68
%69 = load i32, i32* @BANDWIDTH_8_MHZ
%70 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%71 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %70, i32 0, i32 0
%72 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %71, i32 0, i32 6
store i32 %69, i32* %72
%73 = load i32, i32* @FEC_2_3
%74 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%75 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %74, i32 0, i32 0
%76 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %75, i32 0, i32 5
store i32 %73, i32* %76
%77 = load i32, i32* @FEC_1_2
%78 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%79 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %78, i32 0, i32 0
%80 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %79, i32 0, i32 4
store i32 %77, i32* %80
%81 = load i32, i32* @QAM_16
%82 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%83 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %82, i32 0, i32 0
%84 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %83, i32 0, i32 3
store i32 %81, i32* %84
%85 = load i32, i32* @TRANSMISSION_MODE_2K
%86 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%87 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %86, i32 0, i32 0
%88 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %87, i32 0, i32 2
store i32 %85, i32* %88
%89 = load i32, i32* @GUARD_INTERVAL_1_8
%90 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%91 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %90, i32 0, i32 0
%92 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %91, i32 0, i32 1
store i32 %89, i32* %92
%93 = load i32, i32* @HIERARCHY_NONE
%94 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %4, i32 0, i32 1
%95 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %94, i32 0, i32 0
%96 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %95, i32 0, i32 0
store i32 %93, i32* %96
br label %101
97: ; preds = %60
%98 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%99 = load i32, i32* %2
%100 = call i32 @close(i32 %99)
store i32 -1, i32* %1
br label %120
101: ; preds = %65
br label %102
102: ; preds = %101, %43
br label %103
103: ; preds = %102, %22
%104 = load i32, i32* %2
%105 = call i32 @FESetFrontend(i32 %104, %struct.dvb_frontend_parameters* %4)
%106 = load i32, i32* %2
%107 = call i32 @FEDumpBER(i32 %106)
%108 = load i32, i32* %2
%109 = call i32 @FEDumpSNR(i32 %108)
%110 = load i32, i32* %2
%111 = call i32 @FEDumpSignalStrength(i32 %110)
%112 = load i32, i32* %2
%113 = call i32 @FEGetFrontend(i32 %112)
%114 = load i32, i32* %2
%115 = call i32 @FEGetStatus(i32 %114)
%116 = load i32, i32* %2
%117 = call i32 @FEGetEvent(i32 %116)
%118 = load i32, i32* %2
%119 = call i32 @close(i32 %118)
store i32 0, i32* %1
br label %120
120: ; preds = %103, %97, %10
%121 = load i32, i32* %1
ret i32 %121
}

LLVM IR (-O2):
%struct.dvb_frontend_info = type { i64 }
%struct.dvb_frontend_parameters = type { i32, %struct.TYPE_8__, i8* }
%struct.TYPE_8__ = type { %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_7__ = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_6__ = type { i32, i8* }
%struct.TYPE_5__ = type { i32, i32, i8* }
@.str = [28 x i8] c"/dev/dvb/adapter0/frontend0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [16 x i8] c"FRONTEND DEVICE\00"
@FE_QAM = global i64 0
@INVERSION_OFF = global i8* null
@FEC_AUTO = global i8* null
@QAM_64 = global i32 0
@FE_QPSK = global i64 0
@SEC_VOLTAGE_13 = global i32 0
@SEC_TONE_ON = global i32 0
@FE_OFDM = global i64 0
@BANDWIDTH_8_MHZ = global i32 0
@FEC_2_3 = global i32 0
@FEC_1_2 = global i32 0
@QAM_16 = global i32 0
@TRANSMISSION_MODE_2K = global i32 0
@GUARD_INTERVAL_1_8 = global i32 0
@HIERARCHY_NONE = global i32 0
@str = [21 x i8] c"invalid fe_info.type\00"
define i32 @main() {
%1 = alloca %struct.dvb_frontend_info
%2 = alloca %struct.dvb_frontend_parameters
%3 = bitcast %struct.dvb_frontend_info* %1 to i8*
%4 = bitcast %struct.dvb_frontend_parameters* %2 to i8*
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %76
12: ; preds = %0
%13 = call i32 @FEGetInfo(i32 %8, %struct.dvb_frontend_info* %1)
%14 = call i32 @FEDumpInfo(%struct.dvb_frontend_info* %1)
%15 = call i32 @FEGetStatus(i32 %8)
%16 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %1, i64 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @FE_QAM
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %12
%21 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 0
store i32 458000000, i32* %21
%22 = load i8*, i8** @INVERSION_OFF
%23 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 2
store i8* %22, i8** %23
%24 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 2, i32 0
store i32 6900000, i32* %24
%25 = load i8*, i8** @FEC_AUTO
%26 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 2, i32 2
store i8* %25, i8** %26
%27 = load i32, i32* @QAM_64
%28 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 2, i32 1
store i32 %27, i32* %28
br label %67
29: ; preds = %12
%30 = load i64, i64* @FE_QPSK
%31 = icmp eq i64 %17, %30
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 0
store i32 2069500, i32* %33
%34 = load i8*, i8** @INVERSION_OFF
%35 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 2
store i8* %34, i8** %35
%36 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 1, i32 0
store i32 22000000, i32* %36
%37 = load i8*, i8** @FEC_AUTO
%38 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 1, i32 1
store i8* %37, i8** %38
%39 = load i32, i32* @SEC_VOLTAGE_13
%40 = call i32 @FESetVoltage(i32 %8, i32 %39)
%41 = load i32, i32* @SEC_TONE_ON
%42 = call i32 @FESetTone(i32 %8, i32 %41)
br label %67
43: ; preds = %29
%44 = load i64, i64* @FE_OFDM
%45 = icmp eq i64 %17, %44
br i1 %45, label %46, label %64
46: ; preds = %43
%47 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 0
store i32 730000000, i32* %47
%48 = load i8*, i8** @INVERSION_OFF
%49 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 2
store i8* %48, i8** %49
%50 = load i32, i32* @BANDWIDTH_8_MHZ
%51 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 6
store i32 %50, i32* %51
%52 = load i32, i32* @FEC_2_3
%53 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 5
store i32 %52, i32* %53
%54 = load i32, i32* @FEC_1_2
%55 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 4
store i32 %54, i32* %55
%56 = load i32, i32* @QAM_16
%57 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 3
store i32 %56, i32* %57
%58 = load i32, i32* @TRANSMISSION_MODE_2K
%59 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 2
store i32 %58, i32* %59
%60 = load i32, i32* @GUARD_INTERVAL_1_8
%61 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 1
store i32 %60, i32* %61
%62 = load i32, i32* @HIERARCHY_NONE
%63 = getelementptr inbounds %struct.dvb_frontend_parameters, %struct.dvb_frontend_parameters* %2, i64 0, i32 1, i32 0, i32 0
store i32 %62, i32* %63
br label %67
64: ; preds = %43
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%66 = call i32 @close(i32 %8)
br label %76
67: ; preds = %32, %46, %20
%68 = call i32 @FESetFrontend(i32 %8, %struct.dvb_frontend_parameters* %2)
%69 = call i32 @FEDumpBER(i32 %8)
%70 = call i32 @FEDumpSNR(i32 %8)
%71 = call i32 @FEDumpSignalStrength(i32 %8)
%72 = call i32 @FEGetFrontend(i32 %8)
%73 = call i32 @FEGetStatus(i32 %8)
%74 = call i32 @FEGetEvent(i32 %8)
%75 = call i32 @close(i32 %8)
br label %76
76: ; preds = %67, %64, %10
%77 = phi i32 [ -1, %10 ], [ 0, %67 ], [ -1, %64 ]
ret i32 %77
}