#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*/ memcpy(unsigned char *, unsigned char *, int);
unsigned char proto_assembleFrame(unsigned char *, unsigned short *,
                                  unsigned char *, int, int, unsigned short,
                                  unsigned char *);
unsigned char protoW_modifyGatewayId(unsigned char *buf,
                                     unsigned short *bufSize,
                                     unsigned char *lu8originalId,
                                     unsigned char *lu8targetId) {
  unsigned char bodyBuf[6 + 6] = {0};
  unsigned short bodyLen = 6 + 6;
  bodyBuf[0] = 0x01;
  bodyBuf[1] = 0x00;
  bodyBuf[2] = 0x00;
  bodyBuf[3] = 0x00;
  bodyBuf[4] = 0x00;
  bodyBuf[5] = 0x00;
  memcpy(bodyBuf + 6, lu8targetId, 6);
  return proto_assembleFrame(buf, bufSize, lu8originalId, 0x00, 0x98, bodyLen,
                             bodyBuf);
}


x86 assembly (clang, -O0):
<protoW_modifyGatewayId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movw   $0xc,-0x2e(%rbp)
movb   $0x1,-0x2c(%rbp)
movb   $0x0,-0x2b(%rbp)
movb   $0x0,-0x2a(%rbp)
movb   $0x0,-0x29(%rbp)
movb   $0x0,-0x28(%rbp)
movb   $0x0,-0x27(%rbp)
lea    -0x2c(%rbp),%rdi
add    $0x6,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x2e(%rbp),%r9w
lea    -0x2c(%rbp),%rax
xor    %ecx,%ecx
mov    $0x98,%r8d
movzwl %r9w,%r9d
mov    %rax,(%rsp)
call   1030 <proto_assembleFrame@plt>
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<protoW_modifyGatewayId>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x1a(%rsp),%rdi
movw   $0x0,0x1e(%rsp)
movl   $0x0,0x1a(%rsp)
movb   $0x1,0x14(%rsp)
movl   $0x0,0x15(%rsp)
movb   $0x0,0x19(%rsp)
mov    %rcx,%rsi
mov    $0x6,%edx
call   1040 <memcpy@plt>
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    $0x98,%r8d
mov    $0xc,%r9d
call   1030 <proto_assembleFrame@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define zeroext i8 @protoW_modifyGatewayId(i8* %0, i16* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i16*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [12 x i8]
%10 = alloca i16
store i8* %0, i8** %5
store i16* %1, i16** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = bitcast [12 x i8]* %9 to i8*
store i16 12, i16* %10
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
store i8 1, i8* %12
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 1
store i8 0, i8* %13
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 2
store i8 0, i8* %14
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 3
store i8 0, i8* %15
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 4
store i8 0, i8* %16
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 5
store i8 0, i8* %17
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 6
%20 = load i8*, i8** %8
%21 = call i32 @memcpy(i8* %19, i8* %20, i32 6)
%22 = load i8*, i8** %5
%23 = load i16*, i16** %6
%24 = load i8*, i8** %7
%25 = load i16, i16* %10
%26 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%27 = call zeroext i8 @proto_assembleFrame(i8* %22, i16* %23, i8* %24, i32 0, i32 152, i16 zeroext %25, i8* %26)
ret i8 %27
}

LLVM IR (-O2):
define zeroext i8 @protoW_modifyGatewayId(i8* %0, i16* %1, i8* %2, i8* %3) {
%5 = alloca [12 x i8]
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 6
store i8 1, i8* %6
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 1
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 6
%10 = call i32 @memcpy(i8* %9, i8* %3, i32 6)
%11 = call zeroext i8 @proto_assembleFrame(i8* %0, i16* %1, i8* %2, i32 0, i32 152, i16 zeroext 12, i8* %6)
ret i8 %11
}