#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*/ gpio_clr(int);
int /*<<< orphan*/ gpio_set(int);
int /*<<< orphan*/ reg_shift(short);
void reg_data(short byte) {
  byte &= 255;
  int i;
  for (i = 7; i >= 0; i--) {
    reg_shift((byte >> i) & 1);
  }
  gpio_set(1 << 17);
  gpio_clr(1 << 17);
}


x86 assembly (clang, -O0):
<reg_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x2(%rbp)
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     117f <reg_data+0x4f>
movswl -0x2(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
movswl %ax,%edi
call   1050 <reg_shift@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1153 <reg_data+0x23>
mov    $0x20000,%edi
call   1040 <gpio_set@plt>
mov    $0x20000,%edi
call   1030 <gpio_clr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg_data>:
push   %rbx
mov    %edi,%ebx
shr    $0x7,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    $0x6,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    $0x5,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    $0x4,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    $0x3,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    $0x2,%edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
mov    %ebx,%edi
shr    %edi
and    $0x1,%edi
call   1050 <reg_shift@plt>
and    $0x1,%ebx
mov    %ebx,%edi
call   1050 <reg_shift@plt>
mov    $0x20000,%edi
call   1040 <gpio_set@plt>
mov    $0x20000,%edi
pop    %rbx
jmp    1030 <gpio_clr@plt>

LLVM IR (-O0):
define void @reg_data(i16 signext %0) {
%2 = alloca i16
%3 = alloca i32
store i16 %0, i16* %2
%4 = load i16, i16* %2
%5 = sext i16 %4 to i32
%6 = and i32 %5, 255
%7 = trunc i32 %6 to i16
store i16 %7, i16* %2
store i32 7, i32* %3
br label %8
8: ; preds = %19, %1
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i16, i16* %2
%13 = sext i16 %12 to i32
%14 = load i32, i32* %3
%15 = ashr i32 %13, %14
%16 = and i32 %15, 1
%17 = trunc i32 %16 to i16
%18 = call i32 @reg_shift(i16 signext %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %3
%21 = add nsw i32 %20, -1
store i32 %21, i32* %3
br label %8
22: ; preds = %8
%23 = call i32 @gpio_set(i32 131072)
%24 = call i32 @gpio_clr(i32 131072)
ret void
}

LLVM IR (-O2):
define void @reg_data(i16 signext %0) {
%2 = lshr i16 %0, 7
%3 = and i16 %2, 1
%4 = tail call i32 @reg_shift(i16 signext %3)
%5 = lshr i16 %0, 6
%6 = and i16 %5, 1
%7 = tail call i32 @reg_shift(i16 signext %6)
%8 = lshr i16 %0, 5
%9 = and i16 %8, 1
%10 = tail call i32 @reg_shift(i16 signext %9)
%11 = lshr i16 %0, 4
%12 = and i16 %11, 1
%13 = tail call i32 @reg_shift(i16 signext %12)
%14 = lshr i16 %0, 3
%15 = and i16 %14, 1
%16 = tail call i32 @reg_shift(i16 signext %15)
%17 = lshr i16 %0, 2
%18 = and i16 %17, 1
%19 = tail call i32 @reg_shift(i16 signext %18)
%20 = lshr i16 %0, 1
%21 = and i16 %20, 1
%22 = tail call i32 @reg_shift(i16 signext %21)
%23 = and i16 %0, 1
%24 = tail call i32 @reg_shift(i16 signext %23)
%25 = tail call i32 @gpio_set(i32 131072)
%26 = tail call i32 @gpio_clr(i32 131072)
ret void
}