#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*/ inverseArray(unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int protoA_retFrameLen(unsigned char *, unsigned short);
unsigned char protoA_radioReadId(unsigned char *gatewayId, unsigned char idLen,
                                 unsigned char *buf, unsigned short bufSize) {
  if (protoA_retFrameLen(buf, bufSize) == 0x01)
    return 0x01;
  buf += (2 + 1 + 1);
  memcpy(gatewayId, buf, 6);
  inverseArray(gatewayId, 6);
  return 0x00;
}


x86 assembly (clang, -O0):
<protoA_radioReadId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cx,%ax
mov    %sil,%cl
mov    %rdi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ax,-0x22(%rbp)
mov    -0x20(%rbp),%rdi
movzwl -0x22(%rbp),%esi
call   1050 <protoA_retFrameLen@plt>
cmp    $0x1,%eax
jne    116c <protoA_radioReadId+0x3c>
movb   $0x1,-0x1(%rbp)
jmp    119c <protoA_radioReadId+0x6c>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1040 <inverseArray@plt>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<protoA_radioReadId>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rdx,%rdi
mov    %ecx,%esi
call   1050 <protoA_retFrameLen@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
je     1170 <protoA_radioReadId+0x40>
add    $0x4,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1040 <inverseArray@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i8 @protoA_radioReadId(i8* %0, i8 zeroext %1, i8* %2, i16 zeroext %3) {
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i16
store i8* %0, i8** %6
store i8 %1, i8* %7
store i8* %2, i8** %8
store i16 %3, i16* %9
%10 = load i8*, i8** %8
%11 = load i16, i16* %9
%12 = call i32 @protoA_retFrameLen(i8* %10, i16 zeroext %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %4
store i8 1, i8* %5
br label %23
15: ; preds = %4
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i64 4
store i8* %17, i8** %8
%18 = load i8*, i8** %6
%19 = load i8*, i8** %8
%20 = call i32 @memcpy(i8* %18, i8* %19, i32 6)
%21 = load i8*, i8** %6
%22 = call i32 @inverseArray(i8* %21, i32 6)
store i8 0, i8* %5
br label %23
23: ; preds = %15, %14
%24 = load i8, i8* %5
ret i8 %24
}

LLVM IR (-O2):
define zeroext i8 @protoA_radioReadId(i8* %0, i8 zeroext %1, i8* %2, i16 zeroext %3) {
%5 = tail call i32 @protoA_retFrameLen(i8* %2, i16 zeroext %3)
%6 = icmp eq i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %2, i64 4
%9 = tail call i32 @memcpy(i8* %0, i8* %8, i32 6)
%10 = tail call i32 @inverseArray(i8* %0, i32 6)
br label %11
11: ; preds = %4, %7
%12 = phi i8 [ 0, %7 ], [ 1, %4 ]
ret i8 %12
}