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

/* Variables and functions */
int write_fill_confd(int, char *, int);
int write_int(int fd, int val) {
  char buf[4];
  {
    ((char *)(&buf[0]))[0] = (char)((val) >> 24) & 0xff;
    ((char *)(&buf[0]))[1] = (char)((val) >> 16) & 0xff;
    ((char *)(&buf[0]))[2] = (char)((val) >> 8) & 0xff;
    ((char *)(&buf[0]))[3] = (char)((val)&0xff);
  };
  return write_fill_confd(fd, buf, 4);
}


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

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

LLVM IR (-O0):
define i32 @write_int(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 = ashr i32 %6, 24
%8 = trunc i32 %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
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
%14 = load i32, i32* %4
%15 = ashr i32 %14, 16
%16 = trunc i32 %15 to i8
%17 = sext i8 %16 to i32
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8 %19, i8* %21
%22 = load i32, i32* %4
%23 = ashr i32 %22, 8
%24 = trunc i32 %23 to i8
%25 = sext i8 %24 to i32
%26 = and i32 %25, 255
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds i8, i8* %28, i64 2
store i8 %27, i8* %29
%30 = load i32, i32* %4
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 3
store i8 %32, i8* %34
%35 = load i32, i32* %3
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%37 = call i32 @write_fill_confd(i32 %35, i8* %36, i32 4)
ret i32 %37
}

LLVM IR (-O2):
define i32 @write_int(i32 %0, i32 %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = lshr i32 %1, 24
%6 = trunc i32 %5 to i8
store i8 %6, i8* %4
%7 = lshr i32 %1, 16
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %8, i8* %9
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %11, i8* %12
%13 = trunc i32 %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_fill_confd(i32 %0, i8* %4, i32 4)
ret i32 %15
}