#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*/ bcm2835_gpio_clr(int);
int /*<<< orphan*/ bcm2835_gpio_set(int);
void SpiPutc(unsigned char d) {
  int i, n;
  for (i = 0; i < 8; i++) {
    if (d & 0x80)
      bcm2835_gpio_set(10);
    else
      bcm2835_gpio_clr(10);
    d <<= 1;
    for (n = 0; n < 4; n++)
      bcm2835_gpio_clr(11);
    for (n = 0; n < 4; n++)
      bcm2835_gpio_set(11);
  }
}


x86 assembly (clang, -O0):
<SpiPutc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11d9 <SpiPutc+0xb9>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1160 <SpiPutc+0x40>
mov    $0xa,%edi
call   1030 <bcm2835_gpio_set@plt>
jmp    116a <SpiPutc+0x4a>
mov    $0xa,%edi
call   1040 <bcm2835_gpio_clr@plt>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    119d <SpiPutc+0x7d>
mov    $0xb,%edi
call   1040 <bcm2835_gpio_clr@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <SpiPutc+0x5b>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11c6 <SpiPutc+0xa6>
mov    $0xb,%edi
call   1030 <bcm2835_gpio_set@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <SpiPutc+0x84>
jmp    11cb <SpiPutc+0xab>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1135 <SpiPutc+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SpiPutc>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x8,%ebp
jmp    118c <SpiPutc+0x6c>
nopl   0x0(%rax)
call   1040 <bcm2835_gpio_clr@plt>
mov    $0xb,%edi
call   1040 <bcm2835_gpio_clr@plt>
mov    $0xb,%edi
call   1040 <bcm2835_gpio_clr@plt>
mov    $0xb,%edi
call   1040 <bcm2835_gpio_clr@plt>
mov    $0xb,%edi
call   1040 <bcm2835_gpio_clr@plt>
mov    $0xb,%edi
call   1030 <bcm2835_gpio_set@plt>
mov    $0xb,%edi
call   1030 <bcm2835_gpio_set@plt>
mov    $0xb,%edi
call   1030 <bcm2835_gpio_set@plt>
mov    $0xb,%edi
call   1030 <bcm2835_gpio_set@plt>
add    %bl,%bl
add    $0xffffffff,%ebp
je     119c <SpiPutc+0x7c>
mov    $0xa,%edi
test   %bl,%bl
jns    1130 <SpiPutc+0x10>
call   1030 <bcm2835_gpio_set@plt>
jmp    1135 <SpiPutc+0x15>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @SpiPutc(i8 zeroext %0) {
br label %2
2: ; preds = %1, %10
%3 = phi i32 [ 0, %1 ], [ %20, %10 ]
%4 = phi i8 [ %0, %1 ], [ %19, %10 ]
%5 = icmp sgt i8 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @bcm2835_gpio_set(i32 10)
br label %10
8: ; preds = %2
%9 = tail call i32 @bcm2835_gpio_clr(i32 10)
br label %10
10: ; preds = %8, %6
%11 = tail call i32 @bcm2835_gpio_clr(i32 11)
%12 = tail call i32 @bcm2835_gpio_clr(i32 11)
%13 = tail call i32 @bcm2835_gpio_clr(i32 11)
%14 = tail call i32 @bcm2835_gpio_clr(i32 11)
%15 = tail call i32 @bcm2835_gpio_set(i32 11)
%16 = tail call i32 @bcm2835_gpio_set(i32 11)
%17 = tail call i32 @bcm2835_gpio_set(i32 11)
%18 = tail call i32 @bcm2835_gpio_set(i32 11)
%19 = shl i8 %4, 1
%20 = add nuw nsw i32 %3, 1
%21 = icmp eq i32 %20, 8
br i1 %21, label %22, label %2
22: ; preds = %10
ret void
}