#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 receiveByte(int);
void *receiveWord(int);
int /*<<< orphan*/ sendByte(int, unsigned int);
int /*<<< orphan*/ sendWord(int, int /*<<< orphan*/);
int /*<<< orphan*/ updateCarry(int, unsigned int *);
void tube_GBPB(unsigned int *reg) {
  unsigned int *ptr = reg + 4;
  sendByte(2, 0x16);
  sendWord(2, *ptr--);
  sendWord(2, *ptr--);
  sendWord(2, *ptr--);
  sendByte(2, *ptr--);
  sendByte(2, *ptr);
  ptr = reg + 4;
  *ptr-- = receiveWord(2);
  *ptr-- = receiveWord(2);
  *ptr-- = receiveWord(2);
  *ptr-- = receiveByte(2);
  updateCarry(receiveByte(2) & 0x80, reg);
  *ptr-- = receiveWord(2);
}


x86 assembly (clang, -O0):
<tube_GBPB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    $0x2,%edi
mov    $0x16,%esi
call   1070 <sendByte@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
mov    $0x2,%edi
call   1070 <sendByte@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    $0x2,%edi
call   1070 <sendByte@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    $0x2,%edi
call   1050 <receiveByte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    $0x2,%edi
call   1050 <receiveByte@plt>
mov    %eax,%edi
and    $0x80,%edi
mov    -0x8(%rbp),%rsi
call   1060 <updateCarry@plt>
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tube_GBPB>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2,%edi
mov    $0x16,%esi
call   1070 <sendByte@plt>
mov    0x10(%rbx),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    0xc(%rbx),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    0x8(%rbx),%esi
mov    $0x2,%edi
call   1040 <sendWord@plt>
mov    0x4(%rbx),%esi
mov    $0x2,%edi
call   1070 <sendByte@plt>
mov    (%rbx),%esi
mov    $0x2,%edi
call   1070 <sendByte@plt>
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,0x10(%rbx)
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,0xc(%rbx)
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,0x8(%rbx)
mov    $0x2,%edi
call   1050 <receiveByte@plt>
mov    %eax,0x4(%rbx)
mov    $0x2,%edi
call   1050 <receiveByte@plt>
and    $0x80,%eax
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <updateCarry@plt>
mov    $0x2,%edi
call   1030 <receiveWord@plt>
mov    %eax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @tube_GBPB(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = getelementptr inbounds i32, i32* %4, i64 4
store i32* %5, i32** %3
%6 = call i32 @sendByte(i32 2, i32 22)
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i32 -1
store i32* %8, i32** %3
%9 = load i32, i32* %7
%10 = call i32 @sendWord(i32 2, i32 %9)
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i32 -1
store i32* %12, i32** %3
%13 = load i32, i32* %11
%14 = call i32 @sendWord(i32 2, i32 %13)
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i32 -1
store i32* %16, i32** %3
%17 = load i32, i32* %15
%18 = call i32 @sendWord(i32 2, i32 %17)
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i32 -1
store i32* %20, i32** %3
%21 = load i32, i32* %19
%22 = call i32 @sendByte(i32 2, i32 %21)
%23 = load i32*, i32** %3
%24 = load i32, i32* %23
%25 = call i32 @sendByte(i32 2, i32 %24)
%26 = load i32*, i32** %2
%27 = getelementptr inbounds i32, i32* %26, i64 4
store i32* %27, i32** %3
%28 = call i8* @receiveWord(i32 2)
%29 = ptrtoint i8* %28 to i32
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i32 -1
store i32* %31, i32** %3
store i32 %29, i32* %30
%32 = call i8* @receiveWord(i32 2)
%33 = ptrtoint i8* %32 to i32
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i32 -1
store i32* %35, i32** %3
store i32 %33, i32* %34
%36 = call i8* @receiveWord(i32 2)
%37 = ptrtoint i8* %36 to i32
%38 = load i32*, i32** %3
%39 = getelementptr inbounds i32, i32* %38, i32 -1
store i32* %39, i32** %3
store i32 %37, i32* %38
%40 = call i32 @receiveByte(i32 2)
%41 = load i32*, i32** %3
%42 = getelementptr inbounds i32, i32* %41, i32 -1
store i32* %42, i32** %3
store i32 %40, i32* %41
%43 = call i32 @receiveByte(i32 2)
%44 = and i32 %43, 128
%45 = load i32*, i32** %2
%46 = call i32 @updateCarry(i32 %44, i32* %45)
%47 = call i8* @receiveWord(i32 2)
%48 = ptrtoint i8* %47 to i32
%49 = load i32*, i32** %3
%50 = getelementptr inbounds i32, i32* %49, i32 -1
store i32* %50, i32** %3
store i32 %48, i32* %49
ret void
}

LLVM IR (-O2):
define void @tube_GBPB(i32* %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 4
%3 = tail call i32 @sendByte(i32 2, i32 22)
%4 = getelementptr inbounds i32, i32* %0, i64 3
%5 = load i32, i32* %2
%6 = tail call i32 @sendWord(i32 2, i32 %5)
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = load i32, i32* %4
%9 = tail call i32 @sendWord(i32 2, i32 %8)
%10 = getelementptr inbounds i32, i32* %0, i64 1
%11 = load i32, i32* %7
%12 = tail call i32 @sendWord(i32 2, i32 %11)
%13 = load i32, i32* %10
%14 = tail call i32 @sendByte(i32 2, i32 %13)
%15 = load i32, i32* %0
%16 = tail call i32 @sendByte(i32 2, i32 %15)
%17 = tail call i8* @receiveWord(i32 2)
%18 = ptrtoint i8* %17 to i64
%19 = trunc i64 %18 to i32
store i32 %19, i32* %2
%20 = tail call i8* @receiveWord(i32 2)
%21 = ptrtoint i8* %20 to i64
%22 = trunc i64 %21 to i32
store i32 %22, i32* %4
%23 = tail call i8* @receiveWord(i32 2)
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
store i32 %25, i32* %7
%26 = tail call i32 @receiveByte(i32 2)
store i32 %26, i32* %10
%27 = tail call i32 @receiveByte(i32 2)
%28 = and i32 %27, 128
%29 = tail call i32 @updateCarry(i32 %28, i32* %0)
%30 = tail call i8* @receiveWord(i32 2)
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i32
store i32 %32, i32* %0
ret void
}