void manchesterWrite(char c, int T, void (*delay)(unsigned int),
                     void (*setLow)(void), void (*setHigh)(void)) {
  int i;
  setHigh();
  for (i = 7; i >= 0; i--) {
    if (0x01 & (c >> i)) {
      setLow();
      delay(T);
      setHigh();
      delay(T);
    } else {
      setHigh();
      delay(T);
      setLow();
      delay(T);
    }
  }
  setHigh();
}


x86 assembly (clang, -O0):
<manchesterWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
call   *-0x20(%rbp)
movl   $0x7,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     118e <manchesterWrite+0x8e>
movsbl -0x1(%rbp),%eax
mov    -0x24(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1163 <manchesterWrite+0x63>
call   *-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%edi
call   *%rax
call   *-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%edi
call   *%rax
jmp    117b <manchesterWrite+0x7b>
call   *-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%edi
call   *%rax
call   *-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%edi
call   *%rax
jmp    1180 <manchesterWrite+0x80>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1127 <manchesterWrite+0x27>
call   *-0x20(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manchesterWrite>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %esi,%r12d
mov    %edi,%r15d
call   *%r8
movd   %r15d,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xed1(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xed5(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%r15d
test   $0x80,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x40,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x20,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x10,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x8,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x4,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x2,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
mov    %rbp,%rcx
cmovne %rbx,%rcx
mov    %rcx,%r13
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%r13
mov    %r12d,%edi
call   *%r14
test   $0x1,%r15b
mov    %rbx,%rax
cmovne %rbp,%rax
cmove  %rbp,%rbx
call   *%rax
mov    %r12d,%edi
call   *%r14
call   *%rbx
mov    %r12d,%edi
call   *%r14
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    *%rax

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

LLVM IR (-O2):
define void @manchesterWrite(i8 signext %0, i32 %1, void (i32)* nocapture %2, void ()* nocapture %3, void ()* nocapture %4) {
tail call void %4()
%6 = zext i8 %0 to i32
%7 = insertelement <8 x i32> poison, i32 %6, i64 0
%8 = shufflevector <8 x i32> %7, <8 x i32> poison, <8 x i32> zeroinitializer
%9 = and <8 x i32> %8, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128>
%10 = icmp eq <8 x i32> %9, zeroinitializer
%11 = extractelement <8 x i1> %10, i64 7
%12 = select i1 %11, void ()* %4, void ()* %3
%13 = select i1 %11, void ()* %3, void ()* %4
tail call void %12()
tail call void %2(i32 %1)
tail call void %13()
tail call void %2(i32 %1)
%14 = extractelement <8 x i1> %10, i64 6
%15 = select i1 %14, void ()* %4, void ()* %3
%16 = select i1 %14, void ()* %3, void ()* %4
tail call void %15()
tail call void %2(i32 %1)
tail call void %16()
tail call void %2(i32 %1)
%17 = extractelement <8 x i1> %10, i64 5
%18 = select i1 %17, void ()* %4, void ()* %3
%19 = select i1 %17, void ()* %3, void ()* %4
tail call void %18()
tail call void %2(i32 %1)
tail call void %19()
tail call void %2(i32 %1)
%20 = extractelement <8 x i1> %10, i64 4
%21 = select i1 %20, void ()* %4, void ()* %3
%22 = select i1 %20, void ()* %3, void ()* %4
tail call void %21()
tail call void %2(i32 %1)
tail call void %22()
tail call void %2(i32 %1)
%23 = extractelement <8 x i1> %10, i64 3
%24 = select i1 %23, void ()* %4, void ()* %3
%25 = select i1 %23, void ()* %3, void ()* %4
tail call void %24()
tail call void %2(i32 %1)
tail call void %25()
tail call void %2(i32 %1)
%26 = extractelement <8 x i1> %10, i64 2
%27 = select i1 %26, void ()* %4, void ()* %3
%28 = select i1 %26, void ()* %3, void ()* %4
tail call void %27()
tail call void %2(i32 %1)
tail call void %28()
tail call void %2(i32 %1)
%29 = extractelement <8 x i1> %10, i64 1
%30 = select i1 %29, void ()* %4, void ()* %3
%31 = select i1 %29, void ()* %3, void ()* %4
tail call void %30()
tail call void %2(i32 %1)
tail call void %31()
tail call void %2(i32 %1)
%32 = extractelement <8 x i1> %10, i64 0
%33 = select i1 %32, void ()* %4, void ()* %3
%34 = select i1 %32, void ()* %3, void ()* %4
tail call void %33()
tail call void %2(i32 %1)
tail call void %34()
tail call void %2(i32 %1)
tail call void %4()
ret void
}