int checkrevpair(num1, num2) const char *num1, *num2;
{
  unsigned length = countnumflds(num1);
  if (countnumflds(num2) != length ||
      2 < length && compartial(num1, num2, length - 1) != 0) {
    error("invalid branch or revision pair %s : %s", num1, num2);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkrevpair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <countnumflds@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <countnumflds@plt>
cmp    -0x1c(%rbp),%eax
jne    118e <checkrevpair+0x5e>
mov    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jae    11b0 <checkrevpair+0x80>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    $0x0,%al
call   1050 <compartial@plt>
cmp    $0x0,%eax
je     11b0 <checkrevpair+0x80>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <error@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <checkrevpair+0x87>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkrevpair>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <countnumflds@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <countnumflds@plt>
cmp    %ebx,%eax
jne    1174 <checkrevpair+0x44>
mov    $0x1,%ebp
cmp    $0x3,%ebx
jb     118a <checkrevpair+0x5a>
add    $0xffffffff,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <compartial@plt>
test   %eax,%eax
je     118a <checkrevpair+0x5a>
lea    0xe85(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <error@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"invalid branch or revision pair %s : %s\00"
define i32 @checkrevpair(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @countnumflds to i32 (i8*, ...)*)(i8* %7)
store i32 %8, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @countnumflds to i32 (i8*, ...)*)(i8* %9)
%11 = load i32, i32* %6
%12 = icmp ne i32 %10, %11
br i1 %12, label %23, label %13
13: ; preds = %2
%14 = load i32, i32* %6
%15 = icmp ult i32 2, %14
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = sub i32 %19, 1
%21 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @compartial to i32 (i8*, i8*, i32, ...)*)(i8* %17, i8* %18, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %16, %2
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25)
store i32 0, i32* %3
br label %28
27: ; preds = %16, %13
store i32 1, i32* %3
br label %28
28: ; preds = %27, %23
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [40 x i8] c"invalid branch or revision pair %s : %s\00"
define i32 @checkrevpair(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @countnumflds to i32 (i8*, ...)*)(i8* %0)
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @countnumflds to i32 (i8*, ...)*)(i8* %1)
%5 = icmp eq i32 %4, %3
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = icmp ugt i32 %3, 2
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = add i32 %3, -1
%10 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @compartial to i32 (i8*, i8*, i32, ...)*)(i8* %0, i8* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8, %2
%13 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %14
14: ; preds = %6, %8, %12
%15 = phi i32 [ 0, %12 ], [ 1, %8 ], [ 1, %6 ]
ret i32 %15
}