#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 *ccstrcat(char *, char);
char *ccstrcpy(char *);
int ccstrlen(char *);
char *makeoutname(char *inname) {
  char *outname;
  int i, j = -1;
  for (i = 0; i < ccstrlen(inname); i++)
    if (inname[i] == '.')
      j = i;
  if (j >= 0) {
    inname[j] = 0;
  }
  outname = ccstrcpy(inname);
  outname = ccstrcat(outname, '.');
  outname = ccstrcat(outname, 'a');
  outname = ccstrcat(outname, 's');
  outname = ccstrcat(outname, 'm');
  return outname;
}


x86 assembly (clang, -O0):
<makeoutname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ccstrlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1194 <makeoutname+0x64>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1181 <makeoutname+0x51>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <makeoutname+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <makeoutname+0x1a>
cmpl   $0x0,-0x18(%rbp)
jl     11aa <makeoutname+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1040 <ccstrcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x61,%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x73,%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6d,%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeoutname>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <ccstrlen@plt>
test   %eax,%eax
jle    1176 <makeoutname+0x46>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x2e,(%r14,%rbx,1)
cmove  %ebx,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <ccstrlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <makeoutname+0x20>
test   %ebp,%ebp
js     1176 <makeoutname+0x46>
mov    %ebp,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
call   1040 <ccstrcpy@plt>
mov    %rax,%rdi
mov    $0x2e,%esi
call   1030 <ccstrcat@plt>
mov    %rax,%rdi
mov    $0x61,%esi
call   1030 <ccstrcat@plt>
mov    %rax,%rdi
mov    $0x73,%esi
call   1030 <ccstrcat@plt>
mov    %rax,%rdi
mov    $0x6d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ccstrcat@plt>

LLVM IR (-O0):
define i8* @makeoutname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 -1, i32* %5
store i32 0, i32* %4
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %2
%9 = call i32 @ccstrlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %25
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 46
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = load i32, i32* %4
store i32 %20, i32* %5
br label %21
21: ; preds = %19, %11
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
%26 = load i32, i32* %5
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i8*, i8** %2
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
br label %33
33: ; preds = %28, %25
%34 = load i8*, i8** %2
%35 = call i8* @ccstrcpy(i8* %34)
store i8* %35, i8** %3
%36 = load i8*, i8** %3
%37 = call i8* @ccstrcat(i8* %36, i8 signext 46)
store i8* %37, i8** %3
%38 = load i8*, i8** %3
%39 = call i8* @ccstrcat(i8* %38, i8 signext 97)
store i8* %39, i8** %3
%40 = load i8*, i8** %3
%41 = call i8* @ccstrcat(i8* %40, i8 signext 115)
store i8* %41, i8** %3
%42 = load i8*, i8** %3
%43 = call i8* @ccstrcat(i8* %42, i8 signext 109)
store i8* %43, i8** %3
%44 = load i8*, i8** %3
ret i8* %44
}

LLVM IR (-O2):
define i8* @makeoutname(i8* %0) {
%2 = tail call i32 @ccstrlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %1, %4
%5 = phi i64 [ %12, %4 ], [ 0, %1 ]
%6 = phi i32 [ %11, %4 ], [ -1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 46
%10 = trunc i64 %5 to i32
%11 = select i1 %9, i32 %10, i32 %6
%12 = add nuw nsw i64 %5, 1
%13 = tail call i32 @ccstrlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %4, label %16
16: ; preds = %4
%17 = icmp sgt i32 %11, -1
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = zext i32 %11 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %1, %18, %16
%22 = tail call i8* @ccstrcpy(i8* %0)
%23 = tail call i8* @ccstrcat(i8* %22, i8 signext 46)
%24 = tail call i8* @ccstrcat(i8* %23, i8 signext 97)
%25 = tail call i8* @ccstrcat(i8* %24, i8 signext 115)
%26 = tail call i8* @ccstrcat(i8* %25, i8 signext 109)
ret i8* %26
}