#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 cs5463_write(unsigned char *dat, int num) {
  unsigned char i;
  while (num--) {
    for (i = 0; i < 8; i++) {
      GPIOPinWrite(0x40005000, 0x00000002, 0x00);
      if (*dat & 0x80) {
        GPIOPinWrite(0x40005000, 0x00000008, 0xff);
      } else {
        GPIOPinWrite(0x40005000, 0x00000008, 0x00);
      }
      GPIOPinWrite(0x40005000, 0x00000002, 0xff);
      *dat <<= 1;
    }
    dat++;
  }
  GPIOPinWrite(0x40005000, 0x00000002, 0x00);
}


x86 assembly (clang, -O0):
<cs5463_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11d2 <cs5463_write+0xc2>
movb   $0x0,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
cmp    $0x8,%eax
jge    11c1 <cs5463_write+0xb1>
mov    $0x40005000,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1183 <cs5463_write+0x73>
mov    $0x40005000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
jmp    1194 <cs5463_write+0x84>
mov    $0x40005000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40005000,%edi
mov    $0x2,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
shl    $0x1,%ecx
mov    %cl,(%rax)
mov    -0xd(%rbp),%al
add    $0x1,%al
mov    %al,-0xd(%rbp)
jmp    1137 <cs5463_write+0x27>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111f <cs5463_write+0xf>
mov    $0x40005000,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cs5463_write>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1193 <cs5463_write+0x83>
mov    %esi,%r14d
mov    %rdi,%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x8,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x40005000,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
cmpb   $0x0,0x0(%rbp)
mov    $0xff,%edx
cmovns %r15d,%edx
mov    $0x40005000,%edi
mov    $0x8,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40005000,%edi
mov    $0x2,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
shlb   0x0(%rbp)
add    $0xff,%bl
jne    1140 <cs5463_write+0x30>
add    $0x1,%rbp
add    $0xffffffff,%r14d
jne    1130 <cs5463_write+0x20>
mov    $0x40005000,%edi
mov    $0x2,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <GPIOPinWrite@plt>

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

LLVM IR (-O2):
define void @cs5463_write(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %23, label %4
4: ; preds = %2, %19
%5 = phi i32 [ %20, %19 ], [ %1, %2 ]
%6 = phi i8* [ %21, %19 ], [ %0, %2 ]
br label %7
7: ; preds = %4, %7
%8 = phi i8 [ 0, %4 ], [ %17, %7 ]
%9 = tail call i32 @GPIOPinWrite(i32 1073762304, i32 2, i32 0)
%10 = load i8, i8* %6
%11 = icmp sgt i8 %10, -1
%12 = select i1 %11, i32 0, i32 255
%13 = tail call i32 @GPIOPinWrite(i32 1073762304, i32 8, i32 %12)
%14 = tail call i32 @GPIOPinWrite(i32 1073762304, i32 2, i32 255)
%15 = load i8, i8* %6
%16 = shl i8 %15, 1
store i8 %16, i8* %6
%17 = add nuw nsw i8 %8, 1
%18 = icmp eq i8 %17, 8
br i1 %18, label %19, label %7
19: ; preds = %7
%20 = add nsw i32 %5, -1
%21 = getelementptr inbounds i8, i8* %6, i64 1
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %4
23: ; preds = %19, %2
%24 = tail call i32 @GPIOPinWrite(i32 1073762304, i32 2, i32 0)
ret void
}