#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 readTagCharacter(char const **);
int tagcmp(const char *s1, const char *s2) {
  int result;
  int c1, c2;
  do {
    c1 = (unsigned char)*s1++;
    c2 = readTagCharacter(&s2);
    result = c1 - c2;
  } while (result == 0 && c1 != '\0' && c2 != '\0');
  return result;
}


x86 assembly (clang, -O0):
<tagcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <readTagCharacter@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x1d(%rbp)
jne    1172 <tagcmp+0x62>
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
je     1172 <tagcmp+0x62>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1120 <tagcmp+0x10>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tagcmp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%ebp
mov    %r14,%rdi
call   1030 <readTagCharacter@plt>
mov    %eax,%ecx
mov    %ebp,%eax
sub    %ecx,%eax
jne    1150 <tagcmp+0x40>
test   %bpl,%bpl
je     1150 <tagcmp+0x40>
add    $0x1,%rbx
test   %ecx,%ecx
jne    1130 <tagcmp+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tagcmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %8
8: ; preds = %26, %2
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
%11 = load i8, i8* %9
%12 = zext i8 %11 to i32
store i32 %12, i32* %6
%13 = call i32 @readTagCharacter(i8** %4)
store i32 %13, i32* %7
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = sub nsw i32 %14, %15
store i32 %16, i32* %5
br label %17
17: ; preds = %8
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br label %26
26: ; preds = %23, %20, %17
%27 = phi i1 [ false, %20 ], [ false, %17 ], [ %25, %23 ]
br i1 %27, label %8, label %28
28: ; preds = %26
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
define i32 @tagcmp(i8* nocapture %0, i8* %1) {
%3 = alloca i8*
store i8* %1, i8** %3
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ %0, %2 ], [ %6, %4 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
%8 = zext i8 %7 to i32
%9 = call i32 @readTagCharacter(i8** %3)
%10 = sub nsw i32 %8, %9
%11 = icmp eq i32 %10, 0
%12 = icmp ne i8 %7, 0
%13 = select i1 %11, i1 %12, i1 false
%14 = icmp ne i32 %9, 0
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %4, label %16
16: ; preds = %4
ret i32 %10
}