#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int crc_calc(unsigned char const *);
int /*<<< orphan*/ crc_ok(unsigned char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void hexdumpedid(FILE *f, const unsigned char *edid, unsigned size) {
  unsigned b, i, j;
  for (b = 0; b < size / 128; b++) {
    const unsigned char *buf = edid + 128 * b;
    if (b)
      fprintf(f, "\n");
    for (i = 0; i < 128; i += 0x10) {
      fprintf(f, "%02x", buf[i]);
      for (j = 1; j < 0x10; j++) {
        fprintf(f, " %02x", buf[i + j]);
      }
      fprintf(f, "\n");
    }
    if (!crc_ok(buf))
      fprintf(f, "Block %u has a checksum error (should be 0x%02x)\n", b,
              crc_calc(buf));
  }
}


x86 assembly (clang, -O0):
<hexdumpedid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    $0x7,%ecx
cmp    %ecx,%eax
jae    126f <hexdumpedid+0x13f>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x7,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     118a <hexdumpedid+0x5a>
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x80,-0x1c(%rbp)
jae    121c <hexdumpedid+0xec>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jae    11fc <hexdumpedid+0xcc>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <hexdumpedid+0x92>
mov    -0x8(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <hexdumpedid+0x61>
mov    -0x28(%rbp),%rdi
call   1030 <crc_ok@plt>
cmp    $0x0,%eax
jne    125c <hexdumpedid+0x12c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <crc_calc@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1261 <hexdumpedid+0x131>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <hexdumpedid+0x1a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdumpedid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdx,(%rsp)
cmp    $0x80,%edx
jae    116e <hexdumpedid+0x2e>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%rbx
mov    (%rsp),%rax
shr    $0x7,%eax
mov    %rax,(%rsp)
mov    0x8(%rsp),%rax
lea    0xf(%rax),%r15
lea    0xe75(%rip),%r12
lea    0xe6d(%rip),%r13
xor    %ebp,%ebp
jmp    11ae <hexdumpedid+0x6e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
sub    $0xffffffffffffff80,%r15
cmp    (%rsp),%rbp
je     115f <hexdumpedid+0x1f>
mov    %rbp,%r14
shl    $0x7,%r14
mov    %rbp,0x10(%rsp)
test   %rbp,%rbp
je     11cc <hexdumpedid+0x8c>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    0x8(%rsp),%r14
mov    %r14,%rbp
mov    $0xfffffffffffffff0,%r14
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x2(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x3(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x4(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x5(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x6(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x7(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x8(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x9(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xa(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xb(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xc(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xd(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xe(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0xf(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x10(%r15,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x10,%r14
cmp    $0x70,%r14
jb     11e0 <hexdumpedid+0xa0>
mov    %rbp,%r14
mov    %rbp,%rdi
call   1040 <crc_ok@plt>
test   %eax,%eax
mov    0x10(%rsp),%rbp
jne    11a0 <hexdumpedid+0x60>
mov    %r14,%rdi
call   1060 <crc_calc@plt>
mov    %rbx,%rdi
lea    0xcb1(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11a0 <hexdumpedid+0x60>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [50 x i8] c"Block %u has a checksum error (should be 0x%02x)\0A\00"
define void @hexdumpedid(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %74, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = udiv i32 %13, 128
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %77
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = mul i32 128, %18
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
store i8* %21, i8** %10
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32*, i32** %4
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %24, %16
store i32 0, i32* %8
br label %28
28: ; preds = %60, %27
%29 = load i32, i32* %8
%30 = icmp ult i32 %29, 128
br i1 %30, label %31, label %63
31: ; preds = %28
%32 = load i32*, i32** %4
%33 = load i8*, i8** %10
%34 = load i32, i32* %8
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %38)
store i32 1, i32* %9
br label %40
40: ; preds = %54, %31
%41 = load i32, i32* %9
%42 = icmp ult i32 %41, 16
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i32*, i32** %4
%45 = load i8*, i8** %10
%46 = load i32, i32* %8
%47 = load i32, i32* %9
%48 = add i32 %46, %47
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %45, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %43
%55 = load i32, i32* %9
%56 = add i32 %55, 1
store i32 %56, i32* %9
br label %40
57: ; preds = %40
%58 = load i32*, i32** %4
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %60
60: ; preds = %57
%61 = load i32, i32* %8
%62 = add i32 %61, 16
store i32 %62, i32* %8
br label %28
63: ; preds = %28
%64 = load i8*, i8** %10
%65 = call i32 @crc_ok(i8* %64)
%66 = icmp ne i32 %65, 0
br i1 %66, label %73, label %67
67: ; preds = %63
%68 = load i32*, i32** %4
%69 = load i32, i32* %7
%70 = load i8*, i8** %10
%71 = call i32 @crc_calc(i8* %70)
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %69, i32 %71)
br label %73
73: ; preds = %67, %63
br label %74
74: ; preds = %73
%75 = load i32, i32* %7
%76 = add i32 %75, 1
store i32 %76, i32* %7
br label %11
77: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [50 x i8] c"Block %u has a checksum error (should be 0x%02x)\0A\00"
define void @hexdumpedid(i32* nocapture %0, i8* %1, i32 %2) {
%4 = icmp ult i32 %2, 128
br i1 %4, label %110, label %5
5: ; preds = %3
%6 = lshr i32 %2, 7
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %107
%9 = phi i64 [ 0, %5 ], [ %108, %107 ]
%10 = shl i64 %9, 7
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = icmp eq i64 %9, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call i32 @fputc(i32 10, i32* %0)
br label %15
15: ; preds = %13, %8
br label %16
16: ; preds = %15, %16
%17 = phi i64 [ %98, %16 ], [ 0, %15 ]
%18 = getelementptr inbounds i8, i8* %11, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = or i64 %17, 1
%23 = getelementptr inbounds i8, i8* %11, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = or i64 %17, 2
%28 = getelementptr inbounds i8, i8* %11, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = or i64 %17, 3
%33 = getelementptr inbounds i8, i8* %11, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = or i64 %17, 4
%38 = getelementptr inbounds i8, i8* %11, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = or i64 %17, 5
%43 = getelementptr inbounds i8, i8* %11, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = or i64 %17, 6
%48 = getelementptr inbounds i8, i8* %11, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = or i64 %17, 7
%53 = getelementptr inbounds i8, i8* %11, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = or i64 %17, 8
%58 = getelementptr inbounds i8, i8* %11, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = or i64 %17, 9
%63 = getelementptr inbounds i8, i8* %11, i64 %62
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = or i64 %17, 10
%68 = getelementptr inbounds i8, i8* %11, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %70)
%72 = or i64 %17, 11
%73 = getelementptr inbounds i8, i8* %11, i64 %72
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = or i64 %17, 12
%78 = getelementptr inbounds i8, i8* %11, i64 %77
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %80)
%82 = or i64 %17, 13
%83 = getelementptr inbounds i8, i8* %11, i64 %82
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %85)
%87 = or i64 %17, 14
%88 = getelementptr inbounds i8, i8* %11, i64 %87
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = or i64 %17, 15
%93 = getelementptr inbounds i8, i8* %11, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %95)
%97 = tail call i32 @fputc(i32 10, i32* %0)
%98 = add nuw nsw i64 %17, 16
%99 = icmp ult i64 %17, 112
br i1 %99, label %16, label %100
100: ; preds = %16
%101 = tail call i32 @crc_ok(i8* %11)
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %100
%104 = tail call i32 @crc_calc(i8* %11)
%105 = trunc i64 %9 to i32
%106 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %105, i32 %104)
br label %107
107: ; preds = %103, %100
%108 = add nuw nsw i64 %9, 1
%109 = icmp eq i64 %108, %7
br i1 %109, label %110, label %8
110: ; preds = %107, %3
ret void
}