#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 */
int /*<<< orphan*/ assert(char const *);
int /*<<< orphan*/ strcasecmp(char const *, char *);
int /*<<< orphan*/ strcmp(char const *, char *);
int host_is_localhost(const char *host) {
  assert(host);
  if (!strcasecmp(host, "localhost") || !strcmp(host, "127.0.0.1") ||
      !strcasecmp(host, "ipv6-localhost") || !strcmp(host, "::1") ||
      !strcasecmp(host, "ip6-localhost") || !strcmp(host, "0:0:0:0:0:0:0:1"))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<host_is_localhost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11db <host_is_localhost+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11db <host_is_localhost+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11db <host_is_localhost+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11db <host_is_localhost+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11db <host_is_localhost+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e7 <host_is_localhost+0xb7>
movl   $0x1,-0x4(%rbp)
jmp    11ee <host_is_localhost+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<host_is_localhost>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <assert@plt>
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11b6 <host_is_localhost+0x86>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b6 <host_is_localhost+0x86>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b6 <host_is_localhost+0x86>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b6 <host_is_localhost+0x86>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b6 <host_is_localhost+0x86>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [15 x i8] c"ipv6-localhost\00"
@.str.3 = [4 x i8] c"::1\00"
@.str.4 = [14 x i8] c"ip6-localhost\00"
@.str.5 = [16 x i8] c"0:0:0:0:0:0:0:1\00"
define i32 @host_is_localhost(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %3
%7 = call i32 @strcasecmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 @strcasecmp(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = call i32 @strcasecmp(i8* %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25, %21, %17, %13, %9, %1
store i32 1, i32* %2
br label %31
30: ; preds = %25
store i32 0, i32* %2
br label %31
31: ; preds = %30, %29
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [15 x i8] c"ipv6-localhost\00"
@.str.3 = [4 x i8] c"::1\00"
@.str.4 = [14 x i8] c"ip6-localhost\00"
@.str.5 = [16 x i8] c"0:0:0:0:0:0:0:1\00"
define i32 @host_is_localhost(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %17, %1, %5, %8, %11, %14
%22 = phi i32 [ 1, %14 ], [ 1, %11 ], [ 1, %8 ], [ 1, %5 ], [ 1, %1 ], [ %20, %17 ]
ret i32 %22
}