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

/* Variables and functions */
void write_u32(char **str, uint32_t i) {
  (*str)[0] = (unsigned char)(i >> 24) & 0xff;
  (*str)[1] = (unsigned char)(i >> 16) & 0xff;
  (*str)[2] = (unsigned char)(i >> 8) & 0xff;
  (*str)[3] = (unsigned char)i & 0xff;
  ;
  *str += 4;
}


x86 assembly (clang, -O0):
<write_u32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x1(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_u32>:
mov    %esi,%eax
mov    %esi,%ecx
shr    $0x18,%ecx
mov    (%rdi),%rdx
mov    %cl,(%rdx)
mov    %esi,%ecx
shr    $0x10,%ecx
mov    (%rdi),%rdx
mov    %cl,0x1(%rdx)
mov    (%rdi),%rcx
mov    %ah,0x2(%rcx)
mov    (%rdi),%rcx
mov    %al,0x3(%rcx)
addq   $0x4,(%rdi)
ret

LLVM IR (-O0):
define void @write_u32(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = ashr i32 %5, 24
%7 = trunc i32 %6 to i8
%8 = zext i8 %7 to i32
%9 = and i32 %8, 255
%10 = trunc i32 %9 to i8
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %10, i8* %13
%14 = load i32, i32* %4
%15 = ashr i32 %14, 16
%16 = trunc i32 %15 to i8
%17 = zext i8 %16 to i32
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = load i8**, i8*** %3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %19, i8* %22
%23 = load i32, i32* %4
%24 = ashr i32 %23, 8
%25 = trunc i32 %24 to i8
%26 = zext i8 %25 to i32
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = load i8**, i8*** %3
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 2
store i8 %28, i8* %31
%32 = load i32, i32* %4
%33 = trunc i32 %32 to i8
%34 = zext i8 %33 to i32
%35 = and i32 %34, 255
%36 = trunc i32 %35 to i8
%37 = load i8**, i8*** %3
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 3
store i8 %36, i8* %39
%40 = load i8**, i8*** %3
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 4
store i8* %42, i8** %40
ret void
}

LLVM IR (-O2):
define void @write_u32(i8** nocapture %0, i32 %1) {
%3 = lshr i32 %1, 24
%4 = trunc i32 %3 to i8
%5 = load i8*, i8** %0
store i8 %4, i8* %5
%6 = lshr i32 %1, 16
%7 = trunc i32 %6 to i8
%8 = load i8*, i8** %0
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %7, i8* %9
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %0
%13 = getelementptr inbounds i8, i8* %12, i64 2
store i8 %11, i8* %13
%14 = trunc i32 %1 to i8
%15 = load i8*, i8** %0
%16 = getelementptr inbounds i8, i8* %15, i64 3
store i8 %14, i8* %16
%17 = load i8*, i8** %0
%18 = getelementptr inbounds i8, i8* %17, i64 4
store i8* %18, i8** %0
ret void
}