#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int flash_eeprom_read_uint32(int);
int /*<<< orphan*/ flash_eeprom_write_uint32(int, int);
void write_uint8(uint32_t offset, uint8_t value) {
  uint32_t base_offset = offset & ~3;
  uint32_t byte_offset = offset & 3;
  uint32_t base_word = flash_eeprom_read_uint32(base_offset);
  base_word &= ~(0xFF << (8 * byte_offset));
  base_word |= value << (8 * byte_offset);
  flash_eeprom_write_uint32(base_offset, base_word);
}


x86 assembly (clang, -O0):
<write_uint8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <flash_eeprom_read_uint32@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
mov    $0xff,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <flash_eeprom_write_uint32@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_uint8>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%r14d
and    $0xfffffffc,%r14d
mov    %r14d,%edi
call   1030 <flash_eeprom_read_uint32@plt>
shl    $0x3,%ebp
mov    $0xff,%edx
mov    %ebp,%ecx
shl    %cl,%edx
not    %edx
and    %eax,%edx
shl    %cl,%ebx
or     %edx,%ebx
mov    %r14d,%edi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <flash_eeprom_write_uint32@plt>

LLVM IR (-O0):
define void @write_uint8(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = and i32 %8, -4
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = and i32 %10, 3
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = call i32 @flash_eeprom_read_uint32(i32 %12)
store i32 %13, i32* %7
%14 = load i32, i32* %6
%15 = mul nsw i32 8, %14
%16 = shl i32 255, %15
%17 = xor i32 %16, -1
%18 = load i32, i32* %7
%19 = and i32 %18, %17
store i32 %19, i32* %7
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = mul nsw i32 8, %21
%23 = shl i32 %20, %22
%24 = load i32, i32* %7
%25 = or i32 %24, %23
store i32 %25, i32* %7
%26 = load i32, i32* %5
%27 = load i32, i32* %7
%28 = call i32 @flash_eeprom_write_uint32(i32 %26, i32 %27)
ret void
}

LLVM IR (-O2):
define void @write_uint8(i32 %0, i32 %1) {
%3 = and i32 %0, -4
%4 = tail call i32 @flash_eeprom_read_uint32(i32 %3)
%5 = shl i32 %0, 3
%6 = and i32 %5, 24
%7 = shl nuw i32 255, %6
%8 = xor i32 %7, -1
%9 = and i32 %4, %8
%10 = shl i32 %1, %6
%11 = or i32 %9, %10
%12 = tail call i32 @flash_eeprom_write_uint32(i32 %3, i32 %11)
ret void
}