#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 */
int strlen(char *);
scalar_t__ toupper(char);
int libHammingDistFunc(char *seq1, char *seq2) {
  int result, i;
  if (strlen(seq1) != strlen(seq2)) {
    result = -1;
  } else {
    result = 0;
    for (i = 0; i < strlen(seq1); i++) {
      if (toupper(seq1[i]) != toupper(seq2[i]))
        ++result;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<libHammingDistFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
je     115e <libHammingDistFunc+0x3e>
movl   $0xffffffff,-0x14(%rbp)
jmp    11df <libHammingDistFunc+0xbf>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11da <libHammingDistFunc+0xba>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11c7 <libHammingDistFunc+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <libHammingDistFunc+0xac>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <libHammingDistFunc+0x4c>
jmp    11df <libHammingDistFunc+0xbf>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libHammingDistFunc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0xffffffff,%ebp
cmp    %eax,%r15d
jne    1198 <libHammingDistFunc+0x78>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1196 <libHammingDistFunc+0x76>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
xor    %ecx,%ecx
cmp    %rax,%r15
setne  %cl
add    %ecx,%ebp
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <libHammingDistFunc+0x40>
jmp    1198 <libHammingDistFunc+0x78>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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