void ltoe(lp, y) long *lp;
unsigned short *y;
{
  unsigned short yi[(6 + 3)];
  unsigned long ll;
  int k;
  ecleaz(yi);
  if (*lp < 0) {
    ll = (unsigned long)(-(*lp));
    yi[0] = 0xffff;
  } else {
    ll = (unsigned long)(*lp);
  }
  if (sizeof(long) == 8) {
    yi[2] = (unsigned short)(ll >> ((8 * sizeof(long)) - 16));
    yi[2 + 1] = (unsigned short)(ll >> ((8 * sizeof(long)) - 32));
    yi[2 + 2] = (unsigned short)(ll >> 16);
    yi[2 + 3] = (unsigned short)ll;
    yi[1] = (0x3fff) + 47;
  } else {
    yi[2] = (unsigned short)(ll >> 16);
    yi[2 + 1] = (unsigned short)ll;
    yi[1] = (0x3fff) + 15;
  }
  if ((k = enormlz(yi)) > (((6 + 3) - 4) * 16))
    ecleaz(yi);
  else
    yi[1] -= (unsigned short)k;
  emovo(yi, y);
}


x86 assembly (clang, -O0):
<ltoe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1050 <ecleaz@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jge    1171 <ltoe+0x41>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
sub    (%rcx),%rax
mov    %rax,-0x38(%rbp)
movw   $0xffff,-0x30(%rbp)
jmp    117c <ltoe+0x4c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x30,%rax
mov    %ax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x20,%rax
mov    %ax,-0x2a(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x10,%rax
mov    %ax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    %ax,-0x26(%rbp)
movw   $0x402e,-0x2e(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1040 <enormlz@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x50,%eax
jle    11d5 <ltoe+0xa5>
lea    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1050 <ecleaz@plt>
jmp    11e5 <ltoe+0xb5>
mov    -0x3c(%rbp),%eax
movzwl %ax,%ecx
movzwl -0x2e(%rbp),%eax
sub    %ecx,%eax
mov    %ax,-0x2e(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <emovo@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltoe>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <ecleaz@plt>
mov    (%rbx),%rax
test   %rax,%rax
jns    1158 <ltoe+0x28>
neg    %rax
movw   $0xffff,(%rsp)
mov    %rax,%rcx
shr    $0x30,%rcx
mov    %cx,0x4(%rsp)
mov    %rax,%rcx
shr    $0x20,%rcx
mov    %cx,0x6(%rsp)
mov    %rax,%rcx
shr    $0x10,%rcx
mov    %cx,0x8(%rsp)
mov    %ax,0xa(%rsp)
movw   $0x402e,0x2(%rsp)
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <enormlz@plt>
cmp    $0x51,%eax
jl     11a3 <ltoe+0x73>
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <ecleaz@plt>
jmp    11a8 <ltoe+0x78>
sub    %ax,0x2(%rsp)
mov    %rsp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <emovo@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ltoe(i64* %0, i16* %1) {
%3 = alloca i64*
%4 = alloca i16*
%5 = alloca [9 x i16]
%6 = alloca i64
%7 = alloca i32
store i64* %0, i64** %3
store i16* %1, i16** %4
%8 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 0
%9 = call i32 (i16*, ...) bitcast (i32 (...)* @ecleaz to i32 (i16*, ...)*)(i16* %8)
%10 = load i64*, i64** %3
%11 = load i64, i64* %10
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i64*, i64** %3
%15 = load i64, i64* %14
%16 = sub nsw i64 0, %15
store i64 %16, i64* %6
%17 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 0
store i16 -1, i16* %17
br label %21
18: ; preds = %2
%19 = load i64*, i64** %3
%20 = load i64, i64* %19
store i64 %20, i64* %6
br label %21
21: ; preds = %18, %13
%22 = load i64, i64* %6
%23 = lshr i64 %22, 48
%24 = trunc i64 %23 to i16
%25 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 2
store i16 %24, i16* %25
%26 = load i64, i64* %6
%27 = lshr i64 %26, 32
%28 = trunc i64 %27 to i16
%29 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 3
store i16 %28, i16* %29
%30 = load i64, i64* %6
%31 = lshr i64 %30, 16
%32 = trunc i64 %31 to i16
%33 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 4
store i16 %32, i16* %33
%34 = load i64, i64* %6
%35 = trunc i64 %34 to i16
%36 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 5
store i16 %35, i16* %36
%37 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 1
store i16 16430, i16* %37
%38 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 0
%39 = call i32 (i16*, ...) bitcast (i32 (...)* @enormlz to i32 (i16*, ...)*)(i16* %38)
store i32 %39, i32* %7
%40 = icmp sgt i32 %39, 80
br i1 %40, label %41, label %44
41: ; preds = %21
%42 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 0
%43 = call i32 (i16*, ...) bitcast (i32 (...)* @ecleaz to i32 (i16*, ...)*)(i16* %42)
br label %53
44: ; preds = %21
%45 = load i32, i32* %7
%46 = trunc i32 %45 to i16
%47 = zext i16 %46 to i32
%48 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 1
%49 = load i16, i16* %48
%50 = zext i16 %49 to i32
%51 = sub nsw i32 %50, %47
%52 = trunc i32 %51 to i16
store i16 %52, i16* %48
br label %53
53: ; preds = %44, %41
%54 = getelementptr inbounds [9 x i16], [9 x i16]* %5, i64 0, i64 0
%55 = load i16*, i16** %4
%56 = call i32 (i16*, i16*, ...) bitcast (i32 (...)* @emovo to i32 (i16*, i16*, ...)*)(i16* %54, i16* %55)
ret void
}

LLVM IR (-O2):
define void @ltoe(i64* nocapture %0, i16* %1) {
%3 = alloca [9 x i16]
%4 = bitcast [9 x i16]* %3 to i8*
%5 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 0
%6 = call i32 (i16*, ...) bitcast (i32 (...)* @ecleaz to i32 (i16*, ...)*)(i16* %5)
%7 = load i64, i64* %0
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = sub nsw i64 0, %7
store i16 -1, i16* %5
br label %11
11: ; preds = %2, %9
%12 = phi i64 [ %10, %9 ], [ %7, %2 ]
%13 = lshr i64 %12, 48
%14 = trunc i64 %13 to i16
%15 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 2
store i16 %14, i16* %15
%16 = lshr i64 %12, 32
%17 = trunc i64 %16 to i16
%18 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 3
store i16 %17, i16* %18
%19 = lshr i64 %12, 16
%20 = trunc i64 %19 to i16
%21 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 4
store i16 %20, i16* %21
%22 = trunc i64 %12 to i16
%23 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 5
store i16 %22, i16* %23
%24 = getelementptr inbounds [9 x i16], [9 x i16]* %3, i64 0, i64 1
store i16 16430, i16* %24
%25 = call i32 (i16*, ...) bitcast (i32 (...)* @enormlz to i32 (i16*, ...)*)(i16* %5)
%26 = icmp sgt i32 %25, 80
br i1 %26, label %27, label %29
27: ; preds = %11
%28 = call i32 (i16*, ...) bitcast (i32 (...)* @ecleaz to i32 (i16*, ...)*)(i16* %5)
br label %33
29: ; preds = %11
%30 = load i16, i16* %24
%31 = trunc i32 %25 to i16
%32 = sub i16 %30, %31
store i16 %32, i16* %24
br label %33
33: ; preds = %29, %27
%34 = call i32 (i16*, i16*, ...) bitcast (i32 (...)* @emovo to i32 (i16*, i16*, ...)*)(i16* %5, i16* %1)
ret void
}