#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_event {
  int /*<<< orphan*/ parameters;
  int /*<<< orphan*/ status;
};

/* Variables and functions */
int /*<<< orphan*/ FEDumpParameters(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FEDumpStatus(int /*<<< orphan*/ *);
int /*<<< orphan*/ FE_GET_EVENT;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct dvb_frontend_event *);
int /*<<< orphan*/ printf(char *);
int FEGetEvent(int fd) {
  struct dvb_frontend_event event;
  int result;
  while (!(ioctl(fd, FE_GET_EVENT, &event))) {
    printf("FE Event Status:");
    FEDumpStatus(&event.status);
    printf("\n");
    printf("FE Event Parameters:\n");
    FEDumpParameters(fd, &event.parameters);
  }
  return 0;
}


x86 assembly (clang, -O0):
<FEGetEvent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1175 <FEGetEvent+0x35>
jmp    11b7 <FEGetEvent+0x77>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1060 <FEDumpStatus@plt>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1030 <FEDumpParameters@plt>
jmp    114b <FEGetEvent+0xb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FEGetEvent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e6c(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rsp,%rdx
call   1070 <ioctl@plt>
test   %eax,%eax
jne    11dd <FEGetEvent+0x7d>
lea    0x4(%rsp),%r14
lea    0xe71(%rip),%r15
lea    0xe7b(%rip),%r12
mov    %rsp,%r13
nopl   0x0(%rax)
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1080 <FEDumpStatus@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r13,%rsi
call   1050 <FEDumpParameters@plt>
mov    0x0(%rbp),%esi
mov    %ebx,%edi
mov    %r13,%rdx
call   1070 <ioctl@plt>
test   %eax,%eax
je     11a0 <FEGetEvent+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.dvb_frontend_event = type { i32, i32 }
@FE_GET_EVENT = global i32 0
@.str = [17 x i8] c"FE Event Status:\00"
@str = [21 x i8] c"FE Event Parameters:\00"
define i32 @FEGetEvent(i32 %0) {
%2 = alloca %struct.dvb_frontend_event
%3 = bitcast %struct.dvb_frontend_event* %2 to i8*
%4 = load i32, i32* @FE_GET_EVENT
%5 = call i32 @ioctl(i32 %0, i32 %4, %struct.dvb_frontend_event* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = getelementptr inbounds %struct.dvb_frontend_event, %struct.dvb_frontend_event* %2, i64 0, i32 1
%9 = getelementptr inbounds %struct.dvb_frontend_event, %struct.dvb_frontend_event* %2, i64 0, i32 0
br label %10
10: ; preds = %7, %10
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @FEDumpStatus(i32* %8)
%13 = call i32 @putchar(i32 10)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%15 = call i32 @FEDumpParameters(i32 %0, i32* %9)
%16 = load i32, i32* @FE_GET_EVENT
%17 = call i32 @ioctl(i32 %0, i32 %16, %struct.dvb_frontend_event* %2)
%18 = icmp eq i32 %17, 0
br i1 %18, label %10, label %19
19: ; preds = %10, %1
ret i32 0
}