#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 /*<<< orphan*/ template;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int write(int, char *, int);
int send_rfxsensor_ident(unsigned short sensor, unsigned char *serial) {
  extern int sptty;
  int ignoret;
  static unsigned char template[14] = {0xff, 0xff, 0xff, 10, 0x7b, 30, 0,
                                       0,    0,    0,    0,  0,    0,  0};
  template[6] = (sensor >> 8) & 0xffu;
  template[7] = sensor & 0xffu;
  memcpy(template + 8, serial, 6);
  ignoret = write(sptty, (char *)template, sizeof(template));
  return 0;
}


x86 assembly (clang, -O0):
<send_rfxsensor_ident>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,0x2ef1(%rip)
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
mov    %al,0x2ee3(%rip)
mov    -0x10(%rbp),%rsi
lea    0x2ed9(%rip),%rdi
mov    $0x6,%edx
call   1040 <memcpy@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0x2eb7(%rip),%rsi
mov    $0xe,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_rfxsensor_ident>:
push   %rbx
lea    0x2f08(%rip),%rbx
rol    $0x8,%di
mov    %di,0x2f03(%rip)
lea    0x2efe(%rip),%rdi
mov    $0x6,%edx
call   1040 <memcpy@plt>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    $0xe,%edx
call   1030 <write@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@send_rfxsensor_ident.template = internal global <{ i8, i8, i8, i8, i8, i8, [8 x i8] }> <{ i8 -1, i8 -1, i8 -1, i8 10, i8 123, i8 30, [8 x i8] zeroinitializer }>
@sptty = external global i32
define i32 @send_rfxsensor_ident(i16 zeroext %0, i8* %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i32
store i16 %0, i16* %3
store i8* %1, i8** %4
%6 = load i16, i16* %3
%7 = zext i16 %6 to i32
%8 = ashr i32 %7, 8
%9 = and i32 %8, 255
%10 = trunc i32 %9 to i8
store i8 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* bitcast (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template to [14 x i8]*), i64 0, i64 6)
%11 = load i16, i16* %3
%12 = zext i16 %11 to i32
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
store i8 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* bitcast (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template to [14 x i8]*), i64 0, i64 7)
%15 = load i8*, i8** %4
%16 = call i32 @memcpy(i8* getelementptr inbounds ([14 x i8], [14 x i8]* bitcast (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template to [14 x i8]*), i64 0, i64 8), i8* %15, i32 6)
%17 = load i32, i32* @sptty
%18 = call i32 @write(i32 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* bitcast (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template to [14 x i8]*), i64 0, i64 0), i32 14)
store i32 %18, i32* %5
ret i32 0
}

LLVM IR (-O2):
@send_rfxsensor_ident.template = internal global <{ i8, i8, i8, i8, i8, i8, [8 x i8] }> <{ i8 -1, i8 -1, i8 -1, i8 10, i8 123, i8 30, [8 x i8] zeroinitializer }>
@sptty = external global i32
define i32 @send_rfxsensor_ident(i16 zeroext %0, i8* %1) {
%3 = lshr i16 %0, 8
%4 = trunc i16 %3 to i8
store i8 %4, i8* getelementptr inbounds (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>, <{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template, i64 0, i32 6, i64 0)
%5 = trunc i16 %0 to i8
store i8 %5, i8* getelementptr inbounds (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>, <{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template, i64 0, i32 6, i64 1)
%6 = tail call i32 @memcpy(i8* getelementptr inbounds (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>, <{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template, i64 0, i32 6, i64 2), i8* %1, i32 6)
%7 = load i32, i32* @sptty
%8 = tail call i32 @write(i32 %7, i8* getelementptr inbounds (<{ i8, i8, i8, i8, i8, i8, [8 x i8] }>, <{ i8, i8, i8, i8, i8, i8, [8 x i8] }>* @send_rfxsensor_ident.template, i64 0, i32 0), i32 14)
ret i32 0
}