#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
char *strrchr(char *, char);
char *getobj(const char *pSrc) {
  static char buffer[255];
  int l = strlen(pSrc);
  char *pSearch;
  if (l < sizeof(buffer) - 5)
    l = sizeof(buffer) - 5;
  memcpy(buffer, pSrc, l);
  buffer[l] = '\0';
  pSearch = strrchr(buffer, '.');
  if (pSearch)
    strcpy(pSearch, ".o");
  return buffer;
}


x86 assembly (clang, -O0):
<getobj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0xfa,%rax
jae    116f <getobj+0x2f>
movl   $0xfa,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0x2ed3(%rip),%rdi
call   1060 <memcpy@plt>
movslq -0xc(%rbp),%rcx
lea    0x2ec3(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2eb8(%rip),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c1 <getobj+0x81>
mov    -0x18(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2e88(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getobj>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0xfb,%eax
mov    $0xfa,%ebp
cmovae %eax,%ebp
lea    0x2ef0(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rax,%r14,1)
mov    %r14,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1196 <getobj+0x56>
lea    0xe72(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0x2eb3(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@getobj.buffer = internal global [255 x i8] zeroinitializer
@.str = [3 x i8] c".o\00"
define i8* @getobj(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = icmp ult i64 %8, 250
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 250, i32* %3
br label %11
11: ; preds = %10, %1
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = call i32 @memcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0), i8* %12, i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i8* @strrchr(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0), i8 signext 46)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %11
%22 = load i8*, i8** %4
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %11
ret i8* getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@getobj.buffer = internal global [255 x i8] zeroinitializer
@.str = [3 x i8] c".o\00"
define i8* @getobj(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp ugt i32 %2, 250
%4 = select i1 %3, i32 %2, i32 250
%5 = tail call i32 @memcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0), i8* %0, i32 %4)
%6 = sext i32 %4 to i64
%7 = getelementptr inbounds [255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 %6
store i8 0, i8* %7
%8 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0), i8 signext 46)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
ret i8* getelementptr inbounds ([255 x i8], [255 x i8]* @getobj.buffer, i64 0, i64 0)
}