#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 */
struct dvb_frontend_parameters {
  int dummy;
};
struct dvb_frontend_info {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ FEDumpParameters(int, struct dvb_frontend_parameters *);
int /*<<< orphan*/ FE_GET_FRONTEND;
int ioctl(int, int /*<<< orphan*/, struct dvb_frontend_parameters *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int FEGetFrontend(int fd) {
  struct dvb_frontend_info info;
  struct dvb_frontend_parameters parameters;
  int result;
  if ((result = ioctl(fd, FE_GET_FRONTEND, &parameters)) < 0) {
    perror("FE_GET_FRONTEND");
    return result;
  }
  printf("FE Parameters:\n");
  FEDumpParameters(fd, &parameters);
  return 0;
}


x86 assembly (clang, -O0):
<FEGetFrontend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1183 <FEGetFrontend+0x43>
lea    0xe8d(%rip),%rdi
call   1060 <perror@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <FEGetFrontend+0x62>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1030 <FEDumpParameters@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FEGetFrontend>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2eac(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1050 <ioctl@plt>
test   %eax,%eax
js     117b <FEGetFrontend+0x3b>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1040 <FEDumpParameters@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe7c(%rip),%rdi
call   1060 <perror@plt>
jmp    1172 <FEGetFrontend+0x32>

LLVM IR (-O0):
%struct.dvb_frontend_info = type { i32 }
%struct.dvb_frontend_parameters = type { i32 }
@FE_GET_FRONTEND = global i32 0
@.str = [16 x i8] c"FE_GET_FRONTEND\00"
@.str.1 = [16 x i8] c"FE Parameters:\0A\00"
define i32 @FEGetFrontend(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.dvb_frontend_info
%5 = alloca %struct.dvb_frontend_parameters
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @FE_GET_FRONTEND
%9 = call i32 @ioctl(i32 %7, i32 %8, %struct.dvb_frontend_parameters* %5)
store i32 %9, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %6
store i32 %13, i32* %2
br label %18
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @FEDumpParameters(i32 %16, %struct.dvb_frontend_parameters* %5)
store i32 0, i32* %2
br label %18
18: ; preds = %14, %11
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
%struct.dvb_frontend_parameters = type { i32 }
@FE_GET_FRONTEND = global i32 0
@.str = [16 x i8] c"FE_GET_FRONTEND\00"
@str = [15 x i8] c"FE Parameters:\00"
define i32 @FEGetFrontend(i32 %0) {
%2 = alloca %struct.dvb_frontend_parameters
%3 = bitcast %struct.dvb_frontend_parameters* %2 to i8*
%4 = load i32, i32* @FE_GET_FRONTEND
%5 = call i32 @ioctl(i32 %0, i32 %4, %struct.dvb_frontend_parameters* %2)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %12
9: ; preds = %1
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%11 = call i32 @FEDumpParameters(i32 %0, %struct.dvb_frontend_parameters* %2)
br label %12
12: ; preds = %9, %7
%13 = phi i32 [ %5, %7 ], [ 0, %9 ]
ret i32 %13
}