#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 */
scalar_t__ io_read_bit(int);
int elev_get_floor_sensor_signal(void) {
  if (io_read_bit((0x200 + 4)))
    return 0;
  else if (io_read_bit((0x200 + 5)))
    return 1;
  else if (io_read_bit((0x200 + 6)))
    return 2;
  else if (io_read_bit((0x200 + 7)))
    return 3;
  else
    return -1;
}


x86 assembly (clang, -O0):
<elev_get_floor_sensor_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x204,%edi
call   1030 <io_read_bit@plt>
cmp    $0x0,%rax
je     1138 <elev_get_floor_sensor_signal+0x28>
movl   $0x0,-0x4(%rbp)
jmp    119f <elev_get_floor_sensor_signal+0x8f>
mov    $0x205,%edi
call   1030 <io_read_bit@plt>
cmp    $0x0,%rax
je     1158 <elev_get_floor_sensor_signal+0x48>
movl   $0x1,-0x4(%rbp)
jmp    119f <elev_get_floor_sensor_signal+0x8f>
mov    $0x206,%edi
call   1030 <io_read_bit@plt>
cmp    $0x0,%rax
je     1178 <elev_get_floor_sensor_signal+0x68>
movl   $0x2,-0x4(%rbp)
jmp    119f <elev_get_floor_sensor_signal+0x8f>
mov    $0x207,%edi
call   1030 <io_read_bit@plt>
cmp    $0x0,%rax
je     1198 <elev_get_floor_sensor_signal+0x88>
movl   $0x3,-0x4(%rbp)
jmp    119f <elev_get_floor_sensor_signal+0x8f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elev_get_floor_sensor_signal>:
push   %rax
mov    $0x204,%edi
call   1030 <io_read_bit@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1127 <elev_get_floor_sensor_signal+0x17>
pop    %rcx
ret
mov    $0x205,%edi
call   1030 <io_read_bit@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1125 <elev_get_floor_sensor_signal+0x15>
mov    $0x206,%edi
call   1030 <io_read_bit@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
jne    1125 <elev_get_floor_sensor_signal+0x15>
mov    $0x207,%edi
call   1030 <io_read_bit@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
or     $0x3,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @elev_get_floor_sensor_signal() {
%1 = alloca i32
%2 = call i64 @io_read_bit(i32 516)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 0, i32* %1
br label %18
5: ; preds = %0
%6 = call i64 @io_read_bit(i32 517)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 1, i32* %1
br label %18
9: ; preds = %5
%10 = call i64 @io_read_bit(i32 518)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 2, i32* %1
br label %18
13: ; preds = %9
%14 = call i64 @io_read_bit(i32 519)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 3, i32* %1
br label %18
17: ; preds = %13
store i32 -1, i32* %1
br label %18
18: ; preds = %17, %16, %12, %8, %4
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @elev_get_floor_sensor_signal() {
%1 = tail call i64 @io_read_bit(i32 516)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call i64 @io_read_bit(i32 517)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call i64 @io_read_bit(i32 518)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i64 @io_read_bit(i32 519)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 -1, i32 3
br label %13
13: ; preds = %9, %6, %3, %0
%14 = phi i32 [ 0, %0 ], [ 1, %3 ], [ 2, %6 ], [ %12, %9 ]
ret i32 %14
}