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

/* Variables and functions */
int /*<<< orphan*/ encodeFirstByte(int /*<<< orphan*/);
int /*<<< orphan*/ encodeFourthByte(int /*<<< orphan*/);
int /*<<< orphan*/ encodeSecondByte(int /*<<< orphan*/);
int /*<<< orphan*/ encodeThirdByte(int /*<<< orphan*/);
void encode(uint32_t src, uint8_t *dest) {
  dest[0] = encodeFirstByte(src);
  dest[1] = encodeSecondByte(src);
  dest[2] = encodeThirdByte(src);
  dest[3] = encodeFourthByte(src);
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <encodeFirstByte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
call   1050 <encodeSecondByte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%edi
call   1030 <encodeThirdByte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x4(%rbp),%edi
call   1060 <encodeFourthByte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <encodeFirstByte@plt>
mov    %eax,(%rbx)
mov    %ebp,%edi
call   1050 <encodeSecondByte@plt>
mov    %eax,0x4(%rbx)
mov    %ebp,%edi
call   1030 <encodeThirdByte@plt>
mov    %eax,0x8(%rbx)
mov    %ebp,%edi
call   1060 <encodeFourthByte@plt>
mov    %eax,0xc(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @encode(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
%6 = call i32 @encodeFirstByte(i32 %5)
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 %6, i32* %8
%9 = load i32, i32* %3
%10 = call i32 @encodeSecondByte(i32 %9)
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %10, i32* %12
%13 = load i32, i32* %3
%14 = call i32 @encodeThirdByte(i32 %13)
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 2
store i32 %14, i32* %16
%17 = load i32, i32* %3
%18 = call i32 @encodeFourthByte(i32 %17)
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 3
store i32 %18, i32* %20
ret void
}

LLVM IR (-O2):
define void @encode(i32 %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @encodeFirstByte(i32 %0)
store i32 %3, i32* %1
%4 = tail call i32 @encodeSecondByte(i32 %0)
%5 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %4, i32* %5
%6 = tail call i32 @encodeThirdByte(i32 %0)
%7 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %6, i32* %7
%8 = tail call i32 @encodeFourthByte(i32 %0)
%9 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %8, i32* %9
ret void
}