#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 uint32_t *)(0x400AF004))) = ui32Block;
  ui32Reg = 0x400AF034;
  while (ui32Count) {
    (*((volatile uint32_t *)(ui32Reg))) = *pui32Password;
    pui32Password++;
    ui32Reg += 4;
    ui32Count--;
    while ((*((volatile uint32_t *)(0x400AF018))) & 0x00000001) {
    }
  }
  return ((*((volatile uint32_t *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMBlockPasswordSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
movl   $0x400af034,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1170 <EEPROMBlockPasswordSet+0x70>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
movslq -0x18(%rbp),%rax
mov    %ecx,(%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),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116b <EEPROMBlockPasswordSet+0x6b>
jmp    1153 <EEPROMBlockPasswordSet+0x53>
jmp    111f <EEPROMBlockPasswordSet+0x1f>
mov    $0x400af018,%eax
mov    (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockPasswordSet>:
mov    %edi,0x400af004
test   %edx,%edx
je     119b <EEPROMBlockPasswordSet+0x9b>
mov    $0x400af034,%eax
cmp    $0x1,%edx
je     1178 <EEPROMBlockPasswordSet+0x78>
mov    %edx,%r8d
and    $0xfffffffe,%r8d
xor    %edi,%edi
mov    $0x400af034,%eax
nopw   0x0(%rax,%rax,1)
mov    (%rsi),%ecx
mov    %ecx,(%rax)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
testl  $0x1,0x400af018
jne    1140 <EEPROMBlockPasswordSet+0x40>
mov    0x4(%rsi),%ecx
mov    %ecx,0x4(%rax)
add    $0x8,%rax
nopw   0x0(%rax,%rax,1)
mov    0x400af018,%ecx
test   $0x1,%cl
jne    1160 <EEPROMBlockPasswordSet+0x60>
add    $0x8,%rsi
add    $0x2,%edi
cmp    %r8d,%edi
jne    1130 <EEPROMBlockPasswordSet+0x30>
test   $0x1,%dl
je     119b <EEPROMBlockPasswordSet+0x9b>
mov    (%rsi),%ecx
mov    %ecx,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x400af018,%eax
test   $0x1,%al
jne    1190 <EEPROMBlockPasswordSet+0x90>
mov    0x400af018,%eax
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
store volatile i32 %8, i32* inttoptr (i64 1074458628 to i32*)
store i32 1074458676, i32* %7
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store volatile i32 %14, i32* %17
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %5
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 4
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = add nsw i32 %22, -1
store i32 %23, i32* %6
br label %24
24: ; preds = %28, %12
%25 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
%26 = and i32 %25, 1
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
br label %24
29: ; preds = %24
br label %9
30: ; preds = %9
%31 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
ret i32 %31
}

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