#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*/ __getmachinename(unsigned char *);
int /*<<< orphan*/ __getusername(unsigned char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strInsert(unsigned char *, ...);
int strlen(unsigned char *);
void genKey(unsigned char *key, int size) {
  unsigned char hostname[1024];
  unsigned char username[1024];
  memset(key, '0', size);
  __getusername(username);
  __getmachinename(hostname);
  strInsert(key, hostname, 0, strlen(hostname));
  strInsert(key, "::", strlen(hostname), 2);
  strInsert(key, username, strlen(hostname) + 2, strlen(username));
  key[size] = '\0';
}


x86 assembly (clang, -O0):
<genKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x30,%esi
call   1040 <memset@plt>
lea    -0x810(%rbp),%rdi
call   1050 <__getusername@plt>
lea    -0x410(%rbp),%rdi
call   1070 <__getmachinename@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x840(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x840(%rbp),%rdi
mov    -0x838(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
mov    $0x0,%al
call   1060 <strInsert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x830(%rbp),%rdi
mov    %eax,%edx
lea    0xe10(%rip),%rsi
mov    $0x2,%ecx
mov    $0x0,%al
call   1060 <strInsert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x828(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x820(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x2,%eax
mov    %eax,-0x814(%rbp)
lea    -0x810(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x828(%rbp),%rdi
mov    -0x820(%rbp),%rsi
mov    -0x814(%rbp),%edx
mov    %eax,%ecx
mov    $0x0,%al
call   1060 <strInsert@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genKey>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
mov    $0x30,%esi
mov    %r15d,%edx
call   1040 <memset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <__getusername@plt>
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <__getmachinename@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <strInsert@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1060 <strInsert@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
lea    0x2(%rax),%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <strInsert@plt>
movslq %r15d,%rax
movb   $0x0,(%rbx,%rax,1)
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"::\00"
define void @genKey(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i32 @memset(i8* %7, i32 48, i32 %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call i32 @__getusername(i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = call i32 @__getmachinename(i8* %12)
%14 = load i8*, i8** %3
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 (i8*, ...) @strInsert(i8* %14, i8* %15, i32 0, i32 %17)
%19 = load i8*, i8** %3
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 (i8*, ...) @strInsert(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21, i32 2)
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %26, 2
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = call i32 (i8*, ...) @strInsert(i8* %23, i8* %24, i32 %27, i32 %29)
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"::\00"
define void @genKey(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @memset(i8* %0, i32 48, i32 %1)
%8 = call i32 @__getusername(i8* %6)
%9 = call i32 @__getmachinename(i8* %5)
%10 = call i32 @strlen(i8* %5)
%11 = call i32 (i8*, ...) @strInsert(i8* %0, i8* %5, i32 0, i32 %10)
%12 = call i32 @strlen(i8* %5)
%13 = call i32 (i8*, ...) @strInsert(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12, i32 2)
%14 = call i32 @strlen(i8* %5)
%15 = add nsw i32 %14, 2
%16 = call i32 @strlen(i8* %6)
%17 = call i32 (i8*, ...) @strInsert(i8* %0, i8* %6, i32 %15, i32 %16)
%18 = sext i32 %1 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
ret void
}