#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 uint32_t;
struct ByteStream {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ByteStream_write_byte(struct ByteStream *, int);
void ByteStream_write_u32(struct ByteStream *self, uint32_t value) {
  ByteStream_write_byte(self, value >> 24 & 0xff);
  ByteStream_write_byte(self, value >> 16 & 0xff);
  ByteStream_write_byte(self, value >> 8 & 0xff);
  ByteStream_write_byte(self, value & 0xff);
}


x86 assembly (clang, -O0):
<ByteStream_write_u32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sar    $0x18,%esi
and    $0xff,%esi
call   1030 <ByteStream_write_byte@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sar    $0x10,%esi
and    $0xff,%esi
call   1030 <ByteStream_write_byte@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sar    $0x8,%esi
and    $0xff,%esi
call   1030 <ByteStream_write_byte@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
and    $0xff,%esi
call   1030 <ByteStream_write_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ByteStream_write_u32>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%eax
shr    $0x18,%eax
mov    %eax,%esi
call   1030 <ByteStream_write_byte@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <ByteStream_write_byte@plt>
movzbl %bh,%esi
mov    %r14,%rdi
call   1030 <ByteStream_write_byte@plt>
movzbl %bl,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ByteStream_write_byte@plt>

LLVM IR (-O0):
%struct.ByteStream = type { i32 }
define void @ByteStream_write_u32(%struct.ByteStream* %0, i32 %1) {
%3 = alloca %struct.ByteStream*
%4 = alloca i32
store %struct.ByteStream* %0, %struct.ByteStream** %3
store i32 %1, i32* %4
%5 = load %struct.ByteStream*, %struct.ByteStream** %3
%6 = load i32, i32* %4
%7 = ashr i32 %6, 24
%8 = and i32 %7, 255
%9 = call i32 @ByteStream_write_byte(%struct.ByteStream* %5, i32 %8)
%10 = load %struct.ByteStream*, %struct.ByteStream** %3
%11 = load i32, i32* %4
%12 = ashr i32 %11, 16
%13 = and i32 %12, 255
%14 = call i32 @ByteStream_write_byte(%struct.ByteStream* %10, i32 %13)
%15 = load %struct.ByteStream*, %struct.ByteStream** %3
%16 = load i32, i32* %4
%17 = ashr i32 %16, 8
%18 = and i32 %17, 255
%19 = call i32 @ByteStream_write_byte(%struct.ByteStream* %15, i32 %18)
%20 = load %struct.ByteStream*, %struct.ByteStream** %3
%21 = load i32, i32* %4
%22 = and i32 %21, 255
%23 = call i32 @ByteStream_write_byte(%struct.ByteStream* %20, i32 %22)
ret void
}

LLVM IR (-O2):
%struct.ByteStream = type { i32 }
define void @ByteStream_write_u32(%struct.ByteStream* %0, i32 %1) {
%3 = lshr i32 %1, 24
%4 = tail call i32 @ByteStream_write_byte(%struct.ByteStream* %0, i32 %3)
%5 = lshr i32 %1, 16
%6 = and i32 %5, 255
%7 = tail call i32 @ByteStream_write_byte(%struct.ByteStream* %0, i32 %6)
%8 = lshr i32 %1, 8
%9 = and i32 %8, 255
%10 = tail call i32 @ByteStream_write_byte(%struct.ByteStream* %0, i32 %9)
%11 = and i32 %1, 255
%12 = tail call i32 @ByteStream_write_byte(%struct.ByteStream* %0, i32 %11)
ret void
}