#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 add_serverentry(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int add_serverentry_str(char *serverstr) {
  char *colon;
  int port;
  if ((colon = strchr(serverstr, ':')) == NULL) {
    fprintf(stderr, "invalid server format specified\n");
    return -1;
  }
  *colon = 0;
  sscanf((colon + 1), "%d", &port);
  return add_serverentry(serverstr, port);
}


x86 assembly (clang, -O0):
<add_serverentry_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1189 <add_serverentry_str+0x49>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <add_serverentry_str+0x77>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe82(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <add_serverentry@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_serverentry_str>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1180 <add_serverentry_str+0x40>
movb   $0x0,(%rax)
add    $0x1,%rax
lea    0xebc(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1050 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <add_serverentry@plt>
jmp    119a <add_serverentry_str+0x5a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"invalid server format specified\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @add_serverentry_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strchr(i8* %6, i8 signext 58)
store i8* %7, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %20
12: ; preds = %1
%13 = load i8*, i8** %4
store i8 0, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = call i32 @add_serverentry(i8* %17, i32 %18)
store i32 %19, i32* %2
br label %20
20: ; preds = %12, %9
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"invalid server format specified\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @add_serverentry_str(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %14
9: ; preds = %1
store i8 0, i8* %4
%10 = getelementptr inbounds i8, i8* %4, i64 1
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = call i32 @add_serverentry(i8* %0, i32 %12)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ -1, %6 ], [ %13, %9 ]
ret i32 %15
}