#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*/ address;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
char *strchr(char const *, char);
const char *irc_protocol_get_address_from_host(const char *host) {
  static char address[256];
  char *pos;
  address[0] = '\0';
  if (host) {
    if (host[0] == ':')
      host++;
    pos = strchr(host, '!');
    if (pos)
      snprintf(address, sizeof(address), "%s", pos + 1);
    else
      snprintf(address, sizeof(address), "%s", host);
  }
  return address;
}


x86 assembly (clang, -O0):
<irc_protocol_get_address_from_host>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,0x2f0d(%rip)
cmpq   $0x0,-0x8(%rbp)
je     11bd <irc_protocol_get_address_from_host+0x9d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    115a <irc_protocol_get_address_from_host+0x3a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x21,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119c <irc_protocol_get_address_from_host+0x7c>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
lea    0x2eba(%rip),%rdi
mov    $0x100,%esi
lea    0xe6e(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11b8 <irc_protocol_get_address_from_host+0x98>
mov    -0x8(%rbp),%rcx
lea    0x2e99(%rip),%rdi
mov    $0x100,%esi
lea    0xe4d(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11bd <irc_protocol_get_address_from_host+0x9d>
lea    0x2e7c(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_protocol_get_address_from_host>:
push   %rbx
movb   $0x0,0x2f18(%rip)
test   %rdi,%rdi
je     1168 <irc_protocol_get_address_from_host+0x48>
xor    %ebx,%ebx
cmpb   $0x3a,(%rdi)
sete   %bl
add    %rdi,%rbx
mov    %rbx,%rdi
mov    $0x21,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
lea    0x2ee9(%rip),%rdi
lea    0xea2(%rip),%rdx
mov    $0x100,%esi
call   1040 <snprintf@plt>
lea    0x2ed1(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@irc_protocol_get_address_from_host.address = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define i8* @irc_protocol_get_address_from_host(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0)
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 58
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %2
br label %15
15: ; preds = %12, %6
%16 = load i8*, i8** %2
%17 = call i8* @strchr(i8* %16, i8 signext 33)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %27
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %1
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0)
}

LLVM IR (-O2):
@irc_protocol_get_address_from_host.address = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define i8* @irc_protocol_get_address_from_host(i8* %0) {
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0)
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 58
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %0, i64 %6
%8 = tail call i8* @strchr(i8* %7, i8 signext 33)
%9 = icmp eq i8* %8, null
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = select i1 %9, i8* %7, i8* %10
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %3, %1
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @irc_protocol_get_address_from_host.address, i64 0, i64 0)
}