#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 EEPROMBlockUnlock(uint32_t ui32Block, uint32_t *pui32Password,
                           uint32_t ui32Count) {
  ;
  ;
  ;
  (*((volatile uint32_t *)(0x400AF004))) = ui32Block;
  (*((volatile uint32_t *)(0x400AF020))) = 0xFFFFFFFF;
  pui32Password += (ui32Count - 1);
  while (ui32Count) {
    (*((volatile uint32_t *)(0x400AF020))) = *pui32Password--;
    ui32Count--;
  }
  return ((*((volatile uint32_t *)(0x400AF020))));
}


x86 assembly (clang, -O0):
<EEPROMBlockUnlock>:
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)
mov    $0x400af020,%eax
movl   $0xffffffff,(%rax)
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116b <EEPROMBlockUnlock+0x6b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    $0x400af020,%eax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <EEPROMBlockUnlock+0x3b>
mov    $0x400af020,%eax
mov    (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockUnlock>:
mov    %edi,0x400af004
movl   $0xffffffff,0x400af020
ff ff ff ff
test   %edx,%edx
je     11af <EEPROMBlockUnlock+0xaf>
lea    -0x1(%rdx),%r8d
movslq %r8d,%rax
lea    (%rsi,%rax,4),%rax
mov    %edx,%esi
and    $0x7,%esi
je     1146 <EEPROMBlockUnlock+0x46>
xor    %edi,%edi
xchg   %ax,%ax
mov    (%rax),%ecx
add    $0xfffffffffffffffc,%rax
mov    %ecx,0x400af020
add    $0x1,%edi
cmp    %edi,%esi
jne    1130 <EEPROMBlockUnlock+0x30>
sub    %edi,%edx
cmp    $0x7,%r8d
jb     11af <EEPROMBlockUnlock+0xaf>
neg    %edx
xor    %ecx,%ecx
mov    (%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x4(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x8(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0xc(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x10(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x14(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x18(%rax,%rcx,4),%esi
mov    %esi,0x400af020
mov    -0x1c(%rax,%rcx,4),%esi
mov    %esi,0x400af020
add    $0xfffffffffffffff8,%rcx
cmp    %ecx,%edx
jne    1150 <EEPROMBlockUnlock+0x50>
mov    0x400af020,%eax
ret

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

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