#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;
scalar_t__ putc(long, int /*<<< orphan*/ *);
int write_long(FILE *stream, long word) {
  if (putc(word >> 24, stream) == EOF)
    return -1;
  if (putc(word >> 16, stream) == EOF)
    return -1;
  if (putc(word >> 8, stream) == EOF)
    return -1;
  if (putc(word, stream) == EOF)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<write_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
sar    $0x18,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2eb0(%rip),%rcx
cmp    (%rcx),%rax
jne    114d <write_long+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <write_long+0xc7>
mov    -0x18(%rbp),%rdi
sar    $0x10,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
jne    117a <write_long+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <write_long+0xc7>
mov    -0x18(%rbp),%rdi
sar    $0x8,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%rax
jne    11a7 <write_long+0x97>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <write_long+0xc7>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <write_long+0xc0>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <write_long+0xc7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_long>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
sar    $0x18,%rdi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    0x2eb5(%rip),%r15
mov    $0xffffffff,%r14d
cmp    (%r15),%rax
je     117e <write_long+0x6e>
mov    %rbp,%rdi
sar    $0x10,%rdi
mov    %rbx,%rsi
call   1030 <putc@plt>
cmp    (%r15),%rax
je     117e <write_long+0x6e>
mov    %rbp,%rdi
sar    $0x8,%rdi
mov    %rbx,%rsi
call   1030 <putc@plt>
cmp    (%r15),%rax
je     117e <write_long+0x6e>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <putc@plt>
xor    %r14d,%r14d
cmp    (%r15),%rax
sete   %r14b
neg    %r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @write_long(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = ashr i64 %6, 24
%8 = load i32*, i32** %4
%9 = call i64 @putc(i64 %7, i32* %8)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %37
13: ; preds = %2
%14 = load i64, i64* %5
%15 = ashr i64 %14, 16
%16 = load i32*, i32** %4
%17 = call i64 @putc(i64 %15, i32* %16)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 -1, i32* %3
br label %37
21: ; preds = %13
%22 = load i64, i64* %5
%23 = ashr i64 %22, 8
%24 = load i32*, i32** %4
%25 = call i64 @putc(i64 %23, i32* %24)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %21
store i32 -1, i32* %3
br label %37
29: ; preds = %21
%30 = load i64, i64* %5
%31 = load i32*, i32** %4
%32 = call i64 @putc(i64 %30, i32* %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 -1, i32* %3
br label %37
36: ; preds = %29
store i32 0, i32* %3
br label %37
37: ; preds = %36, %35, %28, %20, %12
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @write_long(i32* nocapture %0, i64 %1) {
%3 = ashr i64 %1, 24
%4 = tail call i64 @putc(i64 %3, i32* %0)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %22, label %7
7: ; preds = %2
%8 = ashr i64 %1, 16
%9 = tail call i64 @putc(i64 %8, i32* %0)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %22, label %12
12: ; preds = %7
%13 = ashr i64 %1, 8
%14 = tail call i64 @putc(i64 %13, i32* %0)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = tail call i64 @putc(i64 %1, i32* %0)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
%21 = sext i1 %20 to i32
br label %22
22: ; preds = %17, %12, %7, %2
%23 = phi i32 [ -1, %2 ], [ -1, %7 ], [ -1, %12 ], [ %21, %17 ]
ret i32 %23
}