#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 */
struct hostent {
  int /*<<< orphan*/ h_name;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ logquit(int, char *, char *);
char *myhost();
scalar_t__ strcasecmp(char *, int /*<<< orphan*/);
int thishost(char *host) {
  struct hostent *h;
  char *name;
  if ((name = myhost()) == NULL)
    logquit(1, "Can't find my host entry '%s'", myhost());
  h = gethostbyname(host);
  if (h == NULL)
    return (0);
  return (strcasecmp(name, h->h_name) == 0);
}


x86 assembly (clang, -O0):
<thishost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <myhost@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117c <thishost+0x3c>
mov    $0x0,%al
call   1060 <myhost@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xe89(%rip),%rsi
call   1050 <logquit@plt>
mov    -0x10(%rbp),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <thishost+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11be <thishost+0x7e>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thishost>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <myhost@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1174 <thishost+0x34>
xor    %eax,%eax
call   1060 <myhost@plt>
lea    0xe99(%rip),%rsi
mov    $0x1,%edi
mov    %rax,%rdx
call   1050 <logquit@plt>
mov    %r15,%rdi
call   1040 <gethostbyname@plt>
test   %rax,%rax
je     1193 <thishost+0x53>
mov    (%rax),%esi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
@.str = [30 x i8] c"Can't find my host entry '%s'\00"
define i32 @thishost(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.hostent*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = call i8* (...) @myhost()
store i8* %6, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i8* (...) @myhost()
%10 = call i32 @logquit(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %3
%13 = call %struct.hostent* @gethostbyname(i8* %12)
store %struct.hostent* %13, %struct.hostent** %4
%14 = load %struct.hostent*, %struct.hostent** %4
%15 = icmp eq %struct.hostent* %14, null
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 0, i32* %2
br label %25
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = load %struct.hostent*, %struct.hostent** %4
%20 = getelementptr inbounds %struct.hostent, %struct.hostent* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i64 @strcasecmp(i8* %18, i32 %21)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %2
br label %25
25: ; preds = %17, %16
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
@.str = [30 x i8] c"Can't find my host entry '%s'\00"
define i32 @thishost(i8* %0) {
%2 = tail call i8* (...) @myhost()
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* (...) @myhost()
%6 = tail call i32 @logquit(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %1
%8 = tail call %struct.hostent* @gethostbyname(i8* %0)
%9 = icmp eq %struct.hostent* %8, null
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.hostent, %struct.hostent* %8, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i64 @strcasecmp(i8* %2, i32 %12)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %7, %10
%17 = phi i32 [ %15, %10 ], [ 0, %7 ]
ret i32 %17
}