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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ readFile(char *, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int getPort(char *portstr, int size, char *ipfile) {
  char hostfile[17];
  memset(hostfile, 0, sizeof(hostfile));
  strcpy(hostfile, "../.");
  strcat(hostfile, ipfile);
  if (readFile(portstr, size, hostfile) < 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getPort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
lea    -0x40(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x40(%rbp),%rdx
call   1060 <readFile@plt>
cmp    $0x0,%rax
jge    11a6 <getPort+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <getPort+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
lea    0xe94(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
call   1060 <readFile@plt>
sar    $0x3f,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"../.\00"
define i32 @getPort(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [17 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 17)
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%14 = load i8*, i8** %7
%15 = call i32 @strcat(i8* %13, i8* %14)
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%19 = call i64 @readFile(i8* %16, i32 %17, i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 -1, i32* %4
br label %23
22: ; preds = %3
store i32 0, i32* %4
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"../.\00"
define i32 @getPort(i8* %0, i32 %1, i8* %2) {
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 17)
%7 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcat(i8* %5, i8* %2)
%9 = call i64 @readFile(i8* %0, i32 %1, i8* %5)
%10 = ashr i64 %9, 63
%11 = trunc i64 %10 to i32
ret i32 %11
}