#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_info {
  int dummy;
};

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ FE_GET_INFO;
scalar_t__ ioctl(int, int /*<<< orphan*/, struct dvb_frontend_info *);
int /*<<< orphan*/ perror(char *);
int FEGetInfo(int fd, struct dvb_frontend_info *info) {
  int result;
  if (!info)
    return -EINVAL;
  if ((result = ioctl(fd, FE_GET_INFO, info) < 0)) {
    perror("FE_GET_INFO");
    return result;
  }
  return 0;
}


x86 assembly (clang, -O0):
<FEGetInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114d <FEGetInfo+0x2d>
xor    %eax,%eax
mov    0x2e95(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <FEGetInfo+0x7f>
mov    -0x8(%rbp),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x14(%rbp)
test   $0x1,%al
jne    1181 <FEGetInfo+0x61>
jmp    1198 <FEGetInfo+0x78>
lea    0xe78(%rip),%rdi
call   1040 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <FEGetInfo+0x7f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FEGetInfo>:
push   %rax
test   %rsi,%rsi
je     1143 <FEGetInfo+0x23>
mov    %rsi,%rdx
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1150 <FEGetInfo+0x30>
pop    %rcx
ret
mov    0x2e8e(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rcx
ret
lea    0xea9(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.dvb_frontend_info = type { i32 }
@EINVAL = global i32 0
@FE_GET_INFO = global i32 0
@.str = [12 x i8] c"FE_GET_INFO\00"
define i32 @FEGetInfo(i32 %0, %struct.dvb_frontend_info* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.dvb_frontend_info*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.dvb_frontend_info* %1, %struct.dvb_frontend_info** %5
%7 = load %struct.dvb_frontend_info*, %struct.dvb_frontend_info** %5
%8 = icmp ne %struct.dvb_frontend_info* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @EINVAL
%11 = sub nsw i32 0, %10
store i32 %11, i32* %3
br label %23
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i32, i32* @FE_GET_INFO
%15 = load %struct.dvb_frontend_info*, %struct.dvb_frontend_info** %5
%16 = call i64 @ioctl(i32 %13, i32 %14, %struct.dvb_frontend_info* %15)
%17 = icmp slt i64 %16, 0
%18 = zext i1 %17 to i32
store i32 %18, i32* %6
br i1 %17, label %19, label %22
19: ; preds = %12
%20 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %6
store i32 %21, i32* %3
br label %23
22: ; preds = %12
store i32 0, i32* %3
br label %23
23: ; preds = %22, %19, %9
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.dvb_frontend_info = type { i32 }
@EINVAL = global i32 0
@FE_GET_INFO = global i32 0
@.str = [12 x i8] c"FE_GET_INFO\00"
define i32 @FEGetInfo(i32 %0, %struct.dvb_frontend_info* %1) {
%3 = icmp eq %struct.dvb_frontend_info* %1, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @EINVAL
%6 = sub nsw i32 0, %5
br label %13
7: ; preds = %2
%8 = load i32, i32* @FE_GET_INFO
%9 = tail call i64 @ioctl(i32 %0, i32 %8, %struct.dvb_frontend_info* %1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %7, %11, %4
%14 = phi i32 [ 1, %11 ], [ %6, %4 ], [ 0, %7 ]
ret i32 %14
}