#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 *calloc(scalar_t__, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *get_out_file(char *infile) {
  char *outfile = calloc(strlen(infile) + 4, 1);
  char *p = outfile;
  strcpy(outfile, infile);
  while (1) {
    if (*p == '.') {
      *++p = 'b';
      *++p = 'f';
      *++p = 0;
      break;
    } else if (*p == 0) {
      *p++ = '.';
      *p++ = 'b';
      *p++ = 'f';
      *p = 0;
      break;
    }
    p++;
  }
  return outfile;
}


x86 assembly (clang, -O0):
<get_out_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x4,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11bd <get_out_file+0x8d>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x62,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x66,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,0x1(%rax)
jmp    1225 <get_out_file+0xf5>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    120f <get_out_file+0xdf>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x62,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x66,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1225 <get_out_file+0xf5>
jmp    1214 <get_out_file+0xe4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116f <get_out_file+0x3f>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_out_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x4(%rax),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1172 <get_out_file+0x42>
cmp    $0x2e,%cl
je     1179 <get_out_file+0x49>
add    $0x1,%rax
jmp    1160 <get_out_file+0x30>
movw   $0x622e,(%rax)
jmp    117d <get_out_file+0x4d>
movb   $0x62,0x1(%rax)
movw   $0x66,0x2(%rax)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @get_out_file(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 4
%4 = tail call i8* @calloc(i64 %3, i32 1)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
br label %6
6: ; preds = %13, %1
%7 = phi i8* [ %4, %1 ], [ %14, %13 ]
%8 = load i8, i8* %7
switch i8 %8, label %13 [
i8 46, label %9
i8 0, label %11
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
store i8 98, i8* %10
br label %15
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %7, i64 1
store i8 46, i8* %7
store i8 98, i8* %12
br label %15
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
15: ; preds = %11, %9
%16 = getelementptr inbounds i8, i8* %7, i64 2
store i8 102, i8* %16
%17 = getelementptr inbounds i8, i8* %7, i64 3
store i8 0, i8* %17
ret i8* %4
}