#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 */

/* Variables and functions */
char toupper(int /*<<< orphan*/);
int differentWord(char *s1, char *s2) {
  char c1, c2;
  for (;;) {
    c1 = toupper(*s1++);
    c2 = toupper(*s2++);
    if (c1 != c2)
      return c2 - c1;
    if (c1 == 0)
      return 0;
  }
}


x86 assembly (clang, -O0):
<differentWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     1176 <differentWord+0x66>
movsbl -0x1a(%rbp),%eax
movsbl -0x19(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <differentWord+0x84>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    118f <differentWord+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1194 <differentWord+0x84>
jmp    1120 <differentWord+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<differentWord>:
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
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
cmp    %bpl,%al
jne    1148 <differentWord+0x38>
add    $0x1,%rbx
test   %bpl,%bpl
jne    1120 <differentWord+0x10>
xor    %eax,%eax
jmp    1151 <differentWord+0x41>
movsbl %bpl,%ecx
movsbl %al,%eax
sub    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @differentWord(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %17, %2
%4 = phi i8* [ %1, %2 ], [ %18, %17 ]
%5 = phi i8* [ %0, %2 ], [ %19, %17 ]
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = tail call signext i8 @toupper(i32 %7)
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
%11 = tail call signext i8 @toupper(i32 %10)
%12 = icmp eq i8 %11, %8
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = sext i8 %8 to i32
%15 = sext i8 %11 to i32
%16 = sub nsw i32 %15, %14
br label %21
17: ; preds = %3
%18 = getelementptr inbounds i8, i8* %4, i64 1
%19 = getelementptr inbounds i8, i8* %5, i64 1
%20 = icmp eq i8 %8, 0
br i1 %20, label %21, label %3
21: ; preds = %17, %13
%22 = phi i32 [ %16, %13 ], [ 0, %17 ]
ret i32 %22
}