#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 */
struct evbuffer {
  int dummy;
};

/* Variables and functions */
int encode_int_internal(unsigned char *, unsigned long);
int /*<<< orphan*/ evbuffer_add(struct evbuffer *, unsigned char *, int);
int /*<<< orphan*/ evtag_encode_int(struct evbuffer *, int);
int /*<<< orphan*/ evtag_encode_tag(struct evbuffer *, unsigned long);
void evtag_marshal_int(struct evbuffer *evbuf, unsigned long tag,
                       unsigned long integer) {
  unsigned char data[5];
  int len = encode_int_internal(data, integer);
  evtag_encode_tag(evbuf, tag);
  evtag_encode_int(evbuf, len);
  evbuffer_add(evbuf, data, len);
}


x86 assembly (clang, -O0):
<evtag_marshal_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1d(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <encode_int_internal@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <evtag_encode_tag@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <evtag_encode_int@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <evbuffer_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evtag_marshal_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x3(%rsp),%r15
mov    %r15,%rdi
mov    %rdx,%rsi
call   1050 <encode_int_internal@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <evtag_encode_tag@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <evtag_encode_int@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1060 <evbuffer_add@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.evbuffer = type { i32 }
define void @evtag_marshal_int(%struct.evbuffer* %0, i64 %1, i64 %2) {
%4 = alloca %struct.evbuffer*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [5 x i8]
%8 = alloca i32
store %struct.evbuffer* %0, %struct.evbuffer** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%10 = load i64, i64* %6
%11 = call i32 @encode_int_internal(i8* %9, i64 %10)
store i32 %11, i32* %8
%12 = load %struct.evbuffer*, %struct.evbuffer** %4
%13 = load i64, i64* %5
%14 = call i32 @evtag_encode_tag(%struct.evbuffer* %12, i64 %13)
%15 = load %struct.evbuffer*, %struct.evbuffer** %4
%16 = load i32, i32* %8
%17 = call i32 @evtag_encode_int(%struct.evbuffer* %15, i32 %16)
%18 = load %struct.evbuffer*, %struct.evbuffer** %4
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%20 = load i32, i32* %8
%21 = call i32 @evbuffer_add(%struct.evbuffer* %18, i8* %19, i32 %20)
ret void
}

LLVM IR (-O2):
%struct.evbuffer = type { i32 }
define void @evtag_marshal_int(%struct.evbuffer* %0, i64 %1, i64 %2) {
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%6 = call i32 @encode_int_internal(i8* %5, i64 %2)
%7 = call i32 @evtag_encode_tag(%struct.evbuffer* %0, i64 %1)
%8 = call i32 @evtag_encode_int(%struct.evbuffer* %0, i32 %6)
%9 = call i32 @evbuffer_add(%struct.evbuffer* %0, i8* %5, i32 %6)
ret void
}