#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 */
typedef int /*<<< orphan*/ hostname;

/* Variables and functions */
scalar_t__ gethostname(char *, int);
int /*<<< orphan*/ search_postfix_add(char *);
int /*<<< orphan*/ search_postfix_clear();
char *strchr(char *, char);
void search_set_from_hostname(void) {
  char hostname[255 + 1], *domainname;
  search_postfix_clear();
  if (gethostname(hostname, sizeof(hostname)))
    return;
  domainname = strchr(hostname, '.');
  if (!domainname)
    return;
  search_postfix_add(domainname);
}


x86 assembly (clang, -O0):
<search_set_from_hostname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    $0x0,%al
call   1040 <search_postfix_clear@plt>
lea    -0x100(%rbp),%rdi
mov    $0x100,%esi
call   1060 <gethostname@plt>
cmp    $0x0,%rax
je     1172 <search_set_from_hostname+0x32>
jmp    11a9 <search_set_from_hostname+0x69>
lea    -0x100(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x108(%rbp)
jne    119d <search_set_from_hostname+0x5d>
jmp    11a9 <search_set_from_hostname+0x69>
mov    -0x108(%rbp),%rdi
call   1050 <search_postfix_add@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_set_from_hostname>:
sub    $0x108,%rsp
xor    %eax,%eax
call   1040 <search_postfix_clear@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
call   1060 <gethostname@plt>
test   %rax,%rax
je     1168 <search_set_from_hostname+0x28>
add    $0x108,%rsp
ret
mov    %rsp,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1160 <search_set_from_hostname+0x20>
mov    %rax,%rdi
call   1050 <search_postfix_add@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
define void @search_set_from_hostname() {
%1 = alloca [256 x i8]
%2 = alloca i8*
%3 = call i32 (...) @search_postfix_clear()
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = call i64 @gethostname(i8* %4, i32 256)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
br label %17
8: ; preds = %0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%10 = call i8* @strchr(i8* %9, i8 signext 46)
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %8
br label %17
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = call i32 @search_postfix_add(i8* %15)
br label %17
17: ; preds = %14, %13, %7
ret void
}

LLVM IR (-O2):
define void @search_set_from_hostname() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @search_postfix_clear()
%4 = call i64 @gethostname(i8* %2, i32 256)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = call i8* @strchr(i8* %2, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @search_postfix_add(i8* %7)
br label %11
11: ; preds = %6, %0, %9
ret void
}