#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 */

/* Variables and functions */
int /*<<< orphan*/ FE_READ_SIGNAL_STRENGTH;
scalar_t__ ioctl(int, int /*<<< orphan*/, unsigned short *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned short);
int FEDumpSignalStrength(int fd) {
  unsigned short sig_str;
  int result;
  if ((result = ioctl(fd, FE_READ_SIGNAL_STRENGTH, &sig_str) < 0)) {
    perror("FE_READ_SIGNAL_STRENGTH");
    return result;
  }
  printf("FE SIGNAL STRENGTH: %d\n", sig_str);
  return 0;
}


x86 assembly (clang, -O0):
<FEDumpSignalStrength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
lea    -0xa(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x10(%rbp)
test   $0x1,%al
jne    116f <FEDumpSignalStrength+0x3f>
jmp    1186 <FEDumpSignalStrength+0x56>
lea    0xe8a(%rip),%rdi
call   1050 <perror@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <FEDumpSignalStrength+0x6d>
lea    0xe8b(%rip),%rdi
movzwl -0xa(%rbp),%esi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FEDumpSignalStrength>:
push   %rax
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
lea    0x6(%rsp),%rdx
call   1040 <ioctl@plt>
test   %rax,%rax
js     115e <FEDumpSignalStrength+0x2e>
movzwl 0x6(%rsp),%esi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe9b(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@FE_READ_SIGNAL_STRENGTH = global i32 0
@.str = [24 x i8] c"FE_READ_SIGNAL_STRENGTH\00"
@.str.1 = [24 x i8] c"FE SIGNAL STRENGTH: %d\0A\00"
define i32 @FEDumpSignalStrength(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i16
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = load i32, i32* @FE_READ_SIGNAL_STRENGTH
%8 = call i64 @ioctl(i32 %6, i32 %7, i16* %4)
%9 = icmp slt i64 %8, 0
%10 = zext i1 %9 to i32
store i32 %10, i32* %5
br i1 %9, label %11, label %14
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %5
store i32 %13, i32* %2
br label %17
14: ; preds = %1
%15 = load i16, i16* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %15)
store i32 0, i32* %2
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@FE_READ_SIGNAL_STRENGTH = global i32 0
@.str = [24 x i8] c"FE_READ_SIGNAL_STRENGTH\00"
@.str.1 = [24 x i8] c"FE SIGNAL STRENGTH: %d\0A\00"
define i32 @FEDumpSignalStrength(i32 %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = load i32, i32* @FE_READ_SIGNAL_STRENGTH
%5 = call i64 @ioctl(i32 %0, i32 %4, i16* %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %12
9: ; preds = %1
%10 = load i16, i16* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %10)
br label %12
12: ; preds = %9, %7
%13 = phi i32 [ 1, %7 ], [ 0, %9 ]
ret i32 %13
}