#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*/ usleep(int);
void send_pmh(int sleep_us, char *message, int len) {
  (*(volatile unsigned char *)(0xffffb3)) &= ~(1 << 3);
  for (short i = 0; i < len; i++) {
    for (short j = 7; j >= 0; j--) {
      (*(volatile unsigned char *)(0xffffb3)) &= ~(1 << 0);
      if (message[i] & (1 << j)) {
        (*(volatile unsigned char *)(0xffffb3)) |= (1 << 1);
      } else {
        (*(volatile unsigned char *)(0xffffb3)) &= ~(1 << 1);
      }
      usleep(sleep_us);
      (*(volatile unsigned char *)(0xffffb3)) |= (1 << 0);
      usleep(sleep_us);
    }
  }
  usleep(1);
  (*(volatile unsigned char *)(0xffffb3)) &= ~(1 << 2);
  usleep(1);
  (*(volatile unsigned char *)(0xffffb3)) |= (1 << 2);
}


x86 assembly (clang, -O0):
<send_pmh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xfffffff7,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
movw   $0x0,-0x16(%rbp)
movswl -0x16(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1217 <send_pmh+0x107>
movw   $0x7,-0x18(%rbp)
movswl -0x18(%rbp),%eax
cmp    $0x0,%eax
jl     1201 <send_pmh+0xf1>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xfffffffe,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movswq -0x16(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movswl -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11b4 <send_pmh+0xa4>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
or     $0x2,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
jmp    11ca <send_pmh+0xba>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xfffffffd,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edi
call   1030 <usleep@plt>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
or     $0x1,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edi
call   1030 <usleep@plt>
mov    -0x18(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x18(%rbp)
jmp    1151 <send_pmh+0x41>
jmp    1206 <send_pmh+0xf6>
mov    -0x16(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x16(%rbp)
jmp    113e <send_pmh+0x2e>
mov    $0x1,%edi
call   1030 <usleep@plt>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xfffffffb,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
mov    $0x1,%edi
call   1030 <usleep@plt>
mov    $0xffffb3,%eax
mov    (%rax),%al
movzbl %al,%eax
or     $0x4,%eax
mov    %al,%cl
mov    $0xffffb3,%eax
mov    %cl,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_pmh>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
andb   $0xf7,0xffffb3
f7
test   %edx,%edx
jle    1191 <send_pmh+0x81>
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
xor    %r12d,%r12d
nop
movswq %r12w,%r12
mov    $0x7,%ebx
nopl   0x0(%rax)
andb   $0xfe,0xffffb3
fe
movsbl (%r15,%r12,1),%eax
bt     %ebx,%eax
setb   %al
movzbl 0xffffb3,%ecx
and    $0xfd,%cl
add    %al,%al
or     %cl,%al
mov    %al,0xffffb3
mov    %ebp,%edi
call   1030 <usleep@plt>
orb    $0x1,0xffffb3
01
mov    %ebp,%edi
call   1030 <usleep@plt>
add    $0xffffffff,%ebx
jb     1140 <send_pmh+0x30>
add    $0x1,%r12d
movswl %r12w,%eax
cmp    %r14d,%eax
jl     1130 <send_pmh+0x20>
mov    $0x1,%edi
call   1030 <usleep@plt>
andb   $0xfb,0xffffb3
fb
mov    $0x1,%edi
call   1030 <usleep@plt>
orb    $0x4,0xffffb3
04
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @send_pmh(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i16
%8 = alloca i16
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%10 = zext i8 %9 to i32
%11 = and i32 %10, -9
%12 = trunc i32 %11 to i8
store volatile i8 %12, i8* inttoptr (i64 16777139 to i8*)
store i16 0, i16* %7
br label %13
13: ; preds = %62, %3
%14 = load i16, i16* %7
%15 = sext i16 %14 to i32
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %65
18: ; preds = %13
store i16 7, i16* %8
br label %19
19: ; preds = %58, %18
%20 = load i16, i16* %8
%21 = sext i16 %20 to i32
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %61
23: ; preds = %19
%24 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%25 = zext i8 %24 to i32
%26 = and i32 %25, -2
%27 = trunc i32 %26 to i8
store volatile i8 %27, i8* inttoptr (i64 16777139 to i8*)
%28 = load i8*, i8** %5
%29 = load i16, i16* %7
%30 = sext i16 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i16, i16* %8
%35 = sext i16 %34 to i32
%36 = shl i32 1, %35
%37 = and i32 %33, %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %23
%40 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%41 = zext i8 %40 to i32
%42 = or i32 %41, 2
%43 = trunc i32 %42 to i8
store volatile i8 %43, i8* inttoptr (i64 16777139 to i8*)
br label %49
44: ; preds = %23
%45 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%46 = zext i8 %45 to i32
%47 = and i32 %46, -3
%48 = trunc i32 %47 to i8
store volatile i8 %48, i8* inttoptr (i64 16777139 to i8*)
br label %49
49: ; preds = %44, %39
%50 = load i32, i32* %4
%51 = call i32 @usleep(i32 %50)
%52 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%53 = zext i8 %52 to i32
%54 = or i32 %53, 1
%55 = trunc i32 %54 to i8
store volatile i8 %55, i8* inttoptr (i64 16777139 to i8*)
%56 = load i32, i32* %4
%57 = call i32 @usleep(i32 %56)
br label %58
58: ; preds = %49
%59 = load i16, i16* %8
%60 = add i16 %59, -1
store i16 %60, i16* %8
br label %19
61: ; preds = %19
br label %62
62: ; preds = %61
%63 = load i16, i16* %7
%64 = add i16 %63, 1
store i16 %64, i16* %7
br label %13
65: ; preds = %13
%66 = call i32 @usleep(i32 1)
%67 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%68 = zext i8 %67 to i32
%69 = and i32 %68, -5
%70 = trunc i32 %69 to i8
store volatile i8 %70, i8* inttoptr (i64 16777139 to i8*)
%71 = call i32 @usleep(i32 1)
%72 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%73 = zext i8 %72 to i32
%74 = or i32 %73, 4
%75 = trunc i32 %74 to i8
store volatile i8 %75, i8* inttoptr (i64 16777139 to i8*)
ret void
}

LLVM IR (-O2):
define void @send_pmh(i32 %0, i8* nocapture %1, i32 %2) {
%4 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%5 = and i8 %4, -9
store volatile i8 %5, i8* inttoptr (i64 16777139 to i8*)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %11
7: ; preds = %3, %18
%8 = phi i16 [ %19, %18 ], [ 0, %3 ]
%9 = sext i16 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
br label %22
11: ; preds = %18, %3
%12 = tail call i32 @usleep(i32 1)
%13 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%14 = and i8 %13, -5
store volatile i8 %14, i8* inttoptr (i64 16777139 to i8*)
%15 = tail call i32 @usleep(i32 1)
%16 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%17 = or i8 %16, 4
store volatile i8 %17, i8* inttoptr (i64 16777139 to i8*)
ret void
18: ; preds = %22
%19 = add i16 %8, 1
%20 = sext i16 %19 to i32
%21 = icmp slt i32 %20, %2
br i1 %21, label %7, label %11
22: ; preds = %7, %22
%23 = phi i32 [ 7, %7 ], [ %39, %22 ]
%24 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%25 = and i8 %24, -2
store volatile i8 %25, i8* inttoptr (i64 16777139 to i8*)
%26 = load i8, i8* %10
%27 = sext i8 %26 to i32
%28 = shl nuw i32 1, %23
%29 = and i32 %28, %27
%30 = icmp eq i32 %29, 0
%31 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%32 = and i8 %31, -3
%33 = select i1 %30, i8 0, i8 2
%34 = or i8 %32, %33
store volatile i8 %34, i8* inttoptr (i64 16777139 to i8*)
%35 = tail call i32 @usleep(i32 %0)
%36 = load volatile i8, i8* inttoptr (i64 16777139 to i8*)
%37 = or i8 %36, 1
store volatile i8 %37, i8* inttoptr (i64 16777139 to i8*)
%38 = tail call i32 @usleep(i32 %0)
%39 = add nsw i32 %23, -1
%40 = icmp eq i32 %23, 0
br i1 %40, label %18, label %22
}