int config_match_domain(const char *name, const char *pattern) {
  const char *start;
  if (strlen(name) < strlen(pattern)) {
    return 0;
  }
  if (pattern[0] != '.') {
    return 0;
  }
  start = name + strlen(name) - strlen(pattern);
  return !strcasecmp(start, pattern);
}


x86 assembly (clang, -O0):
<config_match_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    1162 <config_match_domain+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <config_match_domain+0xb6>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     117e <config_match_domain+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <config_match_domain+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_match_domain>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
jb     1165 <config_match_domain+0x45>
cmpb   $0x2e,(%r14)
jne    1165 <config_match_domain+0x45>
add    %r15,%rbx
sub    %rcx,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

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

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