#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 write(int, unsigned char *, int);
int send_flag_update(unsigned int flagmap, unsigned char mode) {
  extern int sptty;
  int ignoret;
  static unsigned char template[9] = {0xff, 0xff, 0xff, 5, 0x7b, 15, 0, 0, 0};
  template[6] = mode;
  template[7] = (flagmap & 0xff00) >> 8;
  template[8] = flagmap & 0xff;
  ignoret = write(sptty, template, sizeof(template));
  return 0;
}


x86 assembly (clang, -O0):
<send_flag_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
mov    %al,0x2f04(%rip)
mov    -0x4(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,0x2ef4(%rip)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,0x2ee7(%rip)
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0x2ecf(%rip),%rsi
mov    $0x9,%edx
call   1030 <write@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_flag_update>:
push   %rax
mov    %edi,%eax
mov    %sil,0x2f14(%rip)
lea    0x2f07(%rip),%rsi
mov    %ah,0x2f08(%rip)
mov    %al,0x2f03(%rip)
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    $0x9,%edx
call   1030 <write@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@send_flag_update.template = internal global [9 x i8] c"\FF\FF\FF\05{\0F\00\00\00"
@sptty = external global i32
define i32 @send_flag_update(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%6 = load i8, i8* %4
store i8 %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 6)
%7 = load i32, i32* %3
%8 = and i32 %7, 65280
%9 = lshr i32 %8, 8
%10 = trunc i32 %9 to i8
store i8 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 7)
%11 = load i32, i32* %3
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
store i8 %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 8)
%14 = load i32, i32* @sptty
%15 = call i32 @write(i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 0), i32 9)
store i32 %15, i32* %5
ret i32 0
}

LLVM IR (-O2):
@send_flag_update.template = internal global [9 x i8] c"\FF\FF\FF\05{\0F\00\00\00"
@sptty = external global i32
define i32 @send_flag_update(i32 %0, i8 zeroext %1) {
store i8 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 6)
%3 = lshr i32 %0, 8
%4 = trunc i32 %3 to i8
store i8 %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 7)
%5 = trunc i32 %0 to i8
store i8 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 8)
%6 = load i32, i32* @sptty
%7 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @send_flag_update.template, i64 0, i64 0), i32 9)
ret i32 0
}