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


x86 assembly (clang, -O0):
<std_short_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1181 <std_short_str+0x61>
mov    -0x8(%rbp),%rax
mov    (%rax),%ax
mov    %ax,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jge    1171 <std_short_str+0x51>
mov    -0x18(%rbp),%rsi
mov    $0x2d,%edi
call   1040 <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>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<std_short_str>:
test   %rdi,%rdi
je     1153 <std_short_str+0x33>
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
movzwl (%rdi),%ebp
test   %bp,%bp
jns    1142 <std_short_str+0x22>
mov    $0x2d,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
neg    %ebp
movswl %bp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <short_put@plt>
ret

LLVM IR (-O0):
define void @std_short_str(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 %11, label %29
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i16*
%14 = load i16, i16* %13
store i16 %14, i16* %7
%15 = load i16, i16* %7
%16 = sext i16 %15 to i32
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i32*, i32** %6
%20 = call i32 @fputc(i8 signext 45, i32* %19)
%21 = load i16, i16* %7
%22 = sext i16 %21 to i32
%23 = sub nsw i32 0, %22
%24 = trunc i32 %23 to i16
store i16 %24, i16* %7
br label %25
25: ; preds = %18, %11
%26 = load i16, i16* %7
%27 = load i32*, i32** %6
%28 = call i32 @short_put(i16 signext %26, i32* %27)
br label %29
29: ; preds = %25, %3
ret void
}

LLVM IR (-O2):
define void @std_short_str(i8* noalias %0, i8* noalias nocapture readnone %1, i32* noalias %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = bitcast i8* %0 to i16*
%7 = load i16, i16* %6
%8 = icmp slt i16 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i32 @fputc(i8 signext 45, i32* %2)
%11 = sub i16 0, %7
br label %12
12: ; preds = %9, %5
%13 = phi i16 [ %11, %9 ], [ %7, %5 ]
%14 = tail call i32 @short_put(i16 signext %13, i32* %2)
br label %15
15: ; preds = %12, %3
ret void
}