#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 */
struct sCC1101PhyInfo {
  int dummy;
};

/* Variables and functions */
unsigned char CC1101GetRegister(struct sCC1101PhyInfo *, unsigned char);
int /*<<< orphan*/ CC1101Read(struct sCC1101PhyInfo *, unsigned char,
                              unsigned char *, unsigned char);
void CC1101ReadRegisters(struct sCC1101PhyInfo *phyInfo, unsigned char address,
                         unsigned char *buffer, unsigned char count) {
  if (count == 1) {
    *buffer = CC1101GetRegister(phyInfo, address);
  } else if (count > 1) {
    CC1101Read(phyInfo, address, buffer, count);
  }
}


x86 assembly (clang, -O0):
<CC1101ReadRegisters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x1,%eax
jne    1162 <CC1101ReadRegisters+0x42>
mov    -0x8(%rbp),%rdi
movzbl -0x9(%rbp),%esi
call   1040 <CC1101GetRegister@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    118b <CC1101ReadRegisters+0x6b>
movzbl -0x19(%rbp),%eax
cmp    $0x1,%eax
jle    1186 <CC1101ReadRegisters+0x66>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rdx
movzbl %al,%esi
movzbl -0x19(%rbp),%ecx
call   1030 <CC1101Read@plt>
jmp    118b <CC1101ReadRegisters+0x6b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CC1101ReadRegisters>:
push   %rbx
test   %ecx,%ecx
je     1138 <CC1101ReadRegisters+0x18>
mov    %rdx,%rbx
movzbl %sil,%esi
cmp    $0x1,%cl
jne    113a <CC1101ReadRegisters+0x1a>
call   1040 <CC1101GetRegister@plt>
mov    %al,(%rbx)
pop    %rbx
ret
movzbl %cl,%ecx
mov    %rbx,%rdx
pop    %rbx
jmp    1030 <CC1101Read@plt>

LLVM IR (-O0):
%struct.sCC1101PhyInfo = type { i32 }
define void @CC1101ReadRegisters(%struct.sCC1101PhyInfo* %0, i8 zeroext %1, i8* %2, i8 zeroext %3) {
%5 = alloca %struct.sCC1101PhyInfo*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8
store %struct.sCC1101PhyInfo* %0, %struct.sCC1101PhyInfo** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i8 %3, i8* %8
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load %struct.sCC1101PhyInfo*, %struct.sCC1101PhyInfo** %5
%14 = load i8, i8* %6
%15 = call zeroext i8 @CC1101GetRegister(%struct.sCC1101PhyInfo* %13, i8 zeroext %14)
%16 = load i8*, i8** %7
store i8 %15, i8* %16
br label %28
17: ; preds = %4
%18 = load i8, i8* %8
%19 = zext i8 %18 to i32
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load %struct.sCC1101PhyInfo*, %struct.sCC1101PhyInfo** %5
%23 = load i8, i8* %6
%24 = load i8*, i8** %7
%25 = load i8, i8* %8
%26 = call i32 @CC1101Read(%struct.sCC1101PhyInfo* %22, i8 zeroext %23, i8* %24, i8 zeroext %25)
br label %27
27: ; preds = %21, %17
br label %28
28: ; preds = %27, %12
ret void
}

LLVM IR (-O2):
%struct.sCC1101PhyInfo = type { i32 }
define void @CC1101ReadRegisters(%struct.sCC1101PhyInfo* %0, i8 zeroext %1, i8* %2, i8 zeroext %3) {
switch i8 %3, label %7 [
i8 1, label %5
i8 0, label %9
]
5: ; preds = %4
%6 = tail call zeroext i8 @CC1101GetRegister(%struct.sCC1101PhyInfo* %0, i8 zeroext %1)
store i8 %6, i8* %2
br label %9
7: ; preds = %4
%8 = tail call i32 @CC1101Read(%struct.sCC1101PhyInfo* %0, i8 zeroext %1, i8* %2, i8 zeroext %3)
br label %9
9: ; preds = %4, %7, %5
ret void
}