#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
bool parsePort(char *port_given, int *port) {
  bool exit_due_to_arg_error = false;
  (*port) = atoi(port_given);
  if (*port <= 0 || *port > 65535) {
    fprintf(stderr, "Port (%s) is incorrect and we could not continue !",
            port_given);
    exit_due_to_arg_error = true;
  }
  return exit_due_to_arg_error;
}


x86 assembly (clang, -O0):
<parsePort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1165 <parsePort+0x45>
mov    -0x10(%rbp),%rax
cmpl   $0xffff,(%rax)
jle    1185 <parsePort+0x65>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsePort>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    %eax,(%rbx)
add    $0xffff0000,%ecx
xor    %eax,%eax
cmp    $0xffff0000,%ecx
ja     1160 <parsePort+0x40>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"Port (%s) is incorrect and we could not continue !\00"
define i32 @parsePort(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i32 @atoi(i8* %6)
%8 = load i32*, i32** %4
store i32 %7, i32* %8
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = icmp sle i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, 65535
br i1 %15, label %16, label %20
16: ; preds = %12, %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %3
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %5
br label %20
20: ; preds = %16, %12
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"Port (%s) is incorrect and we could not continue !\00"
define i32 @parsePort(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @atoi(i8* %0)
store i32 %3, i32* %1
%4 = add i32 %3, -65536
%5 = icmp ult i32 %4, -65535
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ 1, %6 ], [ 0, %2 ]
ret i32 %10
}