#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 */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int mls_type_set_int(unsigned char *buf, unsigned int *len, int src) {
  int size = 4;
  assert(4 <= *len);
  buf[0] = (unsigned char)((src >> 24) & 0xff);
  buf[1] = (unsigned char)((src >> 16) & 0xff);
  buf[2] = (unsigned char)((src >> 8) & 0xff);
  buf[3] = (unsigned char)(src & 0xff);
  *len -= size;
  return size;
}


x86 assembly (clang, -O0):
<mls_type_set_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    $0x4,%eax
cmp    (%rcx),%eax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mls_type_set_int>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
cmpl   $0x4,(%rsi)
setae  %dil
call   1030 <assert@plt>
bswap  %ebx
mov    %ebx,(%r15)
addl   $0xfffffffc,(%r14)
mov    $0x4,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @mls_type_set_int(i8* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = icmp ugt i32 %4, 3
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = lshr i32 %2, 24
%9 = trunc i32 %8 to i8
store i8 %9, i8* %0
%10 = lshr i32 %2, 16
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %11, i8* %12
%13 = lshr i32 %2, 8
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %14, i8* %15
%16 = trunc i32 %2 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %16, i8* %17
%18 = load i32, i32* %1
%19 = add i32 %18, -4
store i32 %19, i32* %1
ret i32 4
}