#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 */

/* Variables and functions */
int /*<<< orphan*/ ecc_computeblock(unsigned char *, int, int, int, int,
                                    unsigned char *);
void ecc_generate(unsigned char *sector, int zeroaddress) {
  unsigned char address[4], i;
  if (zeroaddress)
    for (i = 0; i < 4; i++) {
      address[i] = sector[12 + i];
      sector[12 + i] = 0;
    }
  ecc_computeblock(sector + 0xC, 86, 24, 2, 86, sector + 0x81C);
  ecc_computeblock(sector + 0xC, 52, 43, 86, 88, sector + 0x8C8);
  if (zeroaddress)
    for (i = 0; i < 4; i++)
      sector[12 + i] = address[i];
}


x86 assembly (clang, -O0):
<ecc_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1177 <ecc_generate+0x67>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x4,%eax
jge    1172 <ecc_generate+0x62>
mov    -0x8(%rbp),%rax
movzbl -0x11(%rbp),%ecx
add    $0xc,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movzbl -0x11(%rbp),%eax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
movzbl -0x11(%rbp),%ecx
add    $0xc,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    112d <ecc_generate+0x1d>
jmp    1177 <ecc_generate+0x67>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
mov    -0x8(%rbp),%r9
add    $0x81c,%r9
mov    $0x56,%r8d
mov    $0x18,%edx
mov    $0x2,%ecx
mov    %r8d,%esi
call   1030 <ecc_computeblock@plt>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
mov    -0x8(%rbp),%r9
add    $0x8c8,%r9
mov    $0x34,%esi
mov    $0x2b,%edx
mov    $0x56,%ecx
mov    $0x58,%r8d
call   1030 <ecc_computeblock@plt>
cmpl   $0x0,-0xc(%rbp)
je     1215 <ecc_generate+0x105>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x4,%eax
jge    1210 <ecc_generate+0x100>
movzbl -0x11(%rbp),%eax
mov    -0x10(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movzbl -0x11(%rbp),%ecx
add    $0xc,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11dd <ecc_generate+0xcd>
jmp    1215 <ecc_generate+0x105>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecc_generate>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xc(%rdi),%r14
test   %esi,%esi
je     1179 <ecc_generate+0x69>
mov    0xc(%rbx),%ebp
movl   $0x0,0xc(%rbx)
lea    0x81c(%rbx),%r9
mov    %r14,%rdi
mov    $0x56,%esi
mov    $0x18,%edx
mov    $0x2,%ecx
mov    $0x56,%r8d
call   1030 <ecc_computeblock@plt>
lea    0x8c8(%rbx),%r9
mov    %r14,%rdi
mov    $0x34,%esi
mov    $0x2b,%edx
mov    $0x56,%ecx
mov    $0x58,%r8d
call   1030 <ecc_computeblock@plt>
mov    %ebp,0xc(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0x81c(%rbx),%r9
mov    %r14,%rdi
mov    $0x56,%esi
mov    $0x18,%edx
mov    $0x2,%ecx
mov    $0x56,%r8d
call   1030 <ecc_computeblock@plt>
add    $0x8c8,%rbx
mov    %r14,%rdi
mov    $0x34,%esi
mov    $0x2b,%edx
mov    $0x56,%ecx
mov    $0x58,%r8d
mov    %rbx,%r9
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ecc_computeblock@plt>

LLVM IR (-O0):
define void @ecc_generate(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [4 x i8]
%6 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %2
store i8 0, i8* %6
br label %10
10: ; preds = %31, %9
%11 = load i8, i8* %6
%12 = zext i8 %11 to i32
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = add nsw i32 12, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %15, i64 %19
%21 = load i8, i8* %20
%22 = load i8, i8* %6
%23 = zext i8 %22 to i64
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %23
store i8 %21, i8* %24
%25 = load i8*, i8** %3
%26 = load i8, i8* %6
%27 = zext i8 %26 to i32
%28 = add nsw i32 12, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %14
%32 = load i8, i8* %6
%33 = add i8 %32, 1
store i8 %33, i8* %6
br label %10
34: ; preds = %10
br label %35
35: ; preds = %34, %2
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 12
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 2076
%40 = call i32 @ecc_computeblock(i8* %37, i32 86, i32 24, i32 2, i32 86, i8* %39)
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 12
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i64 2248
%45 = call i32 @ecc_computeblock(i8* %42, i32 52, i32 43, i32 86, i32 88, i8* %44)
%46 = load i32, i32* %4
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %68
48: ; preds = %35
store i8 0, i8* %6
br label %49
49: ; preds = %64, %48
%50 = load i8, i8* %6
%51 = zext i8 %50 to i32
%52 = icmp slt i32 %51, 4
br i1 %52, label %53, label %67
53: ; preds = %49
%54 = load i8, i8* %6
%55 = zext i8 %54 to i64
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = load i8*, i8** %3
%59 = load i8, i8* %6
%60 = zext i8 %59 to i32
%61 = add nsw i32 12, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %58, i64 %62
store i8 %57, i8* %63
br label %64
64: ; preds = %53
%65 = load i8, i8* %6
%66 = add i8 %65, 1
store i8 %66, i8* %6
br label %49
67: ; preds = %49
br label %68
68: ; preds = %67, %35
ret void
}

LLVM IR (-O2):
define void @ecc_generate(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = getelementptr inbounds i8, i8* %0, i64 12
br i1 %3, label %17, label %5
5: ; preds = %2
%6 = load i8, i8* %4
store i8 0, i8* %4
%7 = getelementptr inbounds i8, i8* %0, i64 13
%8 = load i8, i8* %7
store i8 0, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 14
%10 = load i8, i8* %9
store i8 0, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 15
%12 = load i8, i8* %11
store i8 0, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 2076
%14 = tail call i32 @ecc_computeblock(i8* %4, i32 86, i32 24, i32 2, i32 86, i8* %13)
%15 = getelementptr inbounds i8, i8* %0, i64 2248
%16 = tail call i32 @ecc_computeblock(i8* %4, i32 52, i32 43, i32 86, i32 88, i8* %15)
store i8 %6, i8* %4
store i8 %8, i8* %7
store i8 %10, i8* %9
store i8 %12, i8* %11
br label %22
17: ; preds = %2
%18 = getelementptr inbounds i8, i8* %0, i64 2076
%19 = tail call i32 @ecc_computeblock(i8* %4, i32 86, i32 24, i32 2, i32 86, i8* %18)
%20 = getelementptr inbounds i8, i8* %0, i64 2248
%21 = tail call i32 @ecc_computeblock(i8* %4, i32 52, i32 43, i32 86, i32 88, i8* %20)
br label %22
22: ; preds = %5, %17
ret void
}