#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 */

/* Variables and functions */
unsigned char sprintf(char *, char *, intptr_t);
int write(int, ...);
int /*<<< orphan*/ x_perror(char *);
void send_long(intptr_t value) {
  unsigned char size;
  char lbuf[64];
  size = sprintf(lbuf, "%lx", value);
  if (write(1, &size, 1) != 1) {
    x_perror("send_long");
  }
  if (write(1, lbuf, size) != (int)size) {
    x_perror("send_long");
  }
}


x86 assembly (clang, -O0):
<send_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb5(%rip),%rsi
call   1050 <sprintf@plt>
mov    %al,-0x9(%rbp)
mov    $0x1,%edx
lea    -0x9(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1040 <write@plt>
cmp    $0x1,%eax
je     117a <send_long+0x4a>
lea    0xe8f(%rip),%rdi
call   1030 <x_perror@plt>
lea    -0x50(%rbp),%rsi
movzbl -0x9(%rbp),%edx
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <write@plt>
movzbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     11a6 <send_long+0x76>
lea    0xe63(%rip),%rdi
call   1030 <x_perror@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_long>:
sub    $0x58,%rsp
mov    %rdi,%rdx
lea    0xec2(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <sprintf@plt>
mov    %al,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
cmp    $0x1,%eax
je     1173 <send_long+0x43>
lea    0xe96(%rip),%rdi
call   1030 <x_perror@plt>
movzbl 0xf(%rsp),%edx
lea    0x10(%rsp),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <write@plt>
movzbl 0xf(%rsp),%ecx
cmp    %ecx,%eax
je     119e <send_long+0x6e>
lea    0xe6b(%rip),%rdi
call   1030 <x_perror@plt>
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lx\00"
@.str.1 = [10 x i8] c"send_long\00"
define void @send_long(i64 %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca [64 x i8]
store i64 %0, i64* %2
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = load i64, i64* %2
%7 = call zeroext i8 @sprintf(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %6)
store i8 %7, i8* %3
%8 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @x_perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = call i32 (i32, ...) @write(i32 1, i8* %13, i32 %15)
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @x_perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lx\00"
@.str.1 = [10 x i8] c"send_long\00"
define void @send_long(i64 %0) {
%2 = alloca i8
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call zeroext i8 @sprintf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %0)
store i8 %5, i8* %2
%6 = call i32 (i32, ...) @write(i32 1, i8* %2, i32 1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @x_perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = call i32 (i32, ...) @write(i32 1, i8* %4, i32 %12)
%14 = load i8, i8* %2
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %13, %15
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = call i32 @x_perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %10
ret void
}