#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(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ short_put(short, int /*<<< orphan*/ *);
void std_short_put(const void *restrict self, const char *restrict format,
                   FILE *restrict stream) {
  (void)format;
  signed short number;
  if (!self)
    fputs("<"
          "signed short"
          " "
          "(NULL)"
          ">",
          stream);
  else {
    fputs("<"
          "signed short"
          " ",
          stream);
    number = *(const signed short *)self;
    if (number < 0) {
      fputc('-', stream);
      number = (signed short)-number;
    }
    short_put(number, stream);
    fputc('>', stream);
  }
}


x86 assembly (clang, -O0):
<std_short_put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1164 <std_short_put+0x34>
mov    -0x18(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <fputs@plt>
jmp    11c4 <std_short_put+0x94>
mov    -0x18(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ax
mov    %ax,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jge    11a6 <std_short_put+0x76>
mov    -0x18(%rbp),%rsi
mov    $0x2d,%edi
call   1050 <fputc@plt>
movswl -0x1a(%rbp),%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %ax,-0x1a(%rbp)
mov    -0x1a(%rbp),%ax
mov    -0x18(%rbp),%rsi
movswl %ax,%edi
call   1030 <short_put@plt>
mov    -0x18(%rbp),%rsi
mov    $0x3e,%edi
call   1050 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<std_short_put>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
test   %rdi,%rdi
je     118e <std_short_put+0x5e>
mov    %rdi,%rbx
lea    0xed0(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
movzwl (%rbx),%ebx
test   %bx,%bx
jns    116f <std_short_put+0x3f>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
neg    %ebx
movswl %bx,%edi
mov    %r14,%rsi
call   1030 <short_put@plt>
mov    $0x3e,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fputc@plt>
lea    0xe6b(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"<signed short (NULL)>\00"
@.str.1 = [15 x i8] c"<signed short \00"
define void @std_short_put(i8* noalias %0, i8* noalias %1, i32* noalias %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i16
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %5
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i32*, i32** %6
%13 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %36
14: ; preds = %3
%15 = load i32*, i32** %6
%16 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = load i8*, i8** %4
%18 = bitcast i8* %17 to i16*
%19 = load i16, i16* %18
store i16 %19, i16* %7
%20 = load i16, i16* %7
%21 = sext i16 %20 to i32
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %14
%24 = load i32*, i32** %6
%25 = call i32 @fputc(i8 signext 45, i32* %24)
%26 = load i16, i16* %7
%27 = sext i16 %26 to i32
%28 = sub nsw i32 0, %27
%29 = trunc i32 %28 to i16
store i16 %29, i16* %7
br label %30
30: ; preds = %23, %14
%31 = load i16, i16* %7
%32 = load i32*, i32** %6
%33 = call i32 @short_put(i16 signext %31, i32* %32)
%34 = load i32*, i32** %6
%35 = call i32 @fputc(i8 signext 62, i32* %34)
br label %36
36: ; preds = %30, %11
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"<signed short (NULL)>\00"
@.str.1 = [15 x i8] c"<signed short \00"
define void @std_short_put(i8* noalias %0, i8* noalias nocapture readnone %1, i32* noalias %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 21, i64 1, i32* %2)
br label %19
7: ; preds = %3
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14, i64 1, i32* %2)
%9 = bitcast i8* %0 to i16*
%10 = load i16, i16* %9
%11 = icmp slt i16 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @fputc(i8 signext 45, i32* %2)
%14 = sub i16 0, %10
br label %15
15: ; preds = %12, %7
%16 = phi i16 [ %14, %12 ], [ %10, %7 ]
%17 = tail call i32 @short_put(i16 signext %16, i32* %2)
%18 = tail call i32 @fputc(i8 signext 62, i32* %2)
br label %19
19: ; preds = %15, %5
ret void
}