int m_upstrcmp(p, q)
char *p, *q;
{
  do {
    if (m_upper((int)*p) < m_upper((int)*q))
      return (-1);
    if (m_upper((int)*p) > m_upper((int)*q++))
      return (1);
  } while (*p++);
  return (0);
}


x86 assembly (clang, -O0):
<m_upstrcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1030 <m_upper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1030 <m_upper@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1158 <m_upstrcmp+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <m_upstrcmp+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1030 <m_upper@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
mov    $0x0,%al
call   1030 <m_upper@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jle    119b <m_upstrcmp+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11bf <m_upstrcmp+0xaf>
jmp    11a0 <m_upstrcmp+0x90>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,(%rax)
jne    1120 <m_upstrcmp+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_upstrcmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
xor    %eax,%eax
call   1030 <m_upper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
xor    %eax,%eax
call   1030 <m_upper@plt>
cmp    %eax,%ebp
jl     116b <m_upstrcmp+0x5b>
movsbl (%r15,%rbx,1),%edi
xor    %eax,%eax
call   1030 <m_upper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
xor    %eax,%eax
call   1030 <m_upper@plt>
cmp    %eax,%ebp
jg     1172 <m_upstrcmp+0x62>
cmpb   $0x0,(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1120 <m_upstrcmp+0x10>
xor    %eax,%eax
jmp    1177 <m_upstrcmp+0x67>
mov    $0xffffffff,%eax
jmp    1177 <m_upstrcmp+0x67>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @m_upstrcmp(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %21, %2
%4 = phi i8* [ %0, %2 ], [ %23, %21 ]
%5 = phi i8* [ %1, %2 ], [ %22, %21 ]
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @m_upper to i32 (i32, ...)*)(i32 %7)
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @m_upper to i32 (i32, ...)*)(i32 %10)
%12 = icmp slt i32 %8, %11
br i1 %12, label %26, label %13
13: ; preds = %3
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @m_upper to i32 (i32, ...)*)(i32 %15)
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @m_upper to i32 (i32, ...)*)(i32 %18)
%20 = icmp sgt i32 %16, %19
br i1 %20, label %26, label %21
21: ; preds = %13
%22 = getelementptr inbounds i8, i8* %5, i64 1
%23 = getelementptr inbounds i8, i8* %4, i64 1
%24 = load i8, i8* %4
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %3
26: ; preds = %21, %13, %3
%27 = phi i32 [ -1, %3 ], [ 1, %13 ], [ 0, %21 ]
ret i32 %27
}