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


x86 assembly (clang, -O0):
<dns_domain_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <dns_domain_equal@plt>
cmp    $0x0,%rax
je     1144 <dns_domain_suffix+0x34>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <dns_domain_suffix+0x76>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
cmpb   $0x0,-0x19(%rbp)
jne    116f <dns_domain_suffix+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    1186 <dns_domain_suffix+0x76>
movzbl -0x19(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <dns_domain_suffix+0x10>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_domain_suffix>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
call   1030 <dns_domain_equal@plt>
test   %rax,%rax
jne    1143 <dns_domain_suffix+0x33>
movzbl (%rbx),%eax
test   %rax,%rax
je     1141 <dns_domain_suffix+0x31>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
jmp    1120 <dns_domain_suffix+0x10>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @dns_domain_suffix(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 %5, label %15
5: ; preds = %2, %9
%6 = phi i8* [ %12, %9 ], [ %0, %2 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = zext i8 %7 to i64
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = tail call i64 @dns_domain_equal(i8* %12, i8* %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %9, %5, %2
%16 = phi i8* [ %0, %2 ], [ null, %5 ], [ %12, %9 ]
ret i8* %16
}