#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 *, int, int, int /*<<< orphan*/ *);
void scp_put(FILE *fptr, int comspec, int comref, int priority, int length,
             void *data) {
  fputc('$', fptr);
  fputc(1, fptr);
  fputc((length + 8) >> 8, fptr);
  fputc((length + 8) & 0xFF, fptr);
  fputc(comspec >> 8, fptr);
  fputc(comspec & 0xFF, fptr);
  fputc(comref >> 8, fptr);
  fputc(comref & 0xFF, fptr);
  fputc(priority, fptr);
  fputc(0, fptr);
  fputc(length >> 8, fptr);
  fputc(length & 0xFF, fptr);
  fwrite(data, length, 1, fptr);
}


x86 assembly (clang, -O0):
<scp_put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x24,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%edi
add    $0x8,%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%edi
add    $0x8,%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%edi
and    $0xff,%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    -0x18(%rbp),%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scp_put>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x24,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0x8(%r15),%r14d
mov    %r14d,%edi
sar    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movzbl %r14b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%edi
sar    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movzbl %bpl,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r13d,%edi
sar    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movzbl %r13b,%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    %r15d,%edi
sar    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movzbl %r15b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
define void @scp_put(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%13 = load i32*, i32** %7
%14 = call i32 @fputc(i32 36, i32* %13)
%15 = load i32*, i32** %7
%16 = call i32 @fputc(i32 1, i32* %15)
%17 = load i32, i32* %11
%18 = add nsw i32 %17, 8
%19 = ashr i32 %18, 8
%20 = load i32*, i32** %7
%21 = call i32 @fputc(i32 %19, i32* %20)
%22 = load i32, i32* %11
%23 = add nsw i32 %22, 8
%24 = and i32 %23, 255
%25 = load i32*, i32** %7
%26 = call i32 @fputc(i32 %24, i32* %25)
%27 = load i32, i32* %8
%28 = ashr i32 %27, 8
%29 = load i32*, i32** %7
%30 = call i32 @fputc(i32 %28, i32* %29)
%31 = load i32, i32* %8
%32 = and i32 %31, 255
%33 = load i32*, i32** %7
%34 = call i32 @fputc(i32 %32, i32* %33)
%35 = load i32, i32* %9
%36 = ashr i32 %35, 8
%37 = load i32*, i32** %7
%38 = call i32 @fputc(i32 %36, i32* %37)
%39 = load i32, i32* %9
%40 = and i32 %39, 255
%41 = load i32*, i32** %7
%42 = call i32 @fputc(i32 %40, i32* %41)
%43 = load i32, i32* %10
%44 = load i32*, i32** %7
%45 = call i32 @fputc(i32 %43, i32* %44)
%46 = load i32*, i32** %7
%47 = call i32 @fputc(i32 0, i32* %46)
%48 = load i32, i32* %11
%49 = ashr i32 %48, 8
%50 = load i32*, i32** %7
%51 = call i32 @fputc(i32 %49, i32* %50)
%52 = load i32, i32* %11
%53 = and i32 %52, 255
%54 = load i32*, i32** %7
%55 = call i32 @fputc(i32 %53, i32* %54)
%56 = load i8*, i8** %12
%57 = load i32, i32* %11
%58 = load i32*, i32** %7
%59 = call i32 @fwrite(i8* %56, i32 %57, i32 1, i32* %58)
ret void
}

LLVM IR (-O2):
define void @scp_put(i32* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* nocapture %5) {
%7 = tail call i32 @fputc(i32 36, i32* %0)
%8 = tail call i32 @fputc(i32 1, i32* %0)
%9 = add nsw i32 %4, 8
%10 = ashr i32 %9, 8
%11 = tail call i32 @fputc(i32 %10, i32* %0)
%12 = and i32 %9, 255
%13 = tail call i32 @fputc(i32 %12, i32* %0)
%14 = ashr i32 %1, 8
%15 = tail call i32 @fputc(i32 %14, i32* %0)
%16 = and i32 %1, 255
%17 = tail call i32 @fputc(i32 %16, i32* %0)
%18 = ashr i32 %2, 8
%19 = tail call i32 @fputc(i32 %18, i32* %0)
%20 = and i32 %2, 255
%21 = tail call i32 @fputc(i32 %20, i32* %0)
%22 = tail call i32 @fputc(i32 %3, i32* %0)
%23 = tail call i32 @fputc(i32 0, i32* %0)
%24 = ashr i32 %4, 8
%25 = tail call i32 @fputc(i32 %24, i32* %0)
%26 = and i32 %4, 255
%27 = tail call i32 @fputc(i32 %26, i32* %0)
%28 = tail call i32 @fwrite(i8* %5, i32 %4, i32 1, i32* %0)
ret void
}