#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__ cpuidfn(int);
int /*<<< orphan*/ diffidx(char *, char *, size_t);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ loadstr(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int main(int argc, char *argv[]) {
  unsigned long n = (unsigned long)cpuidfn(1);
  char a[512] = "0123456789abcdef";
  char b[512] = "01c3456789abCdef";
  size_t alen = strlen(a);
  size_t blen = strlen(b);
  if ((n >> (20) & 1) == 0) {
    fputs("cpuid says this CPU hasn't SSE 4.2\n", stderr);
    exit(1);
  }
  if (argc > 1) {
    loadstr(a, argv[1], sizeof a - 1);
    alen = strlen(a);
  }
  if (argc > 2) {
    loadstr(b, argv[2], sizeof b - 1);
    blen = strlen(b);
  }
  printf("\"%s\" and \"%s\" differ at byte index %lu\n", a, b,
         diffidx(a, b, alen > blen ? blen : alen));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1030 <cpuidfn@plt>
mov    %rax,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x200,%edx
call   1090 <memcpy@plt>
lea    -0x420(%rbp),%rdi
lea    0x1033(%rip),%rsi
mov    $0x200,%edx
call   1090 <memcpy@plt>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x430(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x14,%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1232 <main+0xb2>
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
lea    0x11dd(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1268 <main+0xe8>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1ff,%edx
call   1080 <loadstr@plt>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x428(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    129e <main+0x11e>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x1ff,%edx
call   1080 <loadstr@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x430(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x448(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x428(%rbp),%rax
cmp    -0x430(%rbp),%rax
jbe    12fd <main+0x17d>
mov    -0x430(%rbp),%rax
mov    %rax,-0x458(%rbp)
jmp    130b <main+0x18b>
mov    -0x428(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x438(%rbp),%rsi
mov    -0x440(%rbp),%rdi
mov    -0x458(%rbp),%rdx
call   1070 <diffidx@plt>
mov    -0x450(%rbp),%rsi
mov    -0x448(%rbp),%rdx
mov    %eax,%ecx
lea    0x10e8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%edi
call   1030 <cpuidfn@plt>
mov    %rax,%rbp
lea    0xe59(%rip),%rsi
mov    %rsp,%rdi
mov    $0x200,%edx
call   1090 <memcpy@plt>
lea    0x1045(%rip),%rsi
lea    0x200(%rsp),%rbx
mov    $0x200,%edx
mov    %rbx,%rdi
call   1090 <memcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   $0x100000,%ebp
je     1287 <main+0x107>
mov    %rax,%rbx
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%r15d
jl     1240 <main+0xc0>
mov    0x8(%r14),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x1ff,%edx
call   1080 <loadstr@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
cmp    $0x2,%r15d
je     1243 <main+0xc3>
mov    0x10(%r14),%rsi
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%edx
call   1080 <loadstr@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
jmp    1243 <main+0xc3>
mov    %rax,%rbp
cmp    %rbx,%rbp
cmova  %rbx,%rbp
mov    %rsp,%rbx
lea    0x200(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <diffidx@plt>
lea    0x11ba(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
lea    0x1169(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@__const.main.a = [512 x i8] c"0123456789abcdef\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [512 x i8] c"01c3456789abCdef\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [36 x i8] c"cpuid says this CPU hasn't SSE 4.2\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"\22%s\22 and \22%s\22 differ at byte index %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i64 @cpuidfn(i32 1)
store i64 %11, i64* %6
%12 = bitcast [512 x i8]* %7 to i8*
%13 = bitcast [512 x i8]* %8 to i8*
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %9
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
store i64 %17, i64* %10
%18 = load i64, i64* %6
%19 = lshr i64 %18, 20
%20 = and i64 %19, 1
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 1
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @loadstr(i8* %30, i8* %33, i32 511)
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%36 = call i64 @strlen(i8* %35)
store i64 %36, i64* %9
br label %37
37: ; preds = %29, %26
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 2
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @loadstr(i8* %41, i8* %44, i32 511)
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%47 = call i64 @strlen(i8* %46)
store i64 %47, i64* %10
br label %48
48: ; preds = %40, %37
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%53 = load i64, i64* %9
%54 = load i64, i64* %10
%55 = icmp ugt i64 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %48
%57 = load i64, i64* %10
br label %60
58: ; preds = %48
%59 = load i64, i64* %9
br label %60
60: ; preds = %58, %56
%61 = phi i64 [ %57, %56 ], [ %59, %58 ]
%62 = call i32 @diffidx(i8* %51, i8* %52, i64 %61)
%63 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %49, i8* %50, i32 %62)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [512 x i8] c"0123456789abcdef\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [512 x i8] c"01c3456789abCdef\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [36 x i8] c"cpuid says this CPU hasn't SSE 4.2\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"\22%s\22 and \22%s\22 differ at byte index %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = tail call i64 @cpuidfn(i32 1)
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = call i64 @strlen(i8* %7)
%9 = and i64 %5, 1048576
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = call i64 @strlen(i8* %6)
%17 = icmp sgt i32 %0, 1
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @loadstr(i8* %6, i8* %20, i32 511)
%22 = call i64 @strlen(i8* %6)
%23 = icmp eq i32 %0, 2
br i1 %23, label %29, label %24
24: ; preds = %18
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @loadstr(i8* %7, i8* %26, i32 511)
%28 = call i64 @strlen(i8* %7)
br label %29
29: ; preds = %15, %24, %18
%30 = phi i64 [ %22, %24 ], [ %22, %18 ], [ %16, %15 ]
%31 = phi i64 [ %28, %24 ], [ %8, %18 ], [ %8, %15 ]
%32 = icmp ugt i64 %30, %31
%33 = select i1 %32, i64 %31, i64 %30
%34 = call i32 @diffidx(i8* %6, i8* %7, i64 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7, i32 %34)
ret i32 0
}