#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 _SSE2_strdiff(char *, size_t, char *, size_t);
int _STTNI_strdiff(char *, size_t, char *, size_t);
int man_strdiff(char *, size_t, char *, size_t);
int /*<<< orphan*/ printf(char *, int, ...);
size_t strlen(char *);
int main(void) {
  char *a = "0123456789012345";
  char *b = "0123456789012345aa";
  size_t as = strlen(a);
  size_t bs = strlen(b);
  printf("%li\t%li\n", as, bs);
  printf("%i\n", _SSE2_strdiff(a, as, b, bs));
  printf("%i\n", _STTNI_strdiff(a, as, b, bs));
  printf("%i\n", man_strdiff(a, as, b, bs));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <_SSE2_strdiff@plt>
mov    %eax,%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <_STTNI_strdiff@plt>
mov    %eax,%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1070 <man_strdiff@plt>
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xed8(%rip),%rdi
mov    $0x12,%edx
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9c(%rip),%r14
lea    0xea6(%rip),%r15
mov    $0x10,%esi
mov    $0x12,%ecx
mov    %r14,%rdi
mov    %r15,%rdx
call   1050 <_SSE2_strdiff@plt>
lea    0xea6(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x10,%esi
mov    $0x12,%ecx
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <_STTNI_strdiff@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x10,%esi
mov    $0x12,%ecx
mov    %r14,%rdi
mov    %r15,%rdx
call   1060 <man_strdiff@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789012345\00"
@.str.1 = [19 x i8] c"0123456789012345aa\00"
@.str.2 = [9 x i8] c"%li\09%li\0A\00"
@.str.3 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %3
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %4
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %5
%10 = load i64, i64* %4
%11 = trunc i64 %10 to i32
%12 = load i64, i64* %5
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11, i64 %12)
%14 = load i8*, i8** %2
%15 = load i64, i64* %4
%16 = load i8*, i8** %3
%17 = load i64, i64* %5
%18 = call i32 @_SSE2_strdiff(i8* %14, i64 %15, i8* %16, i64 %17)
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i8*, i8** %2
%21 = load i64, i64* %4
%22 = load i8*, i8** %3
%23 = load i64, i64* %5
%24 = call i32 @_STTNI_strdiff(i8* %20, i64 %21, i8* %22, i64 %23)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %2
%27 = load i64, i64* %4
%28 = load i8*, i8** %3
%29 = load i64, i64* %5
%30 = call i32 @man_strdiff(i8* %26, i64 %27, i8* %28, i64 %29)
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789012345\00"
@.str.1 = [19 x i8] c"0123456789012345aa\00"
@.str.2 = [9 x i8] c"%li\09%li\0A\00"
@.str.3 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 16, i64 18)
%2 = tail call i32 @_SSE2_strdiff(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 18)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %2)
%4 = tail call i32 @_STTNI_strdiff(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 18)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%6 = tail call i32 @man_strdiff(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 18)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %6)
ret i32 0
}