#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 sg_io_hdr {
  int status;
  scalar_t__ host_status;
  scalar_t__ driver_status;
};

/* Variables and functions */
int EIO;
int sg_io_errcheck(struct sg_io_hdr *hdp) {
  int status;
  status = hdp->status & 0x7e;
  if ((hdp->status & 0x7e) == 0 || hdp->host_status == 0 ||
      hdp->driver_status == 0)
    return 0;
  return EIO;
}


x86 assembly (clang, -O0):
<sg_io_errcheck>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x7e,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x7e,%eax
cmp    $0x0,%eax
je     1144 <sg_io_errcheck+0x44>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1144 <sg_io_errcheck+0x44>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jne    1150 <sg_io_errcheck+0x50>
movl   $0x0,-0x4(%rbp)
jmp    115c <sg_io_errcheck+0x5c>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sg_io_errcheck>:
xor    %eax,%eax
testb  $0x7e,(%rdi)
je     1120 <sg_io_errcheck+0x20>
cmpq   $0x0,0x8(%rdi)
je     1120 <sg_io_errcheck+0x20>
xor    %eax,%eax
cmpq   $0x0,0x10(%rdi)
je     1120 <sg_io_errcheck+0x20>
mov    0x2ec2(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.sg_io_hdr = type { i32, i64, i64 }
@EIO = global i32 0
define i32 @sg_io_errcheck(%struct.sg_io_hdr* %0) {
%2 = alloca i32
%3 = alloca %struct.sg_io_hdr*
%4 = alloca i32
store %struct.sg_io_hdr* %0, %struct.sg_io_hdr** %3
%5 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %3
%6 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = and i32 %7, 126
store i32 %8, i32* %4
%9 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %3
%10 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, 126
%13 = icmp eq i32 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %1
%15 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %3
%16 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %3
%21 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %20, i32 0, i32 2
%22 = load i64, i64* %21
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19, %14, %1
store i32 0, i32* %2
br label %27
25: ; preds = %19
%26 = load i32, i32* @EIO
store i32 %26, i32* %2
br label %27
27: ; preds = %25, %24
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
%struct.sg_io_hdr = type { i32, i64, i64 }
@EIO = global i32 0
define i32 @sg_io_errcheck(%struct.sg_io_hdr* nocapture %0) {
%2 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = and i32 %3, 126
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 1
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 2
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, 0
%14 = load i32, i32* @EIO
%15 = select i1 %13, i32 0, i32 %14
br label %16
16: ; preds = %10, %1, %6
%17 = phi i32 [ 0, %6 ], [ 0, %1 ], [ %15, %10 ]
ret i32 %17
}