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

/* Variables and functions */
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(void *, unsigned short, int, int /*<<< orphan*/ *);
void scp2_put(FILE *fptr, unsigned short comspec, unsigned short pkt_len_s16,
              unsigned char priority, unsigned short comref, unsigned data_len,
              void *data) {
  fputc('$', fptr);
  fputc(1, fptr);
  fputc((pkt_len_s16 + 16) >> 8, fptr);
  fputc((pkt_len_s16 + 16), fptr);
  fputc(comspec >> 8, fptr);
  fputc(comspec, fptr);
  fputc((pkt_len_s16 + 16) >> 8, fptr);
  fputc((pkt_len_s16 + 16), fptr);
  fputc(priority, fptr);
  fputc(0, fptr);
  fputc(comref >> 8, fptr);
  fputc(comref, fptr);
  fputc(data_len >> 24, fptr);
  fputc(data_len >> 16, fptr);
  fputc(data_len >> 8, fptr);
  fputc(data_len, fptr);
  fputc(0, fptr);
  fputc(2, fptr);
  fputc(0, fptr);
  fputc(0, fptr);
  fwrite(data, pkt_len_s16, 1, fptr);
}


x86 assembly (clang, -O0):
<scp2_put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8w,%ax
mov    0x10(%rbp),%r8
mov    %rdi,-0x8(%rbp)
mov    %si,-0xa(%rbp)
mov    %dx,-0xc(%rbp)
mov    %cl,-0xd(%rbp)
mov    %ax,-0x10(%rbp)
mov    %r9d,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x24,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1030 <fputc@plt>
movzwl -0xc(%rbp),%edi
add    $0x10,%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0xc(%rbp),%edi
add    $0x10,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0xa(%rbp),%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0xa(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0xc(%rbp),%edi
add    $0x10,%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0xc(%rbp),%edi
add    $0x10,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzbl -0xd(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
movzwl -0x10(%rbp),%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
movzwl -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%edi
shr    $0x18,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%edi
shr    $0x10,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%edi
shr    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x2,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    0x10(%rbp),%rdi
mov    -0xc(%rbp),%ax
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
movzwl %ax,%esi
call   1040 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scp2_put>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r12d
mov    %r8d,0x4(%rsp)
mov    %ecx,(%rsp)
mov    %edx,%ebp
mov    %rbp,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x50(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    $0x24,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0x10(%rbp),%r13d
mov    %r13d,%r14d
shr    $0x8,%r14d
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r15d,%edi
shr    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
shr    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r12d,%edi
shr    $0x18,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r12d,%edi
shr    $0x10,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r12d,%edi
shr    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
define void @scp2_put(i32* %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3, i16 zeroext %4, i32 %5, i8* %6) {
%8 = alloca i32*
%9 = alloca i16
%10 = alloca i16
%11 = alloca i8
%12 = alloca i16
%13 = alloca i32
%14 = alloca i8*
store i32* %0, i32** %8
store i16 %1, i16* %9
store i16 %2, i16* %10
store i8 %3, i8* %11
store i16 %4, i16* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
%15 = load i32*, i32** %8
%16 = call i32 @fputc(i32 36, i32* %15)
%17 = load i32*, i32** %8
%18 = call i32 @fputc(i32 1, i32* %17)
%19 = load i16, i16* %10
%20 = zext i16 %19 to i32
%21 = add nsw i32 %20, 16
%22 = ashr i32 %21, 8
%23 = load i32*, i32** %8
%24 = call i32 @fputc(i32 %22, i32* %23)
%25 = load i16, i16* %10
%26 = zext i16 %25 to i32
%27 = add nsw i32 %26, 16
%28 = load i32*, i32** %8
%29 = call i32 @fputc(i32 %27, i32* %28)
%30 = load i16, i16* %9
%31 = zext i16 %30 to i32
%32 = ashr i32 %31, 8
%33 = load i32*, i32** %8
%34 = call i32 @fputc(i32 %32, i32* %33)
%35 = load i16, i16* %9
%36 = zext i16 %35 to i32
%37 = load i32*, i32** %8
%38 = call i32 @fputc(i32 %36, i32* %37)
%39 = load i16, i16* %10
%40 = zext i16 %39 to i32
%41 = add nsw i32 %40, 16
%42 = ashr i32 %41, 8
%43 = load i32*, i32** %8
%44 = call i32 @fputc(i32 %42, i32* %43)
%45 = load i16, i16* %10
%46 = zext i16 %45 to i32
%47 = add nsw i32 %46, 16
%48 = load i32*, i32** %8
%49 = call i32 @fputc(i32 %47, i32* %48)
%50 = load i8, i8* %11
%51 = zext i8 %50 to i32
%52 = load i32*, i32** %8
%53 = call i32 @fputc(i32 %51, i32* %52)
%54 = load i32*, i32** %8
%55 = call i32 @fputc(i32 0, i32* %54)
%56 = load i16, i16* %12
%57 = zext i16 %56 to i32
%58 = ashr i32 %57, 8
%59 = load i32*, i32** %8
%60 = call i32 @fputc(i32 %58, i32* %59)
%61 = load i16, i16* %12
%62 = zext i16 %61 to i32
%63 = load i32*, i32** %8
%64 = call i32 @fputc(i32 %62, i32* %63)
%65 = load i32, i32* %13
%66 = lshr i32 %65, 24
%67 = load i32*, i32** %8
%68 = call i32 @fputc(i32 %66, i32* %67)
%69 = load i32, i32* %13
%70 = lshr i32 %69, 16
%71 = load i32*, i32** %8
%72 = call i32 @fputc(i32 %70, i32* %71)
%73 = load i32, i32* %13
%74 = lshr i32 %73, 8
%75 = load i32*, i32** %8
%76 = call i32 @fputc(i32 %74, i32* %75)
%77 = load i32, i32* %13
%78 = load i32*, i32** %8
%79 = call i32 @fputc(i32 %77, i32* %78)
%80 = load i32*, i32** %8
%81 = call i32 @fputc(i32 0, i32* %80)
%82 = load i32*, i32** %8
%83 = call i32 @fputc(i32 2, i32* %82)
%84 = load i32*, i32** %8
%85 = call i32 @fputc(i32 0, i32* %84)
%86 = load i32*, i32** %8
%87 = call i32 @fputc(i32 0, i32* %86)
%88 = load i8*, i8** %14
%89 = load i16, i16* %10
%90 = load i32*, i32** %8
%91 = call i32 @fwrite(i8* %88, i16 zeroext %89, i32 1, i32* %90)
ret void
}

LLVM IR (-O2):
define void @scp2_put(i32* %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3, i16 zeroext %4, i32 %5, i8* nocapture %6) {
%8 = tail call i32 @fputc(i32 36, i32* %0)
%9 = tail call i32 @fputc(i32 1, i32* %0)
%10 = zext i16 %2 to i32
%11 = add nuw nsw i32 %10, 16
%12 = lshr i32 %11, 8
%13 = tail call i32 @fputc(i32 %12, i32* %0)
%14 = tail call i32 @fputc(i32 %11, i32* %0)
%15 = zext i16 %1 to i32
%16 = lshr i32 %15, 8
%17 = tail call i32 @fputc(i32 %16, i32* %0)
%18 = tail call i32 @fputc(i32 %15, i32* %0)
%19 = tail call i32 @fputc(i32 %12, i32* %0)
%20 = tail call i32 @fputc(i32 %11, i32* %0)
%21 = zext i8 %3 to i32
%22 = tail call i32 @fputc(i32 %21, i32* %0)
%23 = tail call i32 @fputc(i32 0, i32* %0)
%24 = zext i16 %4 to i32
%25 = lshr i32 %24, 8
%26 = tail call i32 @fputc(i32 %25, i32* %0)
%27 = tail call i32 @fputc(i32 %24, i32* %0)
%28 = lshr i32 %5, 24
%29 = tail call i32 @fputc(i32 %28, i32* %0)
%30 = lshr i32 %5, 16
%31 = tail call i32 @fputc(i32 %30, i32* %0)
%32 = lshr i32 %5, 8
%33 = tail call i32 @fputc(i32 %32, i32* %0)
%34 = tail call i32 @fputc(i32 %5, i32* %0)
%35 = tail call i32 @fputc(i32 0, i32* %0)
%36 = tail call i32 @fputc(i32 2, i32* %0)
%37 = tail call i32 @fputc(i32 0, i32* %0)
%38 = tail call i32 @fputc(i32 0, i32* %0)
%39 = tail call i32 @fwrite(i8* %6, i16 zeroext %2, i32 1, i32* %0)
ret void
}