#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 uint32_t;

/* Variables and functions */
uint32_t EEPROMBlockPasswordSet(uint32_t ui32Block, uint32_t *pui32Password,
                                uint32_t ui32Count) {
  uint32_t ui32Reg;
  ;
  ;
  ;
  (*((volatile unsigned long *)(0x400AF004))) = ui32Block;
  ui32Reg = 0x400AF034;
  while (ui32Count) {
    (*((volatile unsigned long *)(ui32Reg))) = *pui32Password;
    pui32Password++;
    ui32Reg += 4;
    ui32Count--;
    while ((*((volatile unsigned long *)(0x400AF018))) & 0x00000001) {
    }
  }
  return ((*((volatile unsigned long *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMBlockPasswordSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x4(%rbp),%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
movl   $0x400af034,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1177 <EEPROMBlockPasswordSet+0x77>
mov    -0x10(%rbp),%rax
movslq (%rax),%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    $0x400af018,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1172 <EEPROMBlockPasswordSet+0x72>
jmp    1157 <EEPROMBlockPasswordSet+0x57>
jmp    1121 <EEPROMBlockPasswordSet+0x21>
mov    $0x400af018,%eax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockPasswordSet>:
movslq %edi,%rax
mov    %rax,0x400af004
40
test   %edx,%edx
je     119c <EEPROMBlockPasswordSet+0x9c>
mov    $0x400af034,%eax
cmp    $0x1,%edx
je     1179 <EEPROMBlockPasswordSet+0x79>
mov    %edx,%r8d
and    $0xfffffffe,%r8d
xor    %edi,%edi
mov    $0x400af034,%eax
nopl   0x0(%rax,%rax,1)
movslq (%rsi),%rcx
mov    %rcx,(%rax)
cs nopw 0x0(%rax,%rax,1)
testq  $0x1,0x400af018
jne    1140 <EEPROMBlockPasswordSet+0x40>
movslq 0x4(%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    $0x8,%rsi
add    $0x2,%edi
cmp    %r8d,%edi
jne    1130 <EEPROMBlockPasswordSet+0x30>
test   $0x1,%dl
je     119c <EEPROMBlockPasswordSet+0x9c>
movslq (%rsi),%rcx
mov    %rcx,(%rax)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x400af018,%rax
40
test   $0x1,%al
jne    1190 <EEPROMBlockPasswordSet+0x90>
mov    0x400af018,%rax
40
ret

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

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