char *Tcl_DownShift(targetStr, sourceStr)
char *targetStr;
const char *sourceStr;
{
  register char theChar;
  if (targetStr == 0)
    targetStr = malloc(strlen((char *)sourceStr) + 1);
  for (; (theChar = *sourceStr) != '\0'; sourceStr++) {
    if (isupper(theChar))
      theChar = tolower(theChar);
    *targetStr++ = theChar;
  }
  *targetStr = '\0';
  return targetStr;
}


x86 assembly (clang, -O0):
<Tcl_DownShift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1174 <Tcl_DownShift+0x34>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
jmp    1179 <Tcl_DownShift+0x39>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11d1 <Tcl_DownShift+0x91>
movsbl -0x11(%rbp),%edi
call   1060 <isupper@plt>
cmp    $0x0,%eax
je     11ac <Tcl_DownShift+0x6c>
movsbl -0x11(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <Tcl_DownShift+0x39>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tcl_DownShift>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1166 <Tcl_DownShift+0x26>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    (%r14),%bpl
test   %bpl,%bpl
je     11b0 <Tcl_DownShift+0x70>
add    $0x1,%r14
jmp    1194 <Tcl_DownShift+0x54>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %bpl,(%rbx)
add    $0x1,%rbx
movzbl (%r14),%ebp
add    $0x1,%r14
test   %bpl,%bpl
je     11b0 <Tcl_DownShift+0x70>
movsbl %bpl,%r15d
mov    %r15d,%edi
call   1060 <isupper@plt>
test   %eax,%eax
je     1180 <Tcl_DownShift+0x40>
mov    %r15d,%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
jmp    1180 <Tcl_DownShift+0x40>
movb   $0x0,(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @Tcl_DownShift(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = add i64 %10, 1
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %3
br label %13
13: ; preds = %8, %2
br label %14
14: ; preds = %33, %13
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
store i8 %16, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = call i32 @isupper(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = call i32 @tolower(i32 %26)
%28 = trunc i32 %27 to i8
store i8 %28, i8* %5
br label %29
29: ; preds = %24, %19
%30 = load i8, i8* %5
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
store i8 %30, i8* %31
br label %33
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
br label %14
36: ; preds = %14
%37 = load i8*, i8** %3
store i8 0, i8* %37
%38 = load i8*, i8** %3
ret i8* %38
}

LLVM IR (-O2):
define i8* @Tcl_DownShift(i8* writeonly %0, i8* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = add i64 %5, 1
%7 = tail call i8* @malloc(i64 %6)
br label %8
8: ; preds = %4, %2
%9 = phi i8* [ %7, %4 ], [ %0, %2 ]
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 0
br i1 %11, label %28, label %12
12: ; preds = %8, %22
%13 = phi i8 [ %26, %22 ], [ %10, %8 ]
%14 = phi i8* [ %25, %22 ], [ %1, %8 ]
%15 = phi i8* [ %24, %22 ], [ %9, %8 ]
%16 = sext i8 %13 to i32
%17 = tail call i32 @isupper(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = tail call i32 @tolower(i32 %16)
%21 = trunc i32 %20 to i8
br label %22
22: ; preds = %19, %12
%23 = phi i8 [ %21, %19 ], [ %13, %12 ]
%24 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %23, i8* %15
%25 = getelementptr inbounds i8, i8* %14, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %12
28: ; preds = %22, %8
%29 = phi i8* [ %9, %8 ], [ %24, %22 ]
store i8 0, i8* %29
ret i8* %29
}