#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 */
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
int flon_is_subdomain(const char *root, const char *dom) {
  size_t l = strlen(root);
  if (strncmp(root, dom, l) != 0)
    return 0;
  return dom[l] == '\0' || dom[l] == '.';
}


x86 assembly (clang, -O0):
<flon_is_subdomain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1164 <flon_is_subdomain+0x44>
movl   $0x0,-0x4(%rbp)
jmp    119e <flon_is_subdomain+0x7e>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1193 <flon_is_subdomain+0x73>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flon_is_subdomain>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    115e <flon_is_subdomain+0x3e>
mov    (%r14,%r15,1),%al
test   %al,%al
sete   %cl
cmp    $0x2e,%al
sete   %al
or     %cl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @flon_is_subdomain(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %1, i64 %3
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = icmp eq i8 %8, 46
%11 = or i1 %9, %10
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %2, %6
%14 = phi i32 [ %12, %6 ], [ 0, %2 ]
ret i32 %14
}