char const *normalize_arg(s, b)
char const *s;
char **b;
{
  char *t;
  if (*s == '-') {
    *b = t = testalloc(strlen(s) + 3);
    (void)sprintf(t, ".%c%s", '/', s);
    return t;
  } else {
    *b = 0;
    return s;
  }
}


x86 assembly (clang, -O0):
<normalize_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    119d <normalize_arg+0x6d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x3,%rdi
mov    $0x0,%al
call   1040 <testalloc@plt>
movslq %eax,%rcx
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xe7c(%rip),%rsi
mov    $0x2f,%edx
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <normalize_arg+0x80>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_arg>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x2d,(%rdi)
jne    1177 <normalize_arg+0x47>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x3(%rax),%rdi
xor    %eax,%eax
call   1040 <testalloc@plt>
movslq %eax,%r15
mov    %r15,(%r14)
lea    0xea0(%rip),%rsi
mov    %r15,%rdi
mov    $0x2f,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15,%rbx
jmp    117e <normalize_arg+0x4e>
movq   $0x0,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c".%c%s\00"
define i8* @normalize_arg(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 45
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = add i64 %13, 3
%15 = call i32 (i64, ...) bitcast (i32 (...)* @testalloc to i32 (i64, ...)*)(i64 %14)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
store i8* %17, i8** %18
%19 = load i8*, i8** %6
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 47, i8* %20)
%22 = load i8*, i8** %6
store i8* %22, i8** %3
br label %26
23: ; preds = %2
%24 = load i8**, i8*** %5
store i8* null, i8** %24
%25 = load i8*, i8** %4
store i8* %25, i8** %3
br label %26
26: ; preds = %23, %11
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
@.str = [6 x i8] c".%c%s\00"
define i8* @normalize_arg(i8* %0, i8** nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 @strlen(i8* %0)
%7 = add i64 %6, 3
%8 = tail call i32 (i64, ...) bitcast (i32 (...)* @testalloc to i32 (i64, ...)*)(i64 %7)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %1
%11 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 47, i8* %0)
br label %13
12: ; preds = %2
store i8* null, i8** %1
br label %13
13: ; preds = %12, %5
%14 = phi i8* [ %10, %5 ], [ %0, %12 ]
ret i8* %14
}