int c2_read_ar(struct c2interface *c2if, unsigned char *addr) {
  int i;
  c2d_set(c2if, 1);
  c2ck_strobe(c2if);
  c2d_set(c2if, 0);
  c2ck_strobe(c2if);
  c2d_set(c2if, 1);
  c2ck_strobe(c2if);
  c2d_set(c2if, 1);
  *addr = 0;
  for (i = 0; i < 8; i++) {
    *addr >>= 1;
    c2ck_strobe(c2if);
    if (c2d_get(c2if))
      *addr |= 0x80;
  }
  c2ck_strobe(c2if);
  printf("%s: 0x%02X\n", __func__, *addr);
  return 0;
}


x86 assembly (clang, -O0):
<c2_read_ar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <c2d_set@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <c2ck_strobe@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <c2d_set@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <c2ck_strobe@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <c2d_set@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <c2ck_strobe@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <c2d_set@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1213 <c2_read_ar+0xd3>
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
sar    $0x1,%ecx
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <c2ck_strobe@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <c2d_get@plt>
cmp    $0x0,%eax
je     1200 <c2_read_ar+0xc0>
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
or     $0x80,%ecx
mov    %cl,(%rax)
jmp    1205 <c2_read_ar+0xc5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <c2_read_ar+0x7c>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <c2ck_strobe@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edx
lea    0xdd4(%rip),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c2_read_ar>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <c2d_set@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <c2d_set@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <c2d_set@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <c2d_set@plt>
movb   $0x0,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
mov    (%r14),%cl
shr    %cl
movzbl %cl,%edx
or     $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmove  %edx,%eax
mov    %al,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <c2d_get@plt>
test   %eax,%eax
je     12e4 <c2_read_ar+0x1a4>
orb    $0x80,(%r14)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <c2ck_strobe@plt>
movzbl (%r14),%edx
lea    0xd07(%rip),%rdi
lea    0xd0c(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.c2interface = type opaque
@.str = [12 x i8] c"%s: 0x%02X\0A\00"
@__func__.c2_read_ar = [11 x i8] c"c2_read_ar\00"
define i32 @c2_read_ar(%struct.c2interface* %0, i8* %1) {
%3 = alloca %struct.c2interface*
%4 = alloca i8*
%5 = alloca i32
store %struct.c2interface* %0, %struct.c2interface** %3
store i8* %1, i8** %4
%6 = load %struct.c2interface*, %struct.c2interface** %3
%7 = call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %6, i32 1)
%8 = load %struct.c2interface*, %struct.c2interface** %3
%9 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %8)
%10 = load %struct.c2interface*, %struct.c2interface** %3
%11 = call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %10, i32 0)
%12 = load %struct.c2interface*, %struct.c2interface** %3
%13 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %12)
%14 = load %struct.c2interface*, %struct.c2interface** %3
%15 = call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %14, i32 1)
%16 = load %struct.c2interface*, %struct.c2interface** %3
%17 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %16)
%18 = load %struct.c2interface*, %struct.c2interface** %3
%19 = call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %18, i32 1)
%20 = load i8*, i8** %4
store i8 0, i8* %20
store i32 0, i32* %5
br label %21
21: ; preds = %42, %2
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %45
24: ; preds = %21
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = ashr i32 %27, 1
%29 = trunc i32 %28 to i8
store i8 %29, i8* %25
%30 = load %struct.c2interface*, %struct.c2interface** %3
%31 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %30)
%32 = load %struct.c2interface*, %struct.c2interface** %3
%33 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %24
%36 = load i8*, i8** %4
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = or i32 %38, 128
%40 = trunc i32 %39 to i8
store i8 %40, i8* %36
br label %41
41: ; preds = %35, %24
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %21
45: ; preds = %21
%46 = load %struct.c2interface*, %struct.c2interface** %3
%47 = call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %46)
%48 = load i8*, i8** %4
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.c2_read_ar, i64 0, i64 0), i32 %50)
ret i32 0
}

LLVM IR (-O2):
%struct.c2interface = type opaque
@.str = [12 x i8] c"%s: 0x%02X\0A\00"
@__func__.c2_read_ar = [11 x i8] c"c2_read_ar\00"
define i32 @c2_read_ar(%struct.c2interface* %0, i8* nocapture %1) {
%3 = tail call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %0, i32 1)
%4 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%5 = tail call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %0, i32 0)
%6 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%7 = tail call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %0, i32 1)
%8 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%9 = tail call i32 (%struct.c2interface*, i32, ...) bitcast (i32 (...)* @c2d_set to i32 (%struct.c2interface*, i32, ...)*)(%struct.c2interface* %0, i32 1)
store i8 0, i8* %1
%10 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%11 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%12 = icmp eq i32 %11, 0
%13 = load i8, i8* %1
%14 = lshr i8 %13, 1
%15 = or i8 %14, 64
%16 = select i1 %12, i8 %14, i8 %15
store i8 %16, i8* %1
%17 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%18 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%19 = icmp eq i32 %18, 0
%20 = load i8, i8* %1
%21 = lshr i8 %20, 1
%22 = or i8 %21, 64
%23 = select i1 %19, i8 %21, i8 %22
store i8 %23, i8* %1
%24 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%25 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%26 = icmp eq i32 %25, 0
%27 = load i8, i8* %1
%28 = lshr i8 %27, 1
%29 = or i8 %28, 64
%30 = select i1 %26, i8 %28, i8 %29
store i8 %30, i8* %1
%31 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%32 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%33 = icmp eq i32 %32, 0
%34 = load i8, i8* %1
%35 = lshr i8 %34, 1
%36 = or i8 %35, 64
%37 = select i1 %33, i8 %35, i8 %36
store i8 %37, i8* %1
%38 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%39 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%40 = icmp eq i32 %39, 0
%41 = load i8, i8* %1
%42 = lshr i8 %41, 1
%43 = or i8 %42, 64
%44 = select i1 %40, i8 %42, i8 %43
store i8 %44, i8* %1
%45 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%46 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%47 = icmp eq i32 %46, 0
%48 = load i8, i8* %1
%49 = lshr i8 %48, 1
%50 = or i8 %49, 64
%51 = select i1 %47, i8 %49, i8 %50
store i8 %51, i8* %1
%52 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%53 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%54 = icmp eq i32 %53, 0
%55 = load i8, i8* %1
%56 = lshr i8 %55, 1
%57 = or i8 %56, 64
%58 = select i1 %54, i8 %56, i8 %57
store i8 %58, i8* %1
%59 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%60 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2d_get to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%61 = icmp eq i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %2
%63 = load i8, i8* %1
%64 = or i8 %63, -128
store i8 %64, i8* %1
br label %65
65: ; preds = %62, %2
%66 = tail call i32 (%struct.c2interface*, ...) bitcast (i32 (...)* @c2ck_strobe to i32 (%struct.c2interface*, ...)*)(%struct.c2interface* %0)
%67 = load i8, i8* %1
%68 = zext i8 %67 to i32
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.c2_read_ar, i64 0, i64 0), i32 %68)
ret i32 0
}