void deps_calc_target(d, t) struct deps *d;
const char *t;
{
  char *o, *suffix;
  t = base_name(t);
  o = (char *)alloca(strlen(t) + 8);
  strcpy(o, t);
  suffix = strrchr(o, '.');
  if (suffix)
    strcpy(suffix, ".o");
  else
    strcat(o, ".o");
  deps_add_target(d, o);
}


x86 assembly (clang, -O0):
<deps_calc_target>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
call   1060 <base_name@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
add    $0x17,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rax
sub    %rcx,%rax
mov    %rax,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e1 <deps_calc_target+0x81>
mov    -0x20(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f1 <deps_calc_target+0x91>
mov    -0x18(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <deps_add_target@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deps_calc_target>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
xor    %eax,%eax
call   1060 <base_name@plt>
movslq %eax,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0x17,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
jne    11ab <deps_calc_target+0x5b>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %rbx,%rax
movb   $0x0,0x2(%rax)
movw   $0x6f2e,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <deps_add_target@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.deps = type opaque
@.str = [3 x i8] c".o\00"
define void @deps_calc_target(%struct.deps* %0, i8* %1) {
%3 = alloca %struct.deps*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store %struct.deps* %0, %struct.deps** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @base_name to i32 (i8*, ...)*)(i8* %7)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = add i64 %12, 8
%14 = alloca i8, i64 %13
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = load i8*, i8** %4
%17 = call i8* @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %5
%19 = call i8* @strrchr(i8* %18, i32 46)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i8*, i8** %6
%24 = call i8* @strcpy(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %28
25: ; preds = %2
%26 = load i8*, i8** %5
%27 = call i8* @strcat(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %25, %22
%29 = load %struct.deps*, %struct.deps** %3
%30 = load i8*, i8** %5
%31 = call i32 (%struct.deps*, i8*, ...) bitcast (i32 (...)* @deps_add_target to i32 (%struct.deps*, i8*, ...)*)(%struct.deps* %29, i8* %30)
ret void
}

LLVM IR (-O2):
%struct.deps = type opaque
@.str = [3 x i8] c".o\00"
define void @deps_calc_target(%struct.deps* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @base_name to i32 (i8*, ...)*)(i8* %1)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%7 = add i64 %6, 8
%8 = alloca i8, i64 %7
%9 = call i8* @strcpy(i8* %8, i8* dereferenceable(1) %5)
%10 = call i8* @strrchr(i8* %8, i32 46)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i64 @strlen(i8* %8)
%14 = getelementptr i8, i8* %8, i64 %13
br label %15
15: ; preds = %2, %12
%16 = phi i8* [ %14, %12 ], [ %10, %2 ]
%17 = call i32 (%struct.deps*, i8*, ...) bitcast (i32 (...)* @deps_add_target to i32 (%struct.deps*, i8*, ...)*)(%struct.deps* %0, i8* %8)
ret void
}