#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 */
scalar_t__ EOF;
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
scalar_t__ fputc(int, int /*<<< orphan*/ *);
int IO_Write_BE_LONG(long value, FILE *fp) {
  int c1, c2, c3, c4;
  assert(fp);
  c1 = value & 0xff;
  c2 = (value >> 8) & 0xff;
  c3 = (value >> 16) & 0xff;
  c4 = (value >> 24) & 0xff;
  return ((fputc(c4, fp) != EOF) && (fputc(c3, fp) != EOF) &&
          (fputc(c2, fp) != EOF) && (fputc(c1, fp) != EOF));
}


x86 assembly (clang, -O0):
<IO_Write_BE_LONG>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
sar    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
sar    $0x10,%rax
and    $0xff,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
sar    $0x18,%rax
and    $0xff,%rax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e57(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x21(%rbp)
je     1201 <IO_Write_BE_LONG+0xe1>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e33(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x21(%rbp)
je     1201 <IO_Write_BE_LONG+0xe1>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e0f(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x21(%rbp)
je     1201 <IO_Write_BE_LONG+0xe1>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IO_Write_BE_LONG>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
call   1040 <assert@plt>
mov    %rbp,%r15
mov    %ebp,%eax
shr    $0x18,%eax
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    0x2e9a(%rip),%r14
xor    %ebp,%ebp
cmp    (%r14),%rax
je     1193 <IO_Write_BE_LONG+0x73>
mov    %r15,%rax
shr    $0x10,%eax
movzbl %al,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    (%r14),%rax
je     1193 <IO_Write_BE_LONG+0x73>
mov    %r15,%rax
movzbl %ah,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    (%r14),%rax
je     1193 <IO_Write_BE_LONG+0x73>
movzbl %r15b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %ebp,%ebp
cmp    (%r14),%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @IO_Write_BE_LONG(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %3
store i32* %1, i32** %4
%9 = load i32*, i32** %4
%10 = call i32 @assert(i32* %9)
%11 = load i64, i64* %3
%12 = and i64 %11, 255
%13 = trunc i64 %12 to i32
store i32 %13, i32* %5
%14 = load i64, i64* %3
%15 = ashr i64 %14, 8
%16 = and i64 %15, 255
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
%18 = load i64, i64* %3
%19 = ashr i64 %18, 16
%20 = and i64 %19, 255
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
%22 = load i64, i64* %3
%23 = ashr i64 %22, 24
%24 = and i64 %23, 255
%25 = trunc i64 %24 to i32
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = load i32*, i32** %4
%28 = call i64 @fputc(i32 %26, i32* %27)
%29 = load i64, i64* @EOF
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %49
31: ; preds = %2
%32 = load i32, i32* %7
%33 = load i32*, i32** %4
%34 = call i64 @fputc(i32 %32, i32* %33)
%35 = load i64, i64* @EOF
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %49
37: ; preds = %31
%38 = load i32, i32* %6
%39 = load i32*, i32** %4
%40 = call i64 @fputc(i32 %38, i32* %39)
%41 = load i64, i64* @EOF
%42 = icmp ne i64 %40, %41
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = load i32, i32* %5
%45 = load i32*, i32** %4
%46 = call i64 @fputc(i32 %44, i32* %45)
%47 = load i64, i64* @EOF
%48 = icmp ne i64 %46, %47
br label %49
49: ; preds = %43, %37, %31, %2
%50 = phi i1 [ false, %37 ], [ false, %31 ], [ false, %2 ], [ %48, %43 ]
%51 = zext i1 %50 to i32
ret i32 %51
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @IO_Write_BE_LONG(i64 %0, i32* %1) {
%3 = tail call i32 @assert(i32* %1)
%4 = trunc i64 %0 to i32
%5 = and i32 %4, 255
%6 = lshr i32 %4, 8
%7 = and i32 %6, 255
%8 = lshr i32 %4, 24
%9 = tail call i64 @fputc(i32 %8, i32* %1)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %27, label %12
12: ; preds = %2
%13 = lshr i32 %4, 16
%14 = and i32 %13, 255
%15 = tail call i64 @fputc(i32 %14, i32* %1)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %27, label %18
18: ; preds = %12
%19 = tail call i64 @fputc(i32 %7, i32* %1)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %27, label %22
22: ; preds = %18
%23 = tail call i64 @fputc(i32 %5, i32* %1)
%24 = load i64, i64* @EOF
%25 = icmp ne i64 %23, %24
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %22, %18, %12, %2
%28 = phi i32 [ 0, %18 ], [ 0, %12 ], [ 0, %2 ], [ %26, %22 ]
ret i32 %28
}