#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*/ GPIOPinWrite(int, int, int);
void LCD_write_byte(unsigned char dat, unsigned int cmd) {
  unsigned int i;
  GPIOPinWrite(0x40004000, 0x00000001, 0x00);
  if (cmd)
    GPIOPinWrite(0x40004000, 0x00000010, 0xff);
  else
    GPIOPinWrite(0x40004000, 0x00000010, 0x00);
  for (i = 0; i < 8; i++) {
    GPIOPinWrite(0x40004000, 0x00000008, 0x00);
    if (dat & 0x80)
      GPIOPinWrite(0x40004000, 0x00000004, 0xff);
    else
      GPIOPinWrite(0x40004000, 0x00000004, 0x00);
    dat <<= 1;
    GPIOPinWrite(0x40004000, 0x00000008, 0xff);
  }
  GPIOPinWrite(0x40004000, 0x00000001, 0xff);
}


x86 assembly (clang, -O0):
<LCD_write_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x40004000,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
cmpl   $0x0,-0x8(%rbp)
je     1155 <LCD_write_byte+0x45>
mov    $0x40004000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
jmp    1166 <LCD_write_byte+0x56>
mov    $0x40004000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jae    11f0 <LCD_write_byte+0xe0>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11b3 <LCD_write_byte+0xa3>
mov    $0x40004000,%edi
mov    $0x4,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
jmp    11c4 <LCD_write_byte+0xb4>
mov    $0x40004000,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <LCD_write_byte+0x5d>
mov    $0x40004000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCD_write_byte>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%r14d
xor    %ebx,%ebx
mov    $0x40004000,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   %ebp,%ebp
mov    $0xff,%r15d
cmovne %r15d,%ebp
mov    $0x40004000,%edi
mov    $0x10,%esi
mov    %ebp,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   %r14b,%r14b
mov    $0xff,%edx
cmovns %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x40,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x20,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x10,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x8,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x4,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x2,%r14b
mov    $0xff,%edx
cmove  %ebx,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
test   $0x1,%r14b
cmovne %r15d,%ebx
mov    $0x40004000,%edi
mov    $0x4,%esi
mov    %ebx,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <GPIOPinWrite@plt>

LLVM IR (-O0):
define void @LCD_write_byte(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 0)
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @GPIOPinWrite(i32 1073758208, i32 16, i32 255)
br label %13
11: ; preds = %2
%12 = call i32 @GPIOPinWrite(i32 1073758208, i32 16, i32 0)
br label %13
13: ; preds = %11, %9
store i32 0, i32* %5
br label %14
14: ; preds = %33, %13
%15 = load i32, i32* %5
%16 = icmp ult i32 %15, 8
br i1 %16, label %17, label %36
17: ; preds = %14
%18 = call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = and i32 %20, 128
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 255)
br label %27
25: ; preds = %17
%26 = call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 0)
br label %27
27: ; preds = %25, %23
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = shl i32 %29, 1
%31 = trunc i32 %30 to i8
store i8 %31, i8* %3
%32 = call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
br label %33
33: ; preds = %27
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %14
36: ; preds = %14
%37 = call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 255)
ret void
}

LLVM IR (-O2):
define void @LCD_write_byte(i8 zeroext %0, i32 %1) {
%3 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 0)
%4 = icmp eq i32 %1, 0
%5 = select i1 %4, i32 0, i32 255
%6 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 16, i32 %5)
%7 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%8 = icmp sgt i8 %0, -1
%9 = select i1 %8, i32 0, i32 255
%10 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %9)
%11 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%12 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%13 = and i8 %0, 64
%14 = icmp eq i8 %13, 0
%15 = select i1 %14, i32 0, i32 255
%16 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %15)
%17 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%18 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%19 = and i8 %0, 32
%20 = icmp eq i8 %19, 0
%21 = select i1 %20, i32 0, i32 255
%22 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %21)
%23 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%24 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%25 = and i8 %0, 16
%26 = icmp eq i8 %25, 0
%27 = select i1 %26, i32 0, i32 255
%28 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %27)
%29 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%30 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%31 = and i8 %0, 8
%32 = icmp eq i8 %31, 0
%33 = select i1 %32, i32 0, i32 255
%34 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %33)
%35 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%36 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%37 = and i8 %0, 4
%38 = icmp eq i8 %37, 0
%39 = select i1 %38, i32 0, i32 255
%40 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %39)
%41 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%42 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%43 = and i8 %0, 2
%44 = icmp eq i8 %43, 0
%45 = select i1 %44, i32 0, i32 255
%46 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %45)
%47 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%48 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%49 = and i8 %0, 1
%50 = icmp eq i8 %49, 0
%51 = select i1 %50, i32 0, i32 255
%52 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %51)
%53 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%54 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 255)
ret void
}