#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__ ul;

/* Variables and functions */
int write(int, unsigned char *, int);
int wblong(int fd, unsigned long ul) {
  unsigned char data[4];
  data[0] = (char)(ul >> 24) & 0xff;
  data[1] = (char)(ul >> 16) & 0xff;
  data[2] = (char)(ul >> 8) & 0xff;
  data[3] = (char)(ul)&0xff;
  return write(fd, data, 4);
}


x86 assembly (clang, -O0):
<wblong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,-0x14(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wblong>:
push   %rax
bswap  %esi
mov    %esi,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @wblong(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca [4 x i8]
store i32 %0, i32* %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = lshr i64 %6, 24
%8 = trunc i64 %7 to i8
%9 = sext i8 %8 to i32
%10 = and i32 %9, 255
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i64, i64* %4
%14 = lshr i64 %13, 16
%15 = trunc i64 %14 to i8
%16 = sext i8 %15 to i32
%17 = and i32 %16, 255
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %18, i8* %19
%20 = load i64, i64* %4
%21 = lshr i64 %20, 8
%22 = trunc i64 %21 to i8
%23 = sext i8 %22 to i32
%24 = and i32 %23, 255
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %25, i8* %26
%27 = load i64, i64* %4
%28 = trunc i64 %27 to i8
%29 = sext i8 %28 to i32
%30 = and i32 %29, 255
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %31, i8* %32
%33 = load i32, i32* %3
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%35 = call i32 @write(i32 %33, i8* %34, i32 4)
ret i32 %35
}

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