#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 int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, void const *, size_t);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int str1nstr(char *, char *, int);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void sstab_namebyname(char *old_sstab, char *new_sstab) {
  char nameidx[64];
  int idxpos;
  char tmpsstab[128];
  int old_sstab_len;
  time_t timer;
  memset((void *)(nameidx), 0, (size_t)(64));
  old_sstab_len = strlen(old_sstab);
  idxpos = str1nstr(old_sstab, "sstable", old_sstab_len);
  memset((void *)(tmpsstab), 0, (size_t)(128));
  memcpy((void *)(tmpsstab), (const void *)(old_sstab), (size_t)(idxpos));
  time(&timer);
  sprintf(nameidx, "%ld", timer);
  sprintf(new_sstab, "%s%s", tmpsstab, nameidx);
  return;
}


x86 assembly (clang, -O0):
<sstab_namebyname>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xe4(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xe4(%rbp),%edx
lea    0xe5d(%rip),%rsi
call   1070 <str1nstr@plt>
mov    %eax,-0x54(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x54(%rbp),%rdx
call   1050 <memcpy@plt>
lea    -0xe8(%rbp),%rdi
call   1060 <time@plt>
lea    -0x50(%rbp),%rdi
movslq -0xe8(%rbp),%rdx
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sstab_namebyname>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x10(%rsp),%r14
mov    $0x40,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1070 <str1nstr@plt>
mov    %eax,%ebp
lea    0x50(%rsp),%r12
mov    $0x80,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movslq %ebp,%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <memcpy@plt>
lea    0xc(%rsp),%rdi
call   1060 <time@plt>
movslq 0xc(%rsp),%rdx
lea    0xe2c(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe1f(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"sstable\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%s%s\00"
define void @sstab_namebyname(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [64 x i8]
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i64 64)
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %8
%16 = call i32 @str1nstr(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 %16, i32* %6
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i64 128)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%20 = load i8*, i8** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = call i32 @memcpy(i8* %19, i8* %20, i64 %22)
%24 = call i32 @time(i32* %9)
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i8*
%29 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"sstable\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%s%s\00"
define void @sstab_namebyname(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [64 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = call i32 @memset(i8* %6, i32 0, i64 64)
%10 = call i32 @strlen(i8* %0)
%11 = call i32 @str1nstr(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @memset(i8* %7, i32 0, i64 128)
%13 = sext i32 %11 to i64
%14 = call i32 @memcpy(i8* %7, i8* %0, i64 %13)
%15 = call i32 @time(i32* %5)
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %6)
ret void
}