#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 */
scalar_t__ alloca(int);
char *checking_strdup(char *);
scalar_t__ file_exists_p(char *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ number_to_string(char *, int /*<<< orphan*/);
int strlen(char const *);
char *unique_name_1(const char *prefix) {
  int count = 1;
  int plen = strlen(prefix);
  char *template = (char *)alloca(plen + 1 + 24);
  char *template_tail = template + plen;
  memcpy(template, prefix, plen);
  *template_tail++ = '.';
  do
    number_to_string(template_tail, count++);
  while (file_exists_p(template));
  return checking_strdup(template);
}


x86 assembly (clang, -O0):
<unique_name_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
add    $0x18,%edi
call   1050 <alloca@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2e,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
call   1070 <number_to_string@plt>
mov    -0x18(%rbp),%rdi
call   1040 <file_exists_p@plt>
cmp    $0x0,%rax
jne    11c2 <unique_name_1+0x62>
mov    -0x18(%rbp),%rdi
call   1080 <checking_strdup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unique_name_1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0x19(%rbx),%edi
call   1050 <alloca@plt>
mov    %rax,%r14
movslq %ebx,%r12
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
lea    (%r14,%r12,1),%rbx
add    $0x1,%rbx
movb   $0x2e,(%r14,%r12,1)
mov    $0x1,%esi
lea    0x1(%rsi),%ebp
mov    %rbx,%rdi
call   1070 <number_to_string@plt>
mov    %r14,%rdi
call   1040 <file_exists_p@plt>
mov    %ebp,%esi
test   %rax,%rax
jne    11a0 <unique_name_1+0x40>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <checking_strdup@plt>

LLVM IR (-O0):
define i8* @unique_name_1(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
store i32 1, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
%11 = add nsw i32 %10, 24
%12 = call i64 @alloca(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %6
%18 = load i8*, i8** %5
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = call i32 @memcpy(i8* %18, i8* %19, i32 %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %6
store i8 46, i8* %22
br label %24
24: ; preds = %29, %1
%25 = load i8*, i8** %6
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
%28 = call i32 @number_to_string(i8* %25, i32 %26)
br label %29
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = call i64 @file_exists_p(i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %24, label %33
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = call i8* @checking_strdup(i8* %34)
ret i8* %35
}

LLVM IR (-O2):
define i8* @unique_name_1(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 25
%4 = tail call i64 @alloca(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %5, i64 %6
%8 = tail call i32 @memcpy(i8* %5, i8* %0, i32 %2)
%9 = getelementptr inbounds i8, i8* %7, i64 1
store i8 46, i8* %7
br label %10
10: ; preds = %10, %1
%11 = phi i32 [ 1, %1 ], [ %12, %10 ]
%12 = add nuw nsw i32 %11, 1
%13 = tail call i32 @number_to_string(i8* %9, i32 %11)
%14 = tail call i64 @file_exists_p(i8* %5)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %10
16: ; preds = %10
%17 = tail call i8* @checking_strdup(i8* %5)
ret i8* %17
}