#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*/ check_sockdir(char const *);
int cli_conn(char *);
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ free(char *);
char *path_join(char const *, char *);
int hookup(const char *sockdir) {
  char *master_addr;
  int master_fd;
  check_sockdir(sockdir);
  master_addr = path_join(sockdir, "issue");
  master_fd = cli_conn(master_addr);
  if (master_fd < 0)
    errx(2, "Cannot connect to mdm-master");
  free(master_addr);
  return master_fd;
}


x86 assembly (clang, -O0):
<hookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <check_sockdir@plt>
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <path_join@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <cli_conn@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11a0 <hookup+0x50>
mov    $0x2,%edi
lea    0xe6b(%rip),%rsi
call   1040 <errx@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hookup>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <check_sockdir@plt>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <path_join@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <cli_conn@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    118c <hookup+0x3c>
lea    0xe84(%rip),%rsi
mov    $0x2,%edi
call   1040 <errx@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"issue\00"
@.str.1 = [29 x i8] c"Cannot connect to mdm-master\00"
define i32 @hookup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @check_sockdir(i8* %5)
%7 = load i8*, i8** %2
%8 = call i8* @path_join(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @cli_conn(i8* %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @errx(i32 2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
%18 = load i32, i32* %4
ret i32 %18
}

LLVM IR (-O2):
@.str = [6 x i8] c"issue\00"
@.str.1 = [29 x i8] c"Cannot connect to mdm-master\00"
define i32 @hookup(i8* %0) {
%2 = tail call i32 @check_sockdir(i8* %0)
%3 = tail call i8* @path_join(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @cli_conn(i8* %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = tail call i32 @free(i8* %3)
ret i32 %4
}