#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 ERANGE;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int errno;
int strtol(char *, int /*<<< orphan*/ *, int);
int cfg_parse_port(char *tok, int *port) {
  assert(tok != NULL);
  assert(port != NULL);
  errno = 0;
  *port = strtol(tok, NULL, 10);
  if (*port < 0 || errno == ERANGE) {
    do {
      errno =
          errno < 0 ? errno : (-1 * ((((8) * 10000 + (728))) * 1000 + (errno)));
    } while (0);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cfg_parse_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2e7d(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11a0 <cfg_parse_port+0x80>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%eax
jne    11f5 <cfg_parse_port+0xd5>
jmp    11a5 <cfg_parse_port+0x85>
mov    0x2e2c(%rip),%rax
cmpl   $0x0,(%rax)
jge    11c6 <cfg_parse_port+0xa6>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11dd <cfg_parse_port+0xbd>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
add    $0x4cfcfc0,%eax
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    0x2df1(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <cfg_parse_port+0xdc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_parse_port>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
mov    0x2e87(%rip),%r12
movl   $0x0,(%r12)
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,(%r15)
mov    (%r12),%ecx
test   %eax,%eax
js     1181 <cfg_parse_port+0x61>
mov    0x2e6b(%rip),%rax
cmp    (%rax),%ecx
jne    1197 <cfg_parse_port+0x77>
mov    $0xfb303040,%eax
sub    %ecx,%eax
test   %ecx,%ecx
cmovs  %ecx,%eax
mov    %eax,(%r12)
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i32 0
@ERANGE = global i32 0
define i32 @cfg_parse_port(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32*, i32** %5
%11 = icmp ne i32* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* @errno
%14 = load i8*, i8** %4
%15 = call i32 @strtol(i8* %14, i32* null, i32 10)
%16 = load i32*, i32** %5
store i32 %15, i32* %16
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = load i32, i32* @ERANGE
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %20, %2
br label %25
25: ; preds = %24
%26 = load i32, i32* @errno
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i32, i32* @errno
br label %34
30: ; preds = %25
%31 = load i32, i32* @errno
%32 = add nsw i32 80728000, %31
%33 = mul nsw i32 -1, %32
br label %34
34: ; preds = %30, %28
%35 = phi i32 [ %29, %28 ], [ %33, %30 ]
store i32 %35, i32* @errno
br label %36
36: ; preds = %34
store i32 -1, i32* %3
br label %38
37: ; preds = %20
store i32 0, i32* %3
br label %38
38: ; preds = %37, %36
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@errno = global i32 0
@ERANGE = global i32 0
define i32 @cfg_parse_port(i8* %0, i32* writeonly %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i32* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
store i32 0, i32* @errno
%9 = tail call i32 @strtol(i8* nocapture %0, i32* null, i32 10)
store i32 %9, i32* %1
%10 = icmp slt i32 %9, 0
%11 = load i32, i32* @errno
%12 = load i32, i32* @ERANGE
%13 = icmp eq i32 %11, %12
%14 = select i1 %10, i1 true, i1 %13
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = icmp slt i32 %11, 0
%17 = sub i32 -80728000, %11
%18 = select i1 %16, i32 %11, i32 %17
store i32 %18, i32* @errno
br label %19
19: ; preds = %2, %15
%20 = phi i32 [ -1, %15 ], [ 0, %2 ]
ret i32 %20
}