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

/* Variables and functions */
int /*<<< orphan*/ fwrite(unsigned char *, size_t, size_t,
                          int /*<<< orphan*/ *);
void src_long8_write(FILE *fd, int64_t val) {
  unsigned char b[8];
  b[7] = val & 255;
  b[6] = (val = val >> 8) & 255;
  b[5] = (val = val >> 8) & 255;
  b[4] = (val = val >> 8) & 255;
  b[3] = (val = val >> 8) & 255;
  b[2] = (val = val >> 8) & 255;
  b[1] = (val = val >> 8) & 255;
  b[0] = (val = val >> 8) & 255;
  fwrite(b, (size_t)1, (size_t)8, fd);
}


x86 assembly (clang, -O0):
<src_long8_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0xe(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0xf(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0x12(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0x13(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
and    $0xff,%eax
mov    %al,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<src_long8_write>:
push   %rax
mov    %rdi,%rcx
mov    %esi,%eax
bswap  %eax
mov    %eax,0x4(%rsp)
sar    $0x1f,%esi
movzbl %sil,%eax
imul   $0x1010101,%eax,%eax
mov    %eax,(%rsp)
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fwrite@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @src_long8_write(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [8 x i8]
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = and i32 %6, 255
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
store i8 %8, i8* %9
%10 = load i32, i32* %4
%11 = ashr i32 %10, 8
store i32 %11, i32* %4
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
store i8 %13, i8* %14
%15 = load i32, i32* %4
%16 = ashr i32 %15, 8
store i32 %16, i32* %4
%17 = and i32 %16, 255
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
store i8 %18, i8* %19
%20 = load i32, i32* %4
%21 = ashr i32 %20, 8
store i32 %21, i32* %4
%22 = and i32 %21, 255
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
store i8 %23, i8* %24
%25 = load i32, i32* %4
%26 = ashr i32 %25, 8
store i32 %26, i32* %4
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
store i8 %28, i8* %29
%30 = load i32, i32* %4
%31 = ashr i32 %30, 8
store i32 %31, i32* %4
%32 = and i32 %31, 255
%33 = trunc i32 %32 to i8
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 %33, i8* %34
%35 = load i32, i32* %4
%36 = ashr i32 %35, 8
store i32 %36, i32* %4
%37 = and i32 %36, 255
%38 = trunc i32 %37 to i8
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 %38, i8* %39
%40 = load i32, i32* %4
%41 = ashr i32 %40, 8
store i32 %41, i32* %4
%42 = and i32 %41, 255
%43 = trunc i32 %42 to i8
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 %43, i8* %44
%45 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%46 = load i32*, i32** %3
%47 = call i32 @fwrite(i8* %45, i64 1, i64 8, i32* %46)
ret void
}

LLVM IR (-O2):
define void @src_long8_write(i32* nocapture %0, i32 %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = trunc i32 %1 to i8
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
store i8 %5, i8* %6
%7 = lshr i32 %1, 8
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
store i8 %8, i8* %9
%10 = lshr i32 %1, 16
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
store i8 %11, i8* %12
%13 = lshr i32 %1, 24
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
store i8 %14, i8* %15
%16 = ashr i32 %1, 31
%17 = trunc i32 %16 to i8
%18 = call i32 @fwrite(i8* %4, i64 1, i64 8, i32* %0)
ret void
}