#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 */
int write(int, char *, int);
int lsb_write(int fh, int value) {
  char buffer[4];
  buffer[3] = value & 0xff;
  value >>= 8;
  buffer[2] = value & 0xff;
  value >>= 8;
  buffer[1] = value & 0xff;
  value >>= 8;
  buffer[0] = value & 0xff;
  return (write(fh, buffer, 4));
}


x86 assembly (clang, -O0):
<lsb_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xb(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xc(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsb_write>:
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 @lsb_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 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 [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %8, i8* %9
%10 = load i32, i32* %4
%11 = ashr i32 %10, 8
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %14, i8* %15
%16 = load i32, i32* %4
%17 = ashr i32 %16, 8
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %20, i8* %21
%22 = load i32, i32* %4
%23 = ashr i32 %22, 8
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 %26, i8* %27
%28 = load i32, i32* %3
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%30 = call i32 @write(i32 %28, i8* %29, i32 4)
ret i32 %30
}

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