unsigned long EEPROMBlockUnlock(unsigned long ulBlock,
                                unsigned long *pulPassword,
                                unsigned long ulCount) {
  ;
  ;
  ;
  (*((volatile unsigned long *)(0x400AF004))) = ulBlock;
  (*((volatile unsigned long *)(0x400AF020))) = 0xFFFFFFFF;
  pulPassword += (ulCount - 1);
  while (ulCount) {
    (*((volatile unsigned long *)(0x400AF020))) = *pulPassword--;
    ulCount--;
  }
  return ((*((volatile unsigned long *)(0x400AF020))));
}


x86 assembly (clang, -O0):
<EEPROMBlockUnlock>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
mov    $0x400af020,%eax
mov    $0xffffffff,%ecx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1173 <EEPROMBlockUnlock+0x73>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rcx
mov    $0x400af020,%eax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    113d <EEPROMBlockUnlock+0x3d>
mov    $0x400af020,%eax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockUnlock>:
mov    %rdi,0x400af004
40
mov    $0xffffffff,%eax
mov    %rax,0x400af020
40
test   %rdx,%rdx
je     11e0 <EEPROMBlockUnlock+0xe0>
lea    -0x1(%rdx),%r8
lea    (%rsi,%rdx,8),%rax
add    $0xfffffffffffffff8,%rax
mov    %rdx,%rsi
and    $0x7,%rsi
je     115b <EEPROMBlockUnlock+0x5b>
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rax),%rcx
add    $0xfffffffffffffff8,%rax
mov    %rcx,0x400af020
40
add    $0x1,%rdi
cmp    %rdi,%rsi
jne    1140 <EEPROMBlockUnlock+0x40>
sub    %rdi,%rdx
cmp    $0x7,%r8
jb     11e0 <EEPROMBlockUnlock+0xe0>
neg    %rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    (%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x8(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x10(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x18(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x20(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x28(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x30(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
mov    -0x38(%rax,%rcx,8),%rsi
mov    %rsi,0x400af020
40
add    $0xfffffffffffffff8,%rcx
cmp    %rcx,%rdx
jne    1170 <EEPROMBlockUnlock+0x70>
mov    0x400af020,%rax
40
ret

LLVM IR (-O0):
define i64 @EEPROMBlockUnlock(i64 %0, i64* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64 %2, i64* %6
%7 = load i64, i64* %4
store volatile i64 %7, i64* inttoptr (i64 1074458628 to i64*)
store volatile i64 4294967295, i64* inttoptr (i64 1074458656 to i64*)
%8 = load i64, i64* %6
%9 = sub i64 %8, 1
%10 = load i64*, i64** %5
%11 = getelementptr inbounds i64, i64* %10, i64 %9
store i64* %11, i64** %5
br label %12
12: ; preds = %15, %3
%13 = load i64, i64* %6
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64*, i64** %5
%17 = getelementptr inbounds i64, i64* %16, i32 -1
store i64* %17, i64** %5
%18 = load i64, i64* %16
store volatile i64 %18, i64* inttoptr (i64 1074458656 to i64*)
%19 = load i64, i64* %6
%20 = add i64 %19, -1
store i64 %20, i64* %6
br label %12
21: ; preds = %12
%22 = load volatile i64, i64* inttoptr (i64 1074458656 to i64*)
ret i64 %22
}

LLVM IR (-O2):
define i64 @EEPROMBlockUnlock(i64 %0, i64* nocapture %1, i64 %2) {
store volatile i64 %0, i64* inttoptr (i64 1074458628 to i64*)
store volatile i64 4294967295, i64* inttoptr (i64 1074458656 to i64*)
%4 = icmp eq i64 %2, 0
br i1 %4, label %44, label %5
5: ; preds = %3
%6 = add i64 %2, -1
%7 = getelementptr inbounds i64, i64* %1, i64 %6
%8 = and i64 %2, 7
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %5, %10
%11 = phi i64 [ %16, %10 ], [ %2, %5 ]
%12 = phi i64* [ %14, %10 ], [ %7, %5 ]
%13 = phi i64 [ %17, %10 ], [ 0, %5 ]
%14 = getelementptr inbounds i64, i64* %12, i64 -1
%15 = load i64, i64* %12
store volatile i64 %15, i64* inttoptr (i64 1074458656 to i64*)
%16 = add i64 %11, -1
%17 = add i64 %13, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %10
19: ; preds = %10, %5
%20 = phi i64 [ %2, %5 ], [ %16, %10 ]
%21 = phi i64* [ %7, %5 ], [ %14, %10 ]
%22 = icmp ult i64 %6, 7
br i1 %22, label %44, label %23
23: ; preds = %19, %23
%24 = phi i64 [ %42, %23 ], [ %20, %19 ]
%25 = phi i64* [ %40, %23 ], [ %21, %19 ]
%26 = getelementptr inbounds i64, i64* %25, i64 -1
%27 = load i64, i64* %25
store volatile i64 %27, i64* inttoptr (i64 1074458656 to i64*)
%28 = getelementptr inbounds i64, i64* %25, i64 -2
%29 = load i64, i64* %26
store volatile i64 %29, i64* inttoptr (i64 1074458656 to i64*)
%30 = getelementptr inbounds i64, i64* %25, i64 -3
%31 = load i64, i64* %28
store volatile i64 %31, i64* inttoptr (i64 1074458656 to i64*)
%32 = getelementptr inbounds i64, i64* %25, i64 -4
%33 = load i64, i64* %30
store volatile i64 %33, i64* inttoptr (i64 1074458656 to i64*)
%34 = getelementptr inbounds i64, i64* %25, i64 -5
%35 = load i64, i64* %32
store volatile i64 %35, i64* inttoptr (i64 1074458656 to i64*)
%36 = getelementptr inbounds i64, i64* %25, i64 -6
%37 = load i64, i64* %34
store volatile i64 %37, i64* inttoptr (i64 1074458656 to i64*)
%38 = getelementptr inbounds i64, i64* %25, i64 -7
%39 = load i64, i64* %36
store volatile i64 %39, i64* inttoptr (i64 1074458656 to i64*)
%40 = getelementptr inbounds i64, i64* %25, i64 -8
%41 = load i64, i64* %38
store volatile i64 %41, i64* inttoptr (i64 1074458656 to i64*)
%42 = add i64 %24, -8
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %23
44: ; preds = %19, %23, %3
%45 = load volatile i64, i64* inttoptr (i64 1074458656 to i64*)
ret i64 %45
}