#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*/ outb(unsigned char, int);
int /*<<< orphan*/ usleep(int);
void palputdata(char ch) {
  int i = 0;
  unsigned char tmp = 0;
  unsigned char chjust = 0;
  for (i = 0; i < 8; i++) {
    tmp = ch & 1;
    tmp = tmp << 3;
    tmp = tmp & 8;
    outb(tmp, 0x378);
    usleep(10);
    tmp = tmp | 4;
    outb(tmp, 0x378);
    usleep(10);
    chjust = tmp - 4;
    outb(chjust, 0x378);
    usleep(2);
    ch = ch >> 1;
  }
  outb(0, 0x378);
}


x86 assembly (clang, -O0):
<palputdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11e0 <palputdata+0xc0>
movsbl -0x1(%rbp),%eax
and    $0x1,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
shl    $0x3,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
and    $0x8,%eax
mov    %al,-0x9(%rbp)
mov    $0x378,%esi
movzbl -0x9(%rbp),%edi
call   1030 <outb@plt>
mov    $0xa,%edi
call   1040 <usleep@plt>
movzbl -0x9(%rbp),%eax
or     $0x4,%eax
mov    %al,-0x9(%rbp)
mov    $0x378,%esi
movzbl -0x9(%rbp),%edi
call   1030 <outb@plt>
mov    $0xa,%edi
call   1040 <usleep@plt>
movzbl -0x9(%rbp),%eax
sub    $0x4,%eax
mov    %al,-0xa(%rbp)
mov    $0x378,%esi
movzbl -0xa(%rbp),%edi
call   1030 <outb@plt>
mov    $0x2,%edi
call   1040 <usleep@plt>
movsbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <palputdata+0x24>
xor    %edi,%edi
mov    $0x378,%esi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palputdata>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x8,%ebp
nopl   0x0(%rax,%rax,1)
lea    0x0(,%rbx,8),%eax
and    $0x8,%al
movzbl %al,%r14d
mov    %r14d,%edi
mov    $0x378,%esi
call   1030 <outb@plt>
mov    $0xa,%edi
call   1040 <usleep@plt>
lea    0x4(%r14),%eax
movzbl %al,%edi
mov    $0x378,%esi
call   1030 <outb@plt>
mov    $0xa,%edi
call   1040 <usleep@plt>
mov    %r14d,%edi
mov    $0x378,%esi
call   1030 <outb@plt>
mov    $0x2,%edi
call   1040 <usleep@plt>
sar    %bl
add    $0xffffffff,%ebp
jne    1130 <palputdata+0x10>
xor    %edi,%edi
mov    $0x378,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <outb@plt>

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

LLVM IR (-O2):
define void @palputdata(i8 signext %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %15, %2 ]
%4 = phi i8 [ %0, %1 ], [ %14, %2 ]
%5 = shl i8 %4, 3
%6 = and i8 %5, 8
%7 = tail call i32 @outb(i8 zeroext %6, i32 888)
%8 = tail call i32 @usleep(i32 10)
%9 = or i8 %6, 4
%10 = tail call i32 @outb(i8 zeroext %9, i32 888)
%11 = tail call i32 @usleep(i32 10)
%12 = tail call i32 @outb(i8 zeroext %6, i32 888)
%13 = tail call i32 @usleep(i32 2)
%14 = ashr i8 %4, 1
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 8
br i1 %16, label %17, label %2
17: ; preds = %2
%18 = tail call i32 @outb(i8 zeroext 0, i32 888)
ret void
}