#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*/ error(char *);
int spi_transfer_w32(unsigned int *, unsigned int *);
unsigned int small1_pollreg(unsigned int id) {
  unsigned int CMD = ((id & 0xffff) << 16) | 0x4;
  unsigned int rbuf = 31;
  int ret = spi_transfer_w32(&CMD, &rbuf);
  if (ret)
    error("Cannot write");
  ret = spi_transfer_w32(&CMD, &rbuf);
  if (ret)
    error("Cannot write");
  return rbuf;
}


x86 assembly (clang, -O0):
<small1_pollreg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
shl    $0x10,%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1f,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <spi_transfer_w32@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1169 <small1_pollreg+0x49>
lea    0xe9c(%rip),%rdi
call   1030 <error@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <spi_transfer_w32@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     118f <small1_pollreg+0x6f>
lea    0xe76(%rip),%rdi
call   1030 <error@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<small1_pollreg>:
push   %rax
shl    $0x10,%edi
or     $0x4,%edi
mov    %edi,0x4(%rsp)
movl   $0x1f,(%rsp)
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <spi_transfer_w32@plt>
test   %eax,%eax
je     114f <small1_pollreg+0x2f>
lea    0xeb6(%rip),%rdi
call   1030 <error@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <spi_transfer_w32@plt>
test   %eax,%eax
je     116c <small1_pollreg+0x4c>
lea    0xe99(%rip),%rdi
call   1030 <error@plt>
mov    (%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Cannot write\00"
define i32 @small1_pollreg(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 65535
%8 = shl i32 %7, 16
%9 = or i32 %8, 4
store i32 %9, i32* %3
store i32 31, i32* %4
%10 = call i32 @spi_transfer_w32(i32* %3, i32* %4)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
%16 = call i32 @spi_transfer_w32(i32* %3, i32* %4)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"Cannot write\00"
define i32 @small1_pollreg(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = shl i32 %0, 16
%6 = or i32 %5, 4
store i32 %6, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 31, i32* %3
%8 = call i32 @spi_transfer_w32(i32* %2, i32* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = call i32 @spi_transfer_w32(i32* %2, i32* %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %3
ret i32 %18
}