#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 /*<<< orphan*/ assert(int);
int /*<<< orphan*/ emit_adc(int, int);
int /*<<< orphan*/ emit_adcimm(int, int);
int /*<<< orphan*/ emit_addimm_and_set_flags(int, int);
int /*<<< orphan*/ emit_andimm(int, int, int);
int /*<<< orphan*/ emit_mov(int, int);
int /*<<< orphan*/ emit_not(int, int);
int /*<<< orphan*/ emit_popreg(int);
int /*<<< orphan*/ emit_pushreg(int);
int /*<<< orphan*/ emit_shrimm(int, int, int);
int /*<<< orphan*/ emit_xor(int, int, int);
void emit_cmpstr(int s1, int s2, int sr, int temp) {
  assert(temp >= 0);
  emit_pushreg(s2);
  emit_xor(s1, s2, s2);
  emit_shrimm(sr, 1, sr);
  emit_mov(s2, temp);
  emit_addimm_and_set_flags(0 - 0x01010101, temp);
  emit_adcimm(-1, temp);
  emit_not(s2, s2);
  emit_xor(temp, s2, temp);
  emit_andimm(temp, 0x01010101, temp);
  emit_addimm_and_set_flags(-1, temp);
  emit_adc(sr, sr);
  emit_popreg(s2);
}


x86 assembly (clang, -O0):
<emit_cmpstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%edi
call   1050 <emit_pushreg@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1060 <emit_xor@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   10b0 <emit_shrimm@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <emit_mov@plt>
mov    -0x10(%rbp),%esi
mov    $0xfefefeff,%edi
call   10a0 <emit_addimm_and_set_flags@plt>
mov    -0x10(%rbp),%esi
mov    $0xffffffff,%edi
call   1030 <emit_adcimm@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <emit_not@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <emit_xor@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    $0x1010101,%esi
call   10c0 <emit_andimm@plt>
mov    -0x10(%rbp),%esi
mov    $0xffffffff,%edi
call   10a0 <emit_addimm_and_set_flags@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10d0 <emit_adc@plt>
mov    -0x8(%rbp),%edi
call   1070 <emit_popreg@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_cmpstr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%r15d
mov    %ecx,%edi
not    %edi
shr    $0x1f,%edi
call   1080 <assert@plt>
mov    %ebx,%edi
call   1050 <emit_pushreg@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebx,%edx
call   1060 <emit_xor@plt>
mov    %r14d,%edi
mov    $0x1,%esi
mov    %r14d,%edx
call   10b0 <emit_shrimm@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <emit_mov@plt>
mov    $0xfefefeff,%edi
mov    %ebp,%esi
call   10a0 <emit_addimm_and_set_flags@plt>
mov    $0xffffffff,%edi
mov    %ebp,%esi
call   1030 <emit_adcimm@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1090 <emit_not@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1060 <emit_xor@plt>
mov    %ebp,%edi
mov    $0x1010101,%esi
mov    %ebp,%edx
call   10c0 <emit_andimm@plt>
mov    $0xffffffff,%edi
mov    %ebp,%esi
call   10a0 <emit_addimm_and_set_flags@plt>
mov    %r14d,%edi
mov    %r14d,%esi
call   10d0 <emit_adc@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <emit_popreg@plt>

LLVM IR (-O0):
define void @emit_cmpstr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp sge i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %6
%14 = call i32 @emit_pushreg(i32 %13)
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = load i32, i32* %6
%18 = call i32 @emit_xor(i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %7
%20 = load i32, i32* %7
%21 = call i32 @emit_shrimm(i32 %19, i32 1, i32 %20)
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = call i32 @emit_mov(i32 %22, i32 %23)
%25 = load i32, i32* %8
%26 = call i32 @emit_addimm_and_set_flags(i32 -16843009, i32 %25)
%27 = load i32, i32* %8
%28 = call i32 @emit_adcimm(i32 -1, i32 %27)
%29 = load i32, i32* %6
%30 = load i32, i32* %6
%31 = call i32 @emit_not(i32 %29, i32 %30)
%32 = load i32, i32* %8
%33 = load i32, i32* %6
%34 = load i32, i32* %8
%35 = call i32 @emit_xor(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %8
%37 = load i32, i32* %8
%38 = call i32 @emit_andimm(i32 %36, i32 16843009, i32 %37)
%39 = load i32, i32* %8
%40 = call i32 @emit_addimm_and_set_flags(i32 -1, i32 %39)
%41 = load i32, i32* %7
%42 = load i32, i32* %7
%43 = call i32 @emit_adc(i32 %41, i32 %42)
%44 = load i32, i32* %6
%45 = call i32 @emit_popreg(i32 %44)
ret void
}

LLVM IR (-O2):
define void @emit_cmpstr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = xor i32 %3, -1
%6 = lshr i32 %5, 31
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @emit_pushreg(i32 %1)
%9 = tail call i32 @emit_xor(i32 %0, i32 %1, i32 %1)
%10 = tail call i32 @emit_shrimm(i32 %2, i32 1, i32 %2)
%11 = tail call i32 @emit_mov(i32 %1, i32 %3)
%12 = tail call i32 @emit_addimm_and_set_flags(i32 -16843009, i32 %3)
%13 = tail call i32 @emit_adcimm(i32 -1, i32 %3)
%14 = tail call i32 @emit_not(i32 %1, i32 %1)
%15 = tail call i32 @emit_xor(i32 %3, i32 %1, i32 %3)
%16 = tail call i32 @emit_andimm(i32 %3, i32 16843009, i32 %3)
%17 = tail call i32 @emit_addimm_and_set_flags(i32 -1, i32 %3)
%18 = tail call i32 @emit_adc(i32 %2, i32 %2)
%19 = tail call i32 @emit_popreg(i32 %1)
ret void
}