#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__ dns_domain_equal(char const *, char const *);
unsigned int dns_domain_suffixpos(const char *big, const char *little) {
  unsigned char c = 0;
  const char *orig = big;
  for (;;) {
    if (dns_domain_equal(big, little))
      return big - orig;
    if (!(c = *big++))
      return 0;
    big += c;
  }
}


x86 assembly (clang, -O0):
<dns_domain_suffixpos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <dns_domain_equal@plt>
cmp    $0x0,%rax
je     1156 <dns_domain_suffixpos+0x46>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    1195 <dns_domain_suffixpos+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
cmp    $0x0,%al
jne    117e <dns_domain_suffixpos+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    1195 <dns_domain_suffixpos+0x85>
movzbl -0x19(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <dns_domain_suffixpos+0x1c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_domain_suffixpos>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <dns_domain_equal@plt>
mov    %r14,%rbx
test   %rax,%rax
jne    114f <dns_domain_suffixpos+0x3f>
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %rax,%rax
je     1154 <dns_domain_suffixpos+0x44>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <dns_domain_equal@plt>
test   %rax,%rax
je     1130 <dns_domain_suffixpos+0x20>
sub    %r14d,%ebx
jmp    1156 <dns_domain_suffixpos+0x46>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @dns_domain_suffixpos(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 0, i8* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %27, %2
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i64 @dns_domain_equal(i8* %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i8*, i8** %7
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %3
br label %33
21: ; preds = %9
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8, i8* %22
store i8 %24, i8* %6
%25 = icmp ne i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 0, i32* %3
br label %33
27: ; preds = %21
%28 = load i8, i8* %6
%29 = zext i8 %28 to i32
%30 = load i8*, i8** %4
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %4
br label %9
33: ; preds = %26, %14
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @dns_domain_suffixpos(i8* %0, i8* %1) {
%3 = tail call i64 @dns_domain_equal(i8* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %15, %2
%6 = phi i8* [ %0, %2 ], [ %18, %15 ]
%7 = ptrtoint i8* %6 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %7, %8
%10 = trunc i64 %9 to i32
br label %21
11: ; preds = %2, %15
%12 = phi i8* [ %18, %15 ], [ %0, %2 ]
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %12, i64 1
%17 = zext i8 %13 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = tail call i64 @dns_domain_equal(i8* %18, i8* %1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %11, label %5
21: ; preds = %11, %5
%22 = phi i32 [ %10, %5 ], [ 0, %11 ]
ret i32 %22
}