#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 high_ver_name(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *tm_c_ver_name_(char *name, char *next_name, char *path) {
  int high, len;
  high = high_ver_name(name, path);
  if (high == (-1))
    next_name[0] = '\0';
  else {
    strcpy(next_name, name);
    len = strlen(name);
    next_name[len] = '.';
    next_name[len + 1] = '~';
    sprintf(next_name + len + 2, "%d", high + 1);
    len = strlen(next_name);
    next_name[len] = '~';
    next_name[len + 1] = '\0';
  }
  return next_name;
}


x86 assembly (clang, -O0):
<tm_c_ver_name_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <high_ver_name@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    117a <tm_c_ver_name_+0x3a>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11fa <tm_c_ver_name_+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x7e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
add    $0x2,%rdi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xe34(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x7e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_c_ver_name_>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,%rsi
call   1040 <high_ver_name@plt>
mov    %eax,%ebp
mov    %rbx,%rax
cmp    $0xffffffff,%ebp
je     11a5 <tm_c_ver_name_+0x65>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movw   $0x7e2e,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x2,%rdi
add    $0x1,%ebp
lea    0xe77(%rip),%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x7e,(%rbx,%rax,1)
add    %rbx,%rax
add    $0x1,%rax
movb   $0x0,(%rax)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i8* @tm_c_ver_name_(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %6
%11 = call i32 @high_ver_name(i8* %9, i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %16
br label %51
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %8
%23 = load i8*, i8** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 46, i8* %26
%27 = load i8*, i8** %5
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 126, i8* %31
%32 = load i8*, i8** %5
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
%39 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = load i8*, i8** %5
%41 = call i32 @strlen(i8* %40)
store i32 %41, i32* %8
%42 = load i8*, i8** %5
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 126, i8* %45
%46 = load i8*, i8** %5
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
store i8 0, i8* %50
br label %51
51: ; preds = %17, %14
%52 = load i8*, i8** %5
ret i8* %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i8* @tm_c_ver_name_(i8* %0, i8* returned %1, i8* %2) {
%4 = tail call i32 @high_ver_name(i8* %0, i8* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %23, label %6
6: ; preds = %3
%7 = tail call i32 @strcpy(i8* %1, i8* %0)
%8 = tail call i32 @strlen(i8* %0)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 46, i8* %10
%11 = add nsw i32 %8, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 126, i8* %13
%14 = getelementptr inbounds i8, i8* %10, i64 2
%15 = add nuw nsw i32 %4, 1
%16 = tail call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = tail call i32 @strlen(i8* %1)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 126, i8* %19
%20 = add nsw i32 %17, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
br label %23
23: ; preds = %3, %6
%24 = phi i8* [ %22, %6 ], [ %1, %3 ]
store i8 0, i8* %24
ret i8* %1
}