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

/* Variables and functions */
char *malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char *, int);
uint8_t *encode_node_time(char *node, size_t node_size, uint8_t *time) {
  uint8_t *node_time = malloc(node_size + 20);
  if (!node_time)
    return NULL;
  memcpy(node_time, node, node_size);
  memcpy(node_time + node_size, time, 20);
  return node_time;
}


x86 assembly (clang, -O0):
<encode_node_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x14,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115d <encode_node_time+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    118e <encode_node_time+0x6e>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x14,%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_node_time>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x14(%rsi),%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1163 <encode_node_time+0x43>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rdi
add    %r15,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @encode_node_time(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%9 = load i64, i64* %6
%10 = add i64 %9, 20
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i8* null, i8** %4
br label %27
15: ; preds = %3
%16 = load i8*, i8** %8
%17 = load i8*, i8** %5
%18 = load i64, i64* %6
%19 = trunc i64 %18 to i32
%20 = call i32 @memcpy(i8* %16, i8* %17, i32 %19)
%21 = load i8*, i8** %8
%22 = load i64, i64* %6
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i8*, i8** %7
%25 = call i32 @memcpy(i8* %23, i8* %24, i32 20)
%26 = load i8*, i8** %8
store i8* %26, i8** %4
br label %27
27: ; preds = %15, %14
%28 = load i8*, i8** %4
ret i8* %28
}

LLVM IR (-O2):
define i8* @encode_node_time(i8* %0, i64 %1, i8* %2) {
%4 = add i64 %1, 20
%5 = tail call i8* @malloc(i64 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = trunc i64 %1 to i32
%9 = tail call i32 @memcpy(i8* %5, i8* %0, i32 %8)
%10 = getelementptr inbounds i8, i8* %5, i64 %1
%11 = tail call i32 @memcpy(i8* %10, i8* %2, i32 20)
br label %12
12: ; preds = %3, %7
ret i8* %5
}