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

/* Variables and functions */
int /*<<< orphan*/ write(int, scalar_t__ *, int);
void write_int(int fd, int val) {
  uint8_t bytes[4];
  bytes[0] = (uint8_t)((val >> 24) & 0xff);
  bytes[1] = (uint8_t)((val >> 16) & 0xff);
  bytes[2] = (uint8_t)((val >> 8) & 0xff);
  bytes[3] = (uint8_t)((val >> 0) & 0xff);
  write(fd, bytes, 4);
}


x86 assembly (clang, -O0):
<write_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_int>:
sub    $0x28,%rsp
mov    %esi,%eax
mov    %esi,%ecx
movzbl %ah,%edx
movzbl %al,%esi
shr    $0x18,%eax
mov    %rax,(%rsp)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %rax,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rsp,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x28,%rsp
ret

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

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