#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_long_flag_update(unsigned char bank, unsigned long flagmap,
                          unsigned char mode) {
  extern int sptty;
  int ignoret;
  static unsigned char template[12] = {0xff, 0xff, 0xff, 8, 0x7b, 40,
                                       0,    0,    0,    0, 0,    0};
  template[6] = mode;
  template[7] = bank;
  template[8] = (flagmap & 0xff000000) >> 24;
  template[9] = (flagmap & 0x00ff0000) >> 16;
  template[10] = (flagmap & 0x0000ff00) >> 8;
  template[11] = flagmap & 0x000000ff;
  ignoret = write(sptty, template, sizeof(template));
  return 0;
}


x86 assembly (clang, -O0):
<send_long_flag_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    %al,0x2efe(%rip)
mov    -0x1(%rbp),%al
mov    %al,0x2ef6(%rip)
movabs $0xff000000,%rax
and    -0x10(%rbp),%rax
shr    $0x18,%rax
mov    %al,0x2edf(%rip)
mov    -0x10(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %al,0x2ecc(%rip)
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %al,0x2eb9(%rip)
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %al,0x2eaa(%rip)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0x2e8f(%rip),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_long_flag_update>:
push   %rax
mov    %rsi,%rax
mov    %dl,0x2f14(%rip)
lea    0x2f07(%rip),%rsi
mov    %dil,0x2f07(%rip)
mov    %rax,%rcx
shr    $0x18,%rcx
mov    %cl,0x2efb(%rip)
mov    %rax,%rcx
shr    $0x10,%rcx
mov    %cl,0x2eef(%rip)
mov    %ah,0x2eea(%rip)
mov    %al,0x2ee5(%rip)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    $0xc,%edx
call   1030 <write@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@send_long_flag_update.template = internal global [12 x i8] c"\FF\FF\FF\08{(\00\00\00\00\00\00"
@sptty = external global i32
define i32 @send_long_flag_update(i8 zeroext %0, i64 %1, i8 zeroext %2) {
%4 = alloca i8
%5 = alloca i64
%6 = alloca i8
%7 = alloca i32
store i8 %0, i8* %4
store i64 %1, i64* %5
store i8 %2, i8* %6
%8 = load i8, i8* %6
store i8 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 6)
%9 = load i8, i8* %4
store i8 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 7)
%10 = load i64, i64* %5
%11 = and i64 %10, 4278190080
%12 = lshr i64 %11, 24
%13 = trunc i64 %12 to i8
store i8 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 8)
%14 = load i64, i64* %5
%15 = and i64 %14, 16711680
%16 = lshr i64 %15, 16
%17 = trunc i64 %16 to i8
store i8 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 9)
%18 = load i64, i64* %5
%19 = and i64 %18, 65280
%20 = lshr i64 %19, 8
%21 = trunc i64 %20 to i8
store i8 %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 10)
%22 = load i64, i64* %5
%23 = and i64 %22, 255
%24 = trunc i64 %23 to i8
store i8 %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 11)
%25 = load i32, i32* @sptty
%26 = call i32 @write(i32 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @send_long_flag_update.template, i64 0, i64 0), i32 12)
store i32 %26, i32* %7
ret i32 0
}

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