#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ __aosc_split_triple_sub_16(int, int *, int *, int *);
char *__aosc_encode_fixed_size_16(char *dst, uint16_t base, uint16_t val) {
  uint16_t word1, word2, word3;
  __aosc_split_triple_sub_16(base - val, &word1, &word2, &word3);
  dst[0] = 0x66;
  dst[1] = 0x2d;
  do {
    (&dst[2])[1] = (word1) >> 8;
    (&dst[2])[0] = (word1);
  } while (0);
  dst[4] = 0x66;
  dst[5] = 0x2d;
  do {
    (&dst[6])[1] = (word2) >> 8;
    (&dst[6])[0] = (word2);
  } while (0);
  dst[8] = 0x66;
  dst[9] = 0x2d;
  do {
    (&dst[10])[1] = (word3) >> 8;
    (&dst[10])[0] = (word3);
  } while (0);
  dst[12] = 0x66;
  dst[13] = 0x50;
  dst[14] = 0;
  return dst;
}


x86 assembly (clang, -O0):
<__aosc_encode_fixed_size_16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x10(%rbp),%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <__aosc_split_triple_sub_16@plt>
mov    -0x8(%rbp),%rax
movb   $0x66,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2d,0x1(%rax)
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x66,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2d,0x5(%rax)
mov    -0x18(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x18(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x8(%rbp),%rax
movb   $0x66,0x8(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2d,0x9(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xb(%rax)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xa(%rax)
mov    -0x8(%rbp),%rax
movb   $0x66,0xc(%rax)
mov    -0x8(%rbp),%rax
movb   $0x50,0xd(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0xe(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__aosc_encode_fixed_size_16>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%eax
mov    %rdi,%rbx
sub    %edx,%eax
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %eax,%edi
call   1030 <__aosc_split_triple_sub_16@plt>
movw   $0x2d66,(%rbx)
mov    0xc(%rsp),%eax
mov    %ah,0x3(%rbx)
mov    %al,0x2(%rbx)
movw   $0x2d66,0x4(%rbx)
mov    0x8(%rsp),%eax
mov    %ah,0x7(%rbx)
mov    %al,0x6(%rbx)
movw   $0x2d66,0x8(%rbx)
mov    0x4(%rsp),%eax
mov    %ah,0xb(%rbx)
mov    %al,0xa(%rbx)
movw   $0x5066,0xc(%rbx)
movb   $0x0,0xe(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i8* @__aosc_encode_fixed_size_16(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = sub nsw i32 %10, %11
%13 = call i32 @__aosc_split_triple_sub_16(i32 %12, i32* %7, i32* %8, i32* %9)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 102, i8* %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 45, i8* %17
br label %18
18: ; preds = %3
%19 = load i32, i32* %7
%20 = ashr i32 %19, 8
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 %21, i8* %24
%25 = load i32, i32* %7
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 %26, i8* %29
br label %30
30: ; preds = %18
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 4
store i8 102, i8* %32
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 5
store i8 45, i8* %34
br label %35
35: ; preds = %30
%36 = load i32, i32* %8
%37 = ashr i32 %36, 8
%38 = trunc i32 %37 to i8
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 6
%41 = getelementptr inbounds i8, i8* %40, i64 1
store i8 %38, i8* %41
%42 = load i32, i32* %8
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 6
%46 = getelementptr inbounds i8, i8* %45, i64 0
store i8 %43, i8* %46
br label %47
47: ; preds = %35
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 8
store i8 102, i8* %49
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 9
store i8 45, i8* %51
br label %52
52: ; preds = %47
%53 = load i32, i32* %9
%54 = ashr i32 %53, 8
%55 = trunc i32 %54 to i8
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 10
%58 = getelementptr inbounds i8, i8* %57, i64 1
store i8 %55, i8* %58
%59 = load i32, i32* %9
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 10
%63 = getelementptr inbounds i8, i8* %62, i64 0
store i8 %60, i8* %63
br label %64
64: ; preds = %52
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i64 12
store i8 102, i8* %66
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 13
store i8 80, i8* %68
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i64 14
store i8 0, i8* %70
%71 = load i8*, i8** %4
ret i8* %71
}

LLVM IR (-O2):
define i8* @__aosc_encode_fixed_size_16(i8* returned writeonly %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = sub nsw i32 %1, %2
%11 = call i32 @__aosc_split_triple_sub_16(i32 %10, i32* %4, i32* %5, i32* %6)
store i8 102, i8* %0
%12 = getelementptr inbounds i8, i8* %0, i64 1
store i8 45, i8* %12
%13 = load i32, i32* %4
%14 = lshr i32 %13, 8
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %15, i8* %17
%18 = trunc i32 %13 to i8
store i8 %18, i8* %16
%19 = getelementptr inbounds i8, i8* %0, i64 4
store i8 102, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 5
store i8 45, i8* %20
%21 = load i32, i32* %5
%22 = lshr i32 %21, 8
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %0, i64 6
%25 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %23, i8* %25
%26 = trunc i32 %21 to i8
store i8 %26, i8* %24
%27 = getelementptr inbounds i8, i8* %0, i64 8
store i8 102, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 9
store i8 45, i8* %28
%29 = load i32, i32* %6
%30 = lshr i32 %29, 8
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %0, i64 10
%33 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %31, i8* %33
%34 = trunc i32 %29 to i8
store i8 %34, i8* %32
%35 = getelementptr inbounds i8, i8* %0, i64 12
store i8 102, i8* %35
%36 = getelementptr inbounds i8, i8* %0, i64 13
store i8 80, i8* %36
%37 = getelementptr inbounds i8, i8* %0, i64 14
store i8 0, i8* %37
ret i8* %0
}