#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*/ time_t;
struct link {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cctools_debug(long long, char *);
int /*<<< orphan*/ link_address_remote(struct link *, char *, int *);
int /*<<< orphan*/ link_putlstring(struct link *, char *, int,
                                   int /*<<< orphan*/);
char *strdup(char *);
int auth_address_accept(struct link *link, char **subject, time_t stoptime) {
  char addr[48];
  int port;
  if (!link_address_remote(link, addr, &port)) {
    cctools_debug((1LL << 12), "address: couldn't get address of link");
    goto reject;
  }
  *subject = strdup(addr);
  if (!*subject) {
    cctools_debug((1LL << 12), "address: out of memory");
    goto reject;
  }
  (link_putlstring(link,
                   "yes\n"
                   "",
                   ((sizeof("yes\n")) - 1), stoptime));
  return 1;
reject:
  (link_putlstring(link,
                   "no\n"
                   "",
                   ((sizeof("no\n")) - 1), stoptime));
  return 0;
}


x86 assembly (clang, -O0):
<auth_address_accept>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   1050 <link_address_remote@plt>
cmp    $0x0,%eax
jne    1183 <auth_address_accept+0x43>
mov    $0x1000,%edi
lea    0xe87(%rip),%rsi
call   1030 <cctools_debug@plt>
jmp    11de <auth_address_accept+0x9e>
lea    -0x50(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ba <auth_address_accept+0x7a>
mov    $0x1000,%edi
lea    0xe76(%rip),%rsi
call   1030 <cctools_debug@plt>
jmp    11de <auth_address_accept+0x9e>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
lea    0xe75(%rip),%rsi
mov    $0x4,%edx
call   1040 <link_putlstring@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <auth_address_accept+0xbd>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
lea    0xe56(%rip),%rsi
mov    $0x3,%edx
call   1040 <link_putlstring@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_address_accept>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <link_address_remote@plt>
test   %eax,%eax
je     1195 <auth_address_accept+0x55>
lea    0x10(%rsp),%rdi
call   1060 <strdup@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     119e <auth_address_accept+0x5e>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
mov    %r14d,%ecx
call   1040 <link_putlstring@plt>
mov    $0x1,%eax
jmp    11c8 <auth_address_accept+0x88>
lea    0xe64(%rip),%rsi
jmp    11a5 <auth_address_accept+0x65>
lea    0xe81(%rip),%rsi
mov    $0x1000,%edi
call   1030 <cctools_debug@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
mov    %r14d,%ecx
call   1040 <link_putlstring@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.link = type { i32 }
@.str = [38 x i8] c"address: couldn't get address of link\00"
@.str.1 = [23 x i8] c"address: out of memory\00"
@.str.2 = [5 x i8] c"yes\0A\00"
@.str.3 = [4 x i8] c"no\0A\00"
define i32 @auth_address_accept(%struct.link* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.link*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [48 x i8]
%9 = alloca i32
store %struct.link* %0, %struct.link** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%10 = load %struct.link*, %struct.link** %5
%11 = getelementptr inbounds [48 x i8], [48 x i8]* %8, i64 0, i64 0
%12 = call i32 @link_address_remote(%struct.link* %10, i8* %11, i32* %9)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %3
%15 = call i32 @cctools_debug(i64 4096, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %29
16: ; preds = %3
%17 = getelementptr inbounds [48 x i8], [48 x i8]* %8, i64 0, i64 0
%18 = call i8* @strdup(i8* %17)
%19 = load i8**, i8*** %6
store i8* %18, i8** %19
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %25, label %23
23: ; preds = %16
%24 = call i32 @cctools_debug(i64 4096, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %29
25: ; preds = %16
%26 = load %struct.link*, %struct.link** %5
%27 = load i32, i32* %7
%28 = call i32 @link_putlstring(%struct.link* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %27)
store i32 1, i32* %4
br label %33
29: ; preds = %23, %14
%30 = load %struct.link*, %struct.link** %5
%31 = load i32, i32* %7
%32 = call i32 @link_putlstring(%struct.link* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %31)
store i32 0, i32* %4
br label %33
33: ; preds = %29, %25
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
%struct.link = type { i32 }
@.str = [38 x i8] c"address: couldn't get address of link\00"
@.str.1 = [23 x i8] c"address: out of memory\00"
@.str.2 = [5 x i8] c"yes\0A\00"
@.str.3 = [4 x i8] c"no\0A\00"
define i32 @auth_address_accept(%struct.link* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = alloca [48 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = call i32 @link_address_remote(%struct.link* %0, i8* %6, i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = call i8* @strdup(i8* %6)
store i8* %11, i8** %1
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @link_putlstring(%struct.link* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %2)
br label %19
15: ; preds = %10, %3
%16 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %10 ]
%17 = call i32 @cctools_debug(i64 4096, i8* %16)
%18 = call i32 @link_putlstring(%struct.link* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %2)
br label %19
19: ; preds = %15, %13
%20 = phi i32 [ 1, %13 ], [ 0, %15 ]
ret i32 %20
}