#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 *VsocUserName();
char *malloc(size_t);
int /*<<< orphan*/ snprintf(char *, size_t, char const *, char const *);
size_t strlen(char const *);
char *VsocHomeAdbShellPath(void) {
  const char kVsocAdbShellFmt[] = "/home/%s/bin/adbshell";
  const char *vsoc_user_name = VsocUserName();
  size_t length = (sizeof kVsocAdbShellFmt) + strlen(vsoc_user_name);
  char *adb_shell_path = malloc(length);
  snprintf(adb_shell_path, length, kVsocAdbShellFmt, vsoc_user_name);
  return adb_shell_path;
}


x86 assembly (clang, -O0):
<VsocHomeAdbShellPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xea6(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <VsocUserName@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x16,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VsocHomeAdbShellPath>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x6c6c6568736264,%rax
mov    %rax,0xe(%rsp)
xor    %eax,%eax
call   1050 <VsocUserName@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x16(%rax),%rbx
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rsp,%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %r15,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.VsocHomeAdbShellPath.kVsocAdbShellFmt = [22 x i8] c"/home/%s/bin/adbshell\00"
define i8* @VsocHomeAdbShellPath() {
%1 = alloca [22 x i8]
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = bitcast [22 x i8]* %1 to i8*
%6 = call i8* (...) @VsocUserName()
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add i64 22, %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 [22 x i8], [22 x i8]* %1, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @snprintf(i8* %12, i64 %13, i8* %14, i8* %15)
%17 = load i8*, i8** %4
ret i8* %17
}

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