#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 */
scalar_t__ errno;
int /*<<< orphan*/ fprint_err(char *, char *, ...);
int /*<<< orphan*/ print_err(char *);
char *strchr(char *, char);
int /*<<< orphan*/ strerror(scalar_t__);
int strtol(char *, char **, int);
extern int host_value(char *prefix, char *cmd, char *arg, char **hostname,
                      int *port) {
  char *p = strchr(arg, ':');
  *hostname = arg;
  if (p != NULL) {
    char *ptr;
    p[0] = '\0';
    errno = 0;
    *port = strtol(p + 1, &ptr, 10);
    if (errno) {
      p[0] = ':';
      print_err("### ");
      if (prefix != NULL)
        fprint_err("%s: ", prefix);
      if (cmd)
        fprint_err("Cannot read port number in %s %s (%s)\n", cmd, arg,
                   strerror(errno));
      else
        fprint_err("Cannot read port number in %s (%s)\n", arg,
                   strerror(errno));
      return 1;
    }
    if (ptr[0] != '\0') {
      p[0] = ':';
      print_err("### ");
      if (prefix != NULL)
        fprint_err("%s: ", prefix);
      if (cmd)
        fprint_err("Unexpected characters in port number in %s %s\n", cmd, arg);
      else
        fprint_err("Unexpected characters in port number in %s\n", arg);
      return 1;
    }
    if (*port < 0) {
      p[0] = ':';
      print_err("### ");
      if (prefix != NULL)
        fprint_err("%s: ", prefix);
      if (cmd)
        fprint_err("Negative port number in %s %s\n", cmd, arg);
      else
        fprint_err("Negative port number in %s\n", arg);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<host_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x38(%rbp)
je     1390 <host_value+0x240>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2e3e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x38(%rbp),%rdi
add    $0x1,%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e12(%rip),%rax
cmpq   $0x0,(%rax)
je     1286 <host_value+0x136>
mov    -0x38(%rbp),%rax
movb   $0x3a,(%rax)
lea    0xe1a(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     1208 <host_value+0xb8>
mov    -0x10(%rbp),%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
cmpq   $0x0,-0x18(%rbp)
je     124f <host_value+0xff>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    127a <host_value+0x12a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    1397 <host_value+0x247>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     130a <host_value+0x1ba>
mov    -0x38(%rbp),%rax
movb   $0x3a,(%rax)
lea    0xd5c(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     12c6 <host_value+0x176>
mov    -0x10(%rbp),%rsi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
cmpq   $0x0,-0x18(%rbp)
je     12ec <host_value+0x19c>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    12fe <host_value+0x1ae>
mov    -0x20(%rbp),%rsi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    1397 <host_value+0x247>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jge    138b <host_value+0x23b>
mov    -0x38(%rbp),%rax
movb   $0x3a,(%rax)
lea    0xcdb(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     1347 <host_value+0x1f7>
mov    -0x10(%rbp),%rsi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
cmpq   $0x0,-0x18(%rbp)
je     136d <host_value+0x21d>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    137f <host_value+0x22f>
mov    -0x20(%rbp),%rsi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    1397 <host_value+0x247>
jmp    1390 <host_value+0x240>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<host_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r13
mov    %rcx,%rbp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %r12,0x0(%rbp)
xor    %ebp,%ebp
test   %rax,%rax
je     12c4 <host_value+0x174>
mov    %rax,%rbx
mov    %r14,0x8(%rsp)
movb   $0x0,(%rax)
mov    0x2e45(%rip),%r14
movq   $0x0,(%r14)
mov    %rax,%rdi
add    $0x1,%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,0x0(%r13)
cmpq   $0x0,(%r14)
je     1211 <host_value+0xc1>
movb   $0x3a,(%rbx)
lea    0xe34(%rip),%rdi
call   1040 <print_err@plt>
test   %r15,%r15
je     11e7 <host_value+0x97>
lea    0xe28(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    (%r14),%rdi
call   1070 <strerror@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     125d <host_value+0x10d>
lea    0xe0a(%rip),%rdi
mov    %r12,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    12bf <host_value+0x16f>
mov    0x10(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1272 <host_value+0x122>
movb   $0x3a,(%rbx)
lea    0xddb(%rip),%rdi
call   1040 <print_err@plt>
test   %r15,%r15
je     1240 <host_value+0xf0>
lea    0xdcf(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     12ae <host_value+0x15e>
lea    0xe04(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    12bf <host_value+0x16f>
lea    0xdcd(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    12bf <host_value+0x16f>
test   %eax,%eax
jns    12c4 <host_value+0x174>
movb   $0x3a,(%rbx)
lea    0xd80(%rip),%rdi
call   1040 <print_err@plt>
test   %r15,%r15
je     129b <host_value+0x14b>
lea    0xd74(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     12d5 <host_value+0x185>
lea    0xe04(%rip),%rdi
jmp    1251 <host_value+0x101>
lea    0xdcf(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf3(%rip),%rdi
jmp    12b5 <host_value+0x165>

LLVM IR (-O0):
@errno = global i64 0
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [39 x i8] c"Cannot read port number in %s %s (%s)\0A\00"
@.str.3 = [36 x i8] c"Cannot read port number in %s (%s)\0A\00"
@.str.4 = [47 x i8] c"Unexpected characters in port number in %s %s\0A\00"
@.str.5 = [44 x i8] c"Unexpected characters in port number in %s\0A\00"
@.str.6 = [31 x i8] c"Negative port number in %s %s\0A\00"
@.str.7 = [28 x i8] c"Negative port number in %s\0A\00"
define i32 @host_value(i8* %0, i8* %1, i8* %2, i8** %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8** %3, i8*** %10
store i32* %4, i32** %11
%14 = load i8*, i8** %9
%15 = call i8* @strchr(i8* %14, i8 signext 58)
store i8* %15, i8** %12
%16 = load i8*, i8** %9
%17 = load i8**, i8*** %10
store i8* %16, i8** %17
%18 = load i8*, i8** %12
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %104
20: ; preds = %5
%21 = load i8*, i8** %12
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 0, i8* %22
store i64 0, i64* @errno
%23 = load i8*, i8** %12
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 @strtol(i8* %24, i8** %13, i32 10)
%26 = load i32*, i32** %11
store i32 %25, i32* %26
%27 = load i64, i64* @errno
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %53
29: ; preds = %20
%30 = load i8*, i8** %12
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 58, i8* %31
%32 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%33 = load i8*, i8** %7
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i8*, i8** %7
%37 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %29
%39 = load i8*, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load i8*, i8** %8
%43 = load i8*, i8** %9
%44 = load i64, i64* @errno
%45 = call i32 @strerror(i64 %44)
%46 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %43, i32 %45)
br label %52
47: ; preds = %38
%48 = load i8*, i8** %9
%49 = load i64, i64* @errno
%50 = call i32 @strerror(i64 %49)
%51 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %48, i32 %50)
br label %52
52: ; preds = %47, %41
store i32 1, i32* %6
br label %105
53: ; preds = %20
%54 = load i8*, i8** %13
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %79
59: ; preds = %53
%60 = load i8*, i8** %12
%61 = getelementptr inbounds i8, i8* %60, i64 0
store i8 58, i8* %61
%62 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%63 = load i8*, i8** %7
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %68
65: ; preds = %59
%66 = load i8*, i8** %7
%67 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %65, %59
%69 = load i8*, i8** %8
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %75
71: ; preds = %68
%72 = load i8*, i8** %8
%73 = load i8*, i8** %9
%74 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %72, i8* %73)
br label %78
75: ; preds = %68
%76 = load i8*, i8** %9
%77 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %75, %71
store i32 1, i32* %6
br label %105
79: ; preds = %53
%80 = load i32*, i32** %11
%81 = load i32, i32* %80
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %103
83: ; preds = %79
%84 = load i8*, i8** %12
%85 = getelementptr inbounds i8, i8* %84, i64 0
store i8 58, i8* %85
%86 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%87 = load i8*, i8** %7
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %92
89: ; preds = %83
%90 = load i8*, i8** %7
%91 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %89, %83
%93 = load i8*, i8** %8
%94 = icmp ne i8* %93, null
br i1 %94, label %95, label %99
95: ; preds = %92
%96 = load i8*, i8** %8
%97 = load i8*, i8** %9
%98 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %96, i8* %97)
br label %102
99: ; preds = %92
%100 = load i8*, i8** %9
%101 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %99, %95
store i32 1, i32* %6
br label %105
103: ; preds = %79
br label %104
104: ; preds = %103, %5
store i32 0, i32* %6
br label %105
105: ; preds = %104, %102, %78, %52
%106 = load i32, i32* %6
ret i32 %106
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [39 x i8] c"Cannot read port number in %s %s (%s)\0A\00"
@.str.3 = [36 x i8] c"Cannot read port number in %s (%s)\0A\00"
@.str.4 = [47 x i8] c"Unexpected characters in port number in %s %s\0A\00"
@.str.5 = [44 x i8] c"Unexpected characters in port number in %s\0A\00"
@.str.6 = [31 x i8] c"Negative port number in %s %s\0A\00"
@.str.7 = [28 x i8] c"Negative port number in %s\0A\00"
define i32 @host_value(i8* %0, i8* %1, i8* %2, i8** nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca i8*
%7 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 58)
store i8* %2, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %57, label %9
9: ; preds = %5
%10 = bitcast i8** %6 to i8*
store i8 0, i8* %7
store i64 0, i64* @errno
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = call i32 @strtol(i8* %11, i8** %6, i32 10)
store i32 %12, i32* %4
%13 = load i64, i64* @errno
%14 = icmp eq i64 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %9
store i8 58, i8* %7
%16 = tail call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %0, null
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %20
20: ; preds = %18, %15
%21 = icmp eq i8* %1, null
%22 = load i64, i64* @errno
%23 = tail call i32 @strerror(i64 %22)
br i1 %21, label %26, label %24
24: ; preds = %20
%25 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2, i32 %23)
br label %57
26: ; preds = %20
%27 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %23)
br label %57
28: ; preds = %9
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %43, label %32
32: ; preds = %28
store i8 58, i8* %7
%33 = tail call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i8* %0, null
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %37
37: ; preds = %35, %32
%38 = icmp eq i8* %1, null
br i1 %38, label %41, label %39
39: ; preds = %37
%40 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2)
br label %57
41: ; preds = %37
%42 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %2)
br label %57
43: ; preds = %28
%44 = icmp slt i32 %12, 0
br i1 %44, label %45, label %56
45: ; preds = %43
store i8 58, i8* %7
%46 = tail call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%47 = icmp eq i8* %0, null
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %50
50: ; preds = %48, %45
%51 = icmp eq i8* %1, null
br i1 %51, label %54, label %52
52: ; preds = %50
%53 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8* %2)
br label %57
54: ; preds = %50
%55 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %2)
br label %57
56: ; preds = %43
br label %57
57: ; preds = %5, %56, %52, %54, %39, %41, %24, %26
%58 = phi i32 [ 1, %26 ], [ 1, %24 ], [ 1, %41 ], [ 1, %39 ], [ 1, %54 ], [ 1, %52 ], [ 0, %56 ], [ 0, %5 ]
ret i32 %58
}