#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 */

/* Variables and functions */
int /*<<< orphan*/ E2PRegReadA(unsigned short, unsigned char *);
size_t abs(unsigned char);
void E2pRed(unsigned short UsAdr, unsigned char UcLen, unsigned char *UcPtr) {
  unsigned char UcCnt;
  for (UcCnt = 0; UcCnt < UcLen; UcCnt++) {
    E2PRegReadA(UsAdr + UcCnt,
                (unsigned char *)&UcPtr[abs((UcLen - 1) - UcCnt)]);
  }
}


x86 assembly (clang, -O0):
<E2pRed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rdx,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x3(%rbp),%ecx
cmp    %ecx,%eax
jge    119b <E2pRed+0x7b>
movzwl -0x2(%rbp),%eax
movzbl -0x11(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movzbl -0x3(%rbp),%eax
sub    $0x1,%eax
movzbl -0x11(%rbp),%ecx
sub    %ecx,%eax
movzbl %al,%edi
call   1030 <abs@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rcx
mov    -0x14(%rbp),%ax
add    %rcx,%rsi
movzwl %ax,%edi
call   1040 <E2PRegReadA@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    113d <E2pRed+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E2pRed>:
push   %rbp
push   %r14
push   %rbx
test   %esi,%esi
je     1161 <E2pRed+0x41>
mov    %rdx,%r14
mov    %edi,%ebp
movzbl %sil,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
movzbl %bl,%edi
call   1030 <abs@plt>
lea    (%rax,%r14,1),%rsi
movzwl %bp,%ebp
mov    %ebp,%edi
call   1040 <E2PRegReadA@plt>
add    $0x1,%ebp
test   %bx,%bx
jne    1140 <E2pRed+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @E2pRed(i16 zeroext %0, i8 zeroext %1, i8* %2) {
%4 = alloca i16
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8
store i16 %0, i16* %4
store i8 %1, i8* %5
store i8* %2, i8** %6
store i8 0, i8* %7
br label %8
8: ; preds = %32, %3
%9 = load i8, i8* %7
%10 = zext i8 %9 to i32
%11 = load i8, i8* %5
%12 = zext i8 %11 to i32
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %35
14: ; preds = %8
%15 = load i16, i16* %4
%16 = zext i16 %15 to i32
%17 = load i8, i8* %7
%18 = zext i8 %17 to i32
%19 = add nsw i32 %16, %18
%20 = trunc i32 %19 to i16
%21 = load i8*, i8** %6
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = sub nsw i32 %23, 1
%25 = load i8, i8* %7
%26 = zext i8 %25 to i32
%27 = sub nsw i32 %24, %26
%28 = trunc i32 %27 to i8
%29 = call i64 @abs(i8 zeroext %28)
%30 = getelementptr inbounds i8, i8* %21, i64 %29
%31 = call i32 @E2PRegReadA(i16 zeroext %20, i8* %30)
br label %32
32: ; preds = %14
%33 = load i8, i8* %7
%34 = add i8 %33, 1
store i8 %34, i8* %7
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @E2pRed(i16 zeroext %0, i8 zeroext %1, i8* %2) {
%4 = icmp eq i8 %1, 0
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = zext i8 %1 to i16
br label %7
7: ; preds = %5, %7
%8 = phi i16 [ 0, %5 ], [ %16, %7 ]
%9 = trunc i16 %8 to i8
%10 = add i16 %8, %0
%11 = xor i8 %9, -1
%12 = add i8 %11, %1
%13 = tail call i64 @abs(i8 zeroext %12)
%14 = getelementptr inbounds i8, i8* %2, i64 %13
%15 = tail call i32 @E2PRegReadA(i16 zeroext %10, i8* %14)
%16 = add nuw nsw i16 %8, 1
%17 = icmp eq i16 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %7, %3
ret void
}