void show_last_n_error_page(unsigned char *resp, int len, int show_pcb) {
  int k, num, pl, pc, pcb;
  unsigned char *ucp;
  char pcb_str[128];
  num = len - 4;
  ucp = &resp[0] + 4;
  if (num < 4) {
    printf("No error events logged\n");
    return;
  }
  printf("Last n error events log page\n");
  for (k = num; k > 0; k -= pl, ucp += pl) {
    if (k < 3) {
      printf("short Last n error events log page\n");
      return;
    }
    pl = ucp[3] + 4;
    pc = (ucp[0] << 8) + ucp[1];
    pcb = ucp[2];
    printf("  Error event %d:\n", pc);
    if (pl > 4) {
      if ((pcb & 0x1) && (pcb & 0x2)) {
        printf("    [binary]:\n");
        dStrHex((const char *)ucp + 4, pl - 4, 1);
      } else if (pcb & 0x1)
        printf("    %.*s\n", pl - 4, (const char *)(ucp + 4));
      else {
        printf("    [data counter?? (LP bit should be set)]:\n");
        dStrHex((const char *)ucp + 4, pl - 4, 1);
      }
    }
    if (show_pcb) {
      get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
      printf("        <%s>\n", pcb_str);
    }
  }
}


x86 assembly (clang, -O0):
<show_last_n_error_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1177 <show_last_n_error_page+0x47>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <show_last_n_error_page+0x1d5>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1305 <show_last_n_error_page+0x1d5>
cmpl   $0x3,-0x14(%rbp)
jge    11b2 <show_last_n_error_page+0x82>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <show_last_n_error_page+0x1d5>
mov    -0x30(%rbp),%rax
movzbl 0x3(%rax),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x30(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
movzbl 0x2(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x4,-0x1c(%rbp)
jle    12aa <show_last_n_error_page+0x17a>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1248 <show_last_n_error_page+0x118>
mov    -0x24(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1248 <show_last_n_error_page+0x118>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
add    $0x4,%rdi
mov    -0x1c(%rbp),%esi
sub    $0x4,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <dStrHex@plt>
jmp    12a5 <show_last_n_error_page+0x175>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1278 <show_last_n_error_page+0x148>
mov    -0x1c(%rbp),%esi
sub    $0x4,%esi
mov    -0x30(%rbp),%rdx
add    $0x4,%rdx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a0 <show_last_n_error_page+0x170>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
add    $0x4,%rdi
mov    -0x1c(%rbp),%esi
sub    $0x4,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <dStrHex@plt>
jmp    12a5 <show_last_n_error_page+0x175>
jmp    12aa <show_last_n_error_page+0x17a>
cmpl   $0x0,-0x10(%rbp)
je     12df <show_last_n_error_page+0x1af>
mov    -0x24(%rbp),%edi
lea    -0xb0(%rbp),%rsi
mov    $0x80,%edx
mov    $0x0,%al
call   1050 <get_pcb_str@plt>
lea    -0xb0(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e4 <show_last_n_error_page+0x1b4>
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    118b <show_last_n_error_page+0x5b>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_last_n_error_page>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
cmp    $0x7,%esi
jg     1173 <show_last_n_error_page+0x33>
lea    0xf2c(%rip),%rdi
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
add    $0xfffffffc,%ebp
add    $0x4,%rbx
mov    %rsp,%r12
jmp    11ac <show_last_n_error_page+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %r13,%rbx
sub    %r13d,%ebp
jle    1271 <show_last_n_error_page+0x131>
cmp    $0x2,%ebp
jbe    1265 <show_last_n_error_page+0x125>
movzbl 0x3(%rbx),%r13d
movzwl (%rbx),%esi
shl    $0x10,%esi
bswap  %esi
movzbl 0x2(%rbx),%r15d
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
je     1230 <show_last_n_error_page+0xf0>
mov    %r15d,%eax
not    %eax
test   $0x3,%al
jne    11f0 <show_last_n_error_page+0xb0>
lea    0xe6e(%rip),%rdi
jmp    11fd <show_last_n_error_page+0xbd>
nopl   0x0(%rax)
test   $0x1,%r15b
jne    1217 <show_last_n_error_page+0xd7>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rbx),%rdi
mov    %r13d,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <dStrHex@plt>
jmp    1230 <show_last_n_error_page+0xf0>
lea    0x4(%rbx),%rdx
lea    0xdf1(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
add    $0x4,%r13
test   %r14d,%r14d
je     11a0 <show_last_n_error_page+0x60>
mov    $0x80,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <get_pcb_str@plt>
lea    0xdc7(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <show_last_n_error_page+0x60>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"No error events logged\0A\00"
@.str.1 = [30 x i8] c"Last n error events log page\0A\00"
@.str.2 = [36 x i8] c"short Last n error events log page\0A\00"
@.str.3 = [19 x i8] c" Error event %d:\0A\00"
@.str.4 = [15 x i8] c" [binary]:\0A\00"
@.str.5 = [10 x i8] c" %.*s\0A\00"
@.str.6 = [46 x i8] c" [data counter?? (LP bit should be set)]:\0A\00"
@.str.7 = [14 x i8] c" <%s>\0A\00"
define void @show_last_n_error_page(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [128 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 4
store i32 %15, i32* %8
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 4
store i8* %18, i8** %12
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %110
23: ; preds = %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %8
store i32 %25, i32* %7
br label %26
26: ; preds = %102, %23
%27 = load i32, i32* %7
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %110
29: ; preds = %26
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 3
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %110
34: ; preds = %29
%35 = load i8*, i8** %12
%36 = getelementptr inbounds i8, i8* %35, i64 3
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = add nsw i32 %38, 4
store i32 %39, i32* %9
%40 = load i8*, i8** %12
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl i32 %43, 8
%45 = load i8*, i8** %12
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = add nsw i32 %44, %48
store i32 %49, i32* %10
%50 = load i8*, i8** %12
%51 = getelementptr inbounds i8, i8* %50, i64 2
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
store i32 %53, i32* %11
%54 = load i32, i32* %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %9
%57 = icmp sgt i32 %56, 4
br i1 %57, label %58, label %92
58: ; preds = %34
%59 = load i32, i32* %11
%60 = and i32 %59, 1
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %73
62: ; preds = %58
%63 = load i32, i32* %11
%64 = and i32 %63, 2
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%68 = load i8*, i8** %12
%69 = getelementptr inbounds i8, i8* %68, i64 4
%70 = load i32, i32* %9
%71 = sub nsw i32 %70, 4
%72 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @dStrHex to i32 (i8*, i32, i32, ...)*)(i8* %69, i32 %71, i32 1)
br label %91
73: ; preds = %62, %58
%74 = load i32, i32* %11
%75 = and i32 %74, 1
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %73
%78 = load i32, i32* %9
%79 = sub nsw i32 %78, 4
%80 = load i8*, i8** %12
%81 = getelementptr inbounds i8, i8* %80, i64 4
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %79, i8* %81)
br label %90
83: ; preds = %73
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%85 = load i8*, i8** %12
%86 = getelementptr inbounds i8, i8* %85, i64 4
%87 = load i32, i32* %9
%88 = sub nsw i32 %87, 4
%89 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @dStrHex to i32 (i8*, i32, i32, ...)*)(i8* %86, i32 %88, i32 1)
br label %90
90: ; preds = %83, %77
br label %91
91: ; preds = %90, %66
br label %92
92: ; preds = %91, %34
%93 = load i32, i32* %6
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %101
95: ; preds = %92
%96 = load i32, i32* %11
%97 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%98 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @get_pcb_str to i32 (i32, i8*, i64, ...)*)(i32 %96, i8* %97, i64 128)
%99 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %95, %92
br label %102
102: ; preds = %101
%103 = load i32, i32* %9
%104 = load i32, i32* %7
%105 = sub nsw i32 %104, %103
store i32 %105, i32* %7
%106 = load i32, i32* %9
%107 = load i8*, i8** %12
%108 = sext i32 %106 to i64
%109 = getelementptr inbounds i8, i8* %107, i64 %108
store i8* %109, i8** %12
br label %26
110: ; preds = %21, %32, %26
ret void
}

LLVM IR (-O2):
@.str.3 = [19 x i8] c" Error event %d:\0A\00"
@.str.5 = [10 x i8] c" %.*s\0A\00"
@.str.7 = [14 x i8] c" <%s>\0A\00"
@str = [29 x i8] c"Last n error events log page\00"
@str.8 = [45 x i8] c" [data counter?? (LP bit should be set)]:\00"
@str.9 = [14 x i8] c" [binary]:\00"
@str.10 = [35 x i8] c"short Last n error events log page\00"
@str.11 = [23 x i8] c"No error events logged\00"
define void @show_last_n_error_page(i8* %0, i32 %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %1, 8
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
br label %63
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%11 = add nsw i32 %1, -4
%12 = getelementptr inbounds i8, i8* %0, i64 4
%13 = icmp eq i32 %2, 0
br label %14
14: ; preds = %9, %58
%15 = phi i8* [ %12, %9 ], [ %61, %58 ]
%16 = phi i32 [ %11, %9 ], [ %59, %58 ]
%17 = icmp ult i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0))
br label %63
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %15, i64 3
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = add nuw nsw i32 %23, 4
%25 = load i8, i8* %15
%26 = zext i8 %25 to i32
%27 = shl nuw nsw i32 %26, 8
%28 = getelementptr inbounds i8, i8* %15, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = or i32 %27, %30
%32 = getelementptr inbounds i8, i8* %15, i64 2
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%36 = icmp eq i8 %22, 0
br i1 %36, label %54, label %37
37: ; preds = %20
%38 = and i32 %34, 3
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
%42 = getelementptr inbounds i8, i8* %15, i64 4
%43 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @dStrHex to i32 (i8*, i32, i32, ...)*)(i8* %42, i32 %23, i32 1)
br label %54
44: ; preds = %37
%45 = and i32 %34, 1
%46 = icmp eq i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = getelementptr inbounds i8, i8* %15, i64 4
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %23, i8* %48)
br label %54
50: ; preds = %44
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.8, i64 0, i64 0))
%52 = getelementptr inbounds i8, i8* %15, i64 4
%53 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @dStrHex to i32 (i8*, i32, i32, ...)*)(i8* %52, i32 %23, i32 1)
br label %54
54: ; preds = %40, %50, %47, %20
br i1 %13, label %58, label %55
55: ; preds = %54
%56 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @get_pcb_str to i32 (i32, i8*, i64, ...)*)(i32 %34, i8* %5, i64 128)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %5)
br label %58
58: ; preds = %54, %55
%59 = sub nsw i32 %16, %24
%60 = zext i32 %24 to i64
%61 = getelementptr inbounds i8, i8* %15, i64 %60
%62 = icmp sgt i32 %59, 0
br i1 %62, label %14, label %63
63: ; preds = %58, %18, %7
ret void
}