#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 scalar_t__ ptrdiff_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ ptrdiff_put(scalar_t__, int /*<<< orphan*/ *);
void std_ptrdiff_str(const void *restrict self, const char *restrict format,
                     FILE *restrict stream) {
  (void)format;
  ptrdiff_t number;
  if (self) {
    number = *(const ptrdiff_t *)self;
    if (number < 0) {
      fputc('-', stream);
      number = (ptrdiff_t)-number;
    }
    ptrdiff_put(number, stream);
  }
}


x86 assembly (clang, -O0):
<std_ptrdiff_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     117a <std_ptrdiff_str+0x5a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    116d <std_ptrdiff_str+0x4d>
mov    -0x18(%rbp),%rsi
mov    $0x2d,%edi
call   1040 <fputc@plt>
xor    %eax,%eax
sub    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ptrdiff_put@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<std_ptrdiff_str>:
test   %rdi,%rdi
je     1156 <std_ptrdiff_str+0x36>
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    (%rdi),%rbx
test   %rbx,%rbx
jns    1144 <std_ptrdiff_str+0x24>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
neg    %rbx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ptrdiff_put@plt>
ret

LLVM IR (-O0):
define void @std_ptrdiff_str(i8* noalias %0, i8* noalias %1, i32* noalias %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
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 %26
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i64*
%14 = load i64, i64* %13
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = call i32 @fputc(i8 signext 45, i32* %18)
%20 = load i64, i64* %7
%21 = sub nsw i64 0, %20
store i64 %21, i64* %7
br label %22
22: ; preds = %17, %11
%23 = load i64, i64* %7
%24 = load i32*, i32** %6
%25 = call i32 @ptrdiff_put(i64 %23, i32* %24)
br label %26
26: ; preds = %22, %3
ret void
}

LLVM IR (-O2):
define void @std_ptrdiff_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 i64*
%7 = load i64, i64* %6
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i32 @fputc(i8 signext 45, i32* %2)
%11 = sub nsw i64 0, %7
br label %12
12: ; preds = %9, %5
%13 = phi i64 [ %11, %9 ], [ %7, %5 ]
%14 = tail call i32 @ptrdiff_put(i64 %13, i32* %2)
br label %15
15: ; preds = %12, %3
ret void
}