#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 carraydumpedid(FILE *f, const unsigned char *edid, unsigned size) {
  unsigned b, i, j;
  fprintf(f, "unsigned char edid[] = {\n");
  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 += 8) {
      fprintf(f, "\t0x%02x,", buf[i]);
      for (j = 1; j < 8; j++) {
        fprintf(f, " 0x%02x,", buf[i + j]);
      }
      fprintf(f, "\n");
    }
    if (!crc_ok(buf))
      fprintf(f, "\t/* Block %u has a checksum error (should be 0x%02x) */\n",
              b, crc_calc(buf));
  }
  fprintf(f, "};\n");
}


x86 assembly (clang, -O0):
<carraydumpedid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    $0x7,%ecx
cmp    %ecx,%eax
jae    1281 <carraydumpedid+0x151>
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     119c <carraydumpedid+0x6c>
mov    -0x8(%rbp),%rdi
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x80,-0x1c(%rbp)
jae    122e <carraydumpedid+0xfe>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jae    120e <carraydumpedid+0xde>
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    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d4 <carraydumpedid+0xa4>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <carraydumpedid+0x73>
mov    -0x28(%rbp),%rdi
call   1030 <crc_ok@plt>
cmp    $0x0,%eax
jne    126e <carraydumpedid+0x13e>
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    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1273 <carraydumpedid+0x143>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <carraydumpedid+0x2c>
mov    -0x8(%rbp),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carraydumpedid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
lea    0xe91(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbp,(%rsp)
cmp    $0x80,%ebp
jae    11b4 <carraydumpedid+0x64>
lea    0xed1(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fwrite@plt>
mov    (%rsp),%rax
shr    $0x7,%eax
mov    %rax,(%rsp)
mov    0x8(%rsp),%rax
lea    0x7(%rax),%r14
lea    0xe4b(%rip),%r12
lea    0xe4d(%rip),%r13
xor    %ebp,%ebp
jmp    11ee <carraydumpedid+0x9e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
sub    $0xffffffffffffff80,%r14
cmp    (%rsp),%rbp
je     118d <carraydumpedid+0x3d>
mov    %rbp,%r15
shl    $0x7,%r15
mov    %rbp,0x10(%rsp)
test   %rbp,%rbp
je     120c <carraydumpedid+0xbc>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    0x8(%rsp),%r15
mov    %r15,%rbp
mov    $0xfffffffffffffff8,%r15
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x2(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x3(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x4(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x5(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x6(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x7(%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl 0x8(%r14,%r15,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    $0x8,%r15
cmp    $0x78,%r15
jb     1220 <carraydumpedid+0xd0>
mov    %rbp,%r15
mov    %rbp,%rdi
call   1040 <crc_ok@plt>
test   %eax,%eax
mov    0x10(%rsp),%rbp
jne    11e0 <carraydumpedid+0x90>
mov    %r15,%rdi
call   1060 <crc_calc@plt>
mov    %rbx,%rdi
lea    0xd2f(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11e0 <carraydumpedid+0x90>

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

LLVM IR (-O2):
@.str = [26 x i8] c"unsigned char edid[] = {\0A\00"
@.str.2 = [9 x i8] c"\090x%02x,\00"
@.str.3 = [9 x i8] c" 0x%02x,\00"
@.str.4 = [57 x i8] c"\09/* Block %u has a checksum error (should be 0x%02x) */\0A\00"
@.str.5 = [4 x i8] c"};\0A\00"
define void @carraydumpedid(i32* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 25, i64 1, i32* %0)
%5 = icmp ult i32 %2, 128
br i1 %5, label %71, label %6
6: ; preds = %3
%7 = lshr i32 %2, 7
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %68
%10 = phi i64 [ 0, %6 ], [ %69, %68 ]
%11 = shl i64 %10, 7
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = icmp eq i64 %10, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = tail call i32 @fputc(i32 10, i32* %0)
br label %16
16: ; preds = %14, %9
br label %17
17: ; preds = %16, %17
%18 = phi i64 [ %59, %17 ], [ 0, %16 ]
%19 = getelementptr inbounds i8, i8* %12, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = or i64 %18, 1
%24 = getelementptr inbounds i8, i8* %12, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = or i64 %18, 2
%29 = getelementptr inbounds i8, i8* %12, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = or i64 %18, 3
%34 = getelementptr inbounds i8, i8* %12, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = or i64 %18, 4
%39 = getelementptr inbounds i8, i8* %12, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = or i64 %18, 5
%44 = getelementptr inbounds i8, i8* %12, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = or i64 %18, 6
%49 = getelementptr inbounds i8, i8* %12, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = or i64 %18, 7
%54 = getelementptr inbounds i8, i8* %12, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = tail call i32 @fputc(i32 10, i32* %0)
%59 = add nuw nsw i64 %18, 8
%60 = icmp ult i64 %18, 120
br i1 %60, label %17, label %61
61: ; preds = %17
%62 = tail call i32 @crc_ok(i8* %12)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = tail call i32 @crc_calc(i8* %12)
%66 = trunc i64 %10 to i32
%67 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %66, i32 %65)
br label %68
68: ; preds = %64, %61
%69 = add nuw nsw i64 %10, 1
%70 = icmp eq i64 %69, %8
br i1 %70, label %71, label %9
71: ; preds = %68, %3
%72 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %0)
ret void
}