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


x86 assembly (clang, -O0):
<std_ptrdiff_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_ptrdiff_put+0x34>
mov    -0x18(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <fputs@plt>
jmp    11bd <std_ptrdiff_put+0x8d>
mov    -0x18(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11a2 <std_ptrdiff_put+0x72>
mov    -0x18(%rbp),%rsi
mov    $0x2d,%edi
call   1050 <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>
mov    -0x18(%rbp),%rsi
mov    $0x3e,%edi
call   1050 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<std_ptrdiff_put>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
test   %rdi,%rdi
je     118f <std_ptrdiff_put+0x5f>
mov    %rdi,%rbx
lea    0xecd(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    (%rbx),%rbx
test   %rbx,%rbx
jns    1170 <std_ptrdiff_put+0x40>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
neg    %rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <ptrdiff_put@plt>
mov    $0x3e,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fputc@plt>
lea    0xe6a(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"<ptrdiff_t (NULL)>\00"
@.str.1 = [12 x i8] c"<ptrdiff_t \00"
define void @std_ptrdiff_put(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 %14, label %11
11: ; preds = %3
%12 = load i32*, i32** %6
%13 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %33
14: ; preds = %3
%15 = load i32*, i32** %6
%16 = call i32 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = load i8*, i8** %4
%18 = bitcast i8* %17 to i64*
%19 = load i64, i64* %18
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i32*, i32** %6
%24 = call i32 @fputc(i8 signext 45, i32* %23)
%25 = load i64, i64* %7
%26 = sub nsw i64 0, %25
store i64 %26, i64* %7
br label %27
27: ; preds = %22, %14
%28 = load i64, i64* %7
%29 = load i32*, i32** %6
%30 = call i32 @ptrdiff_put(i64 %28, i32* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fputc(i8 signext 62, i32* %31)
br label %33
33: ; preds = %27, %11
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"<ptrdiff_t (NULL)>\00"
@.str.1 = [12 x i8] c"<ptrdiff_t \00"
define void @std_ptrdiff_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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 18, i64 1, i32* %2)
br label %19
7: ; preds = %3
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 11, i64 1, i32* %2)
%9 = bitcast i8* %0 to i64*
%10 = load i64, i64* %9
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @fputc(i8 signext 45, i32* %2)
%14 = sub nsw i64 0, %10
br label %15
15: ; preds = %12, %7
%16 = phi i64 [ %14, %12 ], [ %10, %7 ]
%17 = tail call i32 @ptrdiff_put(i64 %16, i32* %2)
%18 = tail call i32 @fputc(i8 signext 62, i32* %2)
br label %19
19: ; preds = %15, %5
ret void
}