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


x86 assembly (clang, -O0):
<Open_clientfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <open_clientfd@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1183 <Open_clientfd+0x53>
cmpl   $0xffffffff,-0x10(%rbp)
jne    1172 <Open_clientfd+0x42>
lea    0xe98(%rip),%rdi
call   1030 <unix_error@plt>
jmp    117e <Open_clientfd+0x4e>
lea    0xea0(%rip),%rdi
call   1050 <dns_error@plt>
jmp    1183 <Open_clientfd+0x53>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [25 x i8] c"Open_clientfd Unix error\00"
@.str.1 = [24 x i8] c"Open_clientfd DNS error\00"
define i32 @Open_clientfd(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i32 @open_clientfd(i8* %6, i32 %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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = call i32 @dns_error(i8* getelementptr inbounds ([24 x i8], [24 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 = [25 x i8] c"Open_clientfd Unix error\00"
@.str.1 = [24 x i8] c"Open_clientfd DNS error\00"
define i32 @Open_clientfd(i8* %0, i32 %1) {
%3 = tail call i32 @open_clientfd(i8* %0, i32 %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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %5
%10 = tail call i32 @dns_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %7, %9, %2
ret i32 %3
}