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

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
char *strchr(char *, char);
char *strdup(char const *);
int serverPort(const char *arg, char **server, uint16_t *port) {
  char *p;
  char *cp;
  char *srv;
  p = strdup(arg);
  srv = p;
  cp = strchr(srv, '@');
  if (cp == NULL)
    return -1;
  *cp = 0;
  ++cp;
  *port = atoi(cp);
  *server = srv;
  return 0;
}


x86 assembly (clang, -O0):
<serverPort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x40,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1182 <serverPort+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <serverPort+0x88>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serverPort>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1050 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x40,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116e <serverPort+0x3e>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14)
mov    %rbx,(%r15)
xor    %eax,%eax
jmp    1173 <serverPort+0x43>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @serverPort(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%11 = load i8*, i8** %5
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
store i8* %13, i8** %10
%14 = load i8*, i8** %10
%15 = call i8* @strchr(i8* %14, i8 signext 64)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 -1, i32* %4
br label %28
19: ; preds = %3
%20 = load i8*, i8** %9
store i8 0, i8* %20
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = call i32 @atoi(i8* %23)
%25 = load i32*, i32** %7
store i32 %24, i32* %25
%26 = load i8*, i8** %10
%27 = load i8**, i8*** %6
store i8* %26, i8** %27
store i32 0, i32* %4
br label %28
28: ; preds = %19, %18
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @serverPort(i8* nocapture %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 64)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %3
store i8 0, i8* %5
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = tail call i32 @atoi(i8* %8)
store i32 %9, i32* %2
store i8* %4, i8** %1
br label %10
10: ; preds = %3, %7
%11 = phi i32 [ 0, %7 ], [ -1, %3 ]
ret i32 %11
}