#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__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
char *getOutputFile(char *file) {
  char *output = (char *)malloc(strlen(file) + strlen("_LOLS") + 2);
  sprintf(output, "%s_LOLS", file);
  int i;
  for (i = 0; i < strlen(output); i++) {
    if (output[i] == '.') {
      output[i] = '_';
    }
  }
  return output;
}


x86 assembly (clang, -O0):
<getOutputFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%edi
add    %eax,%edi
add    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8c(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11d0 <getOutputFile+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11bd <getOutputFile+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    11c2 <getOutputFile+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <getOutputFile+0x50>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOutputFile>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xebc(%rip),%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
lea    0xea0(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a1 <getOutputFile+0x71>
xor    %ebx,%ebx
jmp    1193 <getOutputFile+0x63>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11a1 <getOutputFile+0x71>
cmpb   $0x2e,(%r15,%rbx,1)
jne    1180 <getOutputFile+0x50>
movb   $0x5f,(%r15,%rbx,1)
jmp    1180 <getOutputFile+0x50>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"_LOLS\00"
@.str.1 = [8 x i8] c"%s_LOLS\00"
define i8* @getOutputFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = add nsw i32 %6, %7
%9 = add nsw i32 %8, 2
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = load i8*, i8** %2
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 0, i32* %4
br label %15
15: ; preds = %34, %1
%16 = load i32, i32* %4
%17 = load i8*, i8** %3
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %37
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 46
br i1 %27, label %28, label %33
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 95, i8* %32
br label %33
33: ; preds = %28, %20
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %15
37: ; preds = %15
%38 = load i8*, i8** %3
ret i8* %38
}

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