#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 */
char *InstanceNumberAsStr();
char *malloc(size_t const);
int /*<<< orphan*/ snprintf(char *, size_t const, char *, char const *,
                            char const *);
size_t strlen(char const *);
char *VsocUserName(void) {
  const char kVsocUserPrefix[] = "vsoc-";
  const char *num = InstanceNumberAsStr();
  const size_t length = (sizeof kVsocUserPrefix) + strlen(num);
  char *vsoc_user_name = malloc(length);
  snprintf(vsoc_user_name, length, "%s%s", kVsocUserPrefix, num);
  return vsoc_user_name;
}


x86 assembly (clang, -O0):
<VsocUserName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xeb2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    $0x0,%al
call   1060 <InstanceNumberAsStr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x6,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x6(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe6a(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VsocUserName>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movw   $0x2d,0xc(%rsp)
movl   $0x636f7376,0x8(%rsp)
63
xor    %eax,%eax
call   1060 <InstanceNumberAsStr@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x6(%rax),%rbx
mov    %rbx,%rdi
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0xe86(%rip),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%r8
call   1040 <snprintf@plt>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.VsocUserName.kVsocUserPrefix = [6 x i8] c"vsoc-\00"
@.str = [5 x i8] c"%s%s\00"
define i8* @VsocUserName() {
%1 = alloca [6 x i8]
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = bitcast [6 x i8]* %1 to i8*
%6 = call i8* (...) @InstanceNumberAsStr()
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add i64 6, %8
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i64, i64* %3
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @snprintf(i8* %12, i64 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = load i8*, i8** %4
ret i8* %17
}

LLVM IR (-O2):
@__const.VsocUserName.kVsocUserPrefix = [6 x i8] c"vsoc-\00"
@.str = [5 x i8] c"%s%s\00"
define i8* @VsocUserName() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = tail call i8* (...) @InstanceNumberAsStr()
%4 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%5 = add i64 %4, 6
%6 = tail call i8* @malloc(i64 %5)
%7 = call i32 @snprintf(i8* %6, i64 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3)
ret i8* %6
}