#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 */
scalar_t__ tolower(char);
int compare_sequence(char *a, char *b, int l) {
  int i = 0;
  int differences = 0;
  for (i = 0; i < l; i++) {
    if (tolower(a[i]) != tolower(b[i])) {
      differences++;
    }
  }
  return differences;
}


x86 assembly (clang, -O0):
<compare_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1196 <compare_sequence+0x86>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1183 <compare_sequence+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1188 <compare_sequence+0x78>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <compare_sequence+0x28>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_sequence>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    115c <compare_sequence+0x4c>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%r13
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
xor    %ecx,%ecx
cmp    %rax,%r13
setne  %cl
add    %ecx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <compare_sequence+0x20>
jmp    115e <compare_sequence+0x4e>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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