#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 /*<<< orphan*/ dns_error(char *);
int open_clientfd_r(char *, char *);
int /*<<< orphan*/ unix_error(char *);
int Open_clientfd_r(char *hostname, char *port) {
  int rc;
  if ((rc = open_clientfd_r(hostname, port)) < 0) {
    if (rc == -1)
      unix_error("Open_clientfd_r Unix error");
    else
      dns_error("Open_clientfd_r DNS error");
  }
  return rc;
}


x86 assembly (clang, -O0):
<Open_clientfd_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <open_clientfd_r@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1185 <Open_clientfd_r+0x55>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1174 <Open_clientfd_r+0x44>
lea    0xe96(%rip),%rdi
call   1040 <unix_error@plt>
jmp    1180 <Open_clientfd_r+0x50>
lea    0xea0(%rip),%rdi
call   1050 <dns_error@plt>
jmp    1185 <Open_clientfd_r+0x55>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Open_clientfd_r>:
push   %rbx
call   1030 <open_clientfd_r@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    115b <Open_clientfd_r+0x2b>
cmp    $0xffffffff,%ebx
je     114f <Open_clientfd_r+0x1f>
lea    0xed3(%rip),%rdi
call   1050 <dns_error@plt>
jmp    115b <Open_clientfd_r+0x2b>
lea    0xeaa(%rip),%rdi
call   1040 <unix_error@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Open_clientfd_r Unix error\00"
@.str.1 = [26 x i8] c"Open_clientfd_r DNS error\00"
define i32 @Open_clientfd_r(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 @open_clientfd_r(i8* %6, i8* %7)
store i32 %8, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @unix_error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = call i32 @dns_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
br label %18
18: ; preds = %17, %2
%19 = load i32, i32* %5
ret i32 %19
}

LLVM IR (-O2):
@.str = [27 x i8] c"Open_clientfd_r Unix error\00"
@.str.1 = [26 x i8] c"Open_clientfd_r DNS error\00"
define i32 @Open_clientfd_r(i8* %0, i8* %1) {
%3 = tail call i32 @open_clientfd_r(i8* %0, i8* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = icmp eq i32 %3, -1
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @unix_error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %5
%10 = tail call i32 @dns_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %7, %9, %2
ret i32 %3
}