unsigned long EEPROMBlockPasswordSet(unsigned long ulBlock,
                                     unsigned long *pulPassword,
                                     unsigned long ulCount) {
  unsigned long ulReg;
  ;
  ;
  ;
  (*((volatile unsigned long *)(0x400AF004))) = ulBlock;
  ulReg = 0x400AF034;
  while (ulCount) {
    (*((volatile unsigned long *)(ulReg))) = *pulPassword;
    pulPassword++;
    ulReg += 4;
    ulCount--;
    while ((*((volatile unsigned long *)(0x400AF018))) & 0x00000001) {
    }
  }
  return ((*((volatile unsigned long *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMBlockPasswordSet>:
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)
movq   $0x400af034,-0x20(%rbp)
40
cmpq   $0x0,-0x18(%rbp)
je     1181 <EEPROMBlockPasswordSet+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    $0x400af018,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     117c <EEPROMBlockPasswordSet+0x7c>
jmp    1161 <EEPROMBlockPasswordSet+0x61>
jmp    1124 <EEPROMBlockPasswordSet+0x24>
mov    $0x400af018,%eax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockPasswordSet>:
mov    %rdi,0x400af004
40
test   %rdx,%rdx
je     119c <EEPROMBlockPasswordSet+0x9c>
mov    $0x400af034,%eax
cmp    $0x1,%rdx
je     117a <EEPROMBlockPasswordSet+0x7a>
mov    %rdx,%r8
and    $0xfffffffffffffffe,%r8
mov    $0x400af034,%eax
xor    %edi,%edi
nopw   0x0(%rax,%rax,1)
mov    (%rsi),%rcx
mov    %rcx,(%rax)
cs nopw 0x0(%rax,%rax,1)
testq  $0x1,0x400af018
jne    1140 <EEPROMBlockPasswordSet+0x40>
mov    0x8(%rsi),%rcx
mov    %rcx,0x4(%rax)
add    $0x8,%rax
nopw   0x0(%rax,%rax,1)
mov    0x400af018,%rcx
40
test   $0x1,%cl
jne    1160 <EEPROMBlockPasswordSet+0x60>
add    $0x10,%rsi
add    $0x2,%rdi
cmp    %r8,%rdi
jne    1130 <EEPROMBlockPasswordSet+0x30>
test   $0x1,%dl
je     119c <EEPROMBlockPasswordSet+0x9c>
mov    (%rsi),%rcx
mov    %rcx,(%rax)
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x400af018,%rax
40
test   $0x1,%al
jne    1190 <EEPROMBlockPasswordSet+0x90>
mov    0x400af018,%rax
40
ret

LLVM IR (-O0):
define i64 @EEPROMBlockPasswordSet(i64 %0, i64* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64 %2, i64* %6
%8 = load i64, i64* %4
store volatile i64 %8, i64* inttoptr (i64 1074458628 to i64*)
store i64 1074458676, i64* %7
br label %9
9: ; preds = %28, %3
%10 = load i64, i64* %6
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i64*, i64** %5
%14 = load i64, i64* %13
%15 = load i64, i64* %7
%16 = inttoptr i64 %15 to i64*
store volatile i64 %14, i64* %16
%17 = load i64*, i64** %5
%18 = getelementptr inbounds i64, i64* %17, i32 1
store i64* %18, i64** %5
%19 = load i64, i64* %7
%20 = add i64 %19, 4
store i64 %20, i64* %7
%21 = load i64, i64* %6
%22 = add i64 %21, -1
store i64 %22, i64* %6
br label %23
23: ; preds = %27, %12
%24 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
%25 = and i64 %24, 1
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
br label %23
28: ; preds = %23
br label %9
29: ; preds = %9
%30 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
ret i64 %30
}

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