#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*/ gds_swap2bytes(unsigned char *);
int /*<<< orphan*/ write(int, unsigned short *, int);
void gds_write_strans(int fd, int reflect, int abs_angle, int abs_mag) {
  static unsigned short int count, token, strans;
  strans = 32768 * reflect + 2 * abs_mag + abs_angle;
  count = 6;
  gds_swap2bytes((unsigned char *)&count);
  write(fd, &count, 2);
  token = 0x1A01;
  gds_swap2bytes((unsigned char *)&token);
  write(fd, &token, 2);
  gds_swap2bytes((unsigned char *)&strans);
  write(fd, &strans, 2);
}


x86 assembly (clang, -O0):
<gds_write_strans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0xf,%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %ax,0x2eea(%rip)
movw   $0x6,0x2edd(%rip)
lea    0x2ed6(%rip),%rdi
call   1040 <gds_swap2bytes@plt>
mov    -0x4(%rbp),%edi
lea    0x2ec7(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movw   $0x1a01,0x2eb6(%rip)
01 1a
lea    0x2eaf(%rip),%rdi
call   1040 <gds_swap2bytes@plt>
mov    -0x4(%rbp),%edi
lea    0x2ea0(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0x2e91(%rip),%rdi
call   1040 <gds_swap2bytes@plt>
mov    -0x4(%rbp),%edi
lea    0x2e82(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gds_write_strans>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
shl    $0xf,%esi
add    %edx,%esi
lea    (%rsi,%rcx,2),%eax
mov    %ax,0x2f00(%rip)
lea    0x2ef9(%rip),%r14
movw   $0x6,0x2eec(%rip)
lea    0x2ee5(%rip),%r15
mov    %r15,%rdi
call   1040 <gds_swap2bytes@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movw   $0x1a01,0x2ec7(%rip)
01 1a
lea    0x2ec0(%rip),%r15
mov    %r15,%rdi
call   1040 <gds_swap2bytes@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %r14,%rdi
call   1040 <gds_swap2bytes@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x2,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <write@plt>

LLVM IR (-O0):
@gds_write_strans.count = internal global i16 0
@gds_write_strans.token = internal global i16 0
@gds_write_strans.strans = internal global i16 0
define void @gds_write_strans(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %6
%10 = mul nsw i32 32768, %9
%11 = load i32, i32* %8
%12 = mul nsw i32 2, %11
%13 = add nsw i32 %10, %12
%14 = load i32, i32* %7
%15 = add nsw i32 %13, %14
%16 = trunc i32 %15 to i16
store i16 %16, i16* @gds_write_strans.strans
store i16 6, i16* @gds_write_strans.count
%17 = call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.count to i8*))
%18 = load i32, i32* %5
%19 = call i32 @write(i32 %18, i16* @gds_write_strans.count, i32 2)
store i16 6657, i16* @gds_write_strans.token
%20 = call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.token to i8*))
%21 = load i32, i32* %5
%22 = call i32 @write(i32 %21, i16* @gds_write_strans.token, i32 2)
%23 = call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.strans to i8*))
%24 = load i32, i32* %5
%25 = call i32 @write(i32 %24, i16* @gds_write_strans.strans, i32 2)
ret void
}

LLVM IR (-O2):
@gds_write_strans.count = internal global i16 0
@gds_write_strans.token = internal global i16 0
@gds_write_strans.strans = internal global i16 0
define void @gds_write_strans(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl nsw i32 %1, 15
%6 = shl nsw i32 %3, 1
%7 = add i32 %5, %2
%8 = add i32 %7, %6
%9 = trunc i32 %8 to i16
store i16 %9, i16* @gds_write_strans.strans
store i16 6, i16* @gds_write_strans.count
%10 = tail call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.count to i8*))
%11 = tail call i32 @write(i32 %0, i16* @gds_write_strans.count, i32 2)
store i16 6657, i16* @gds_write_strans.token
%12 = tail call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.token to i8*))
%13 = tail call i32 @write(i32 %0, i16* @gds_write_strans.token, i32 2)
%14 = tail call i32 @gds_swap2bytes(i8* bitcast (i16* @gds_write_strans.strans to i8*))
%15 = tail call i32 @write(i32 %0, i16* @gds_write_strans.strans, i32 2)
ret void
}