#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 */
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int sa_family;
};
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
scalar_t__ INET_rresolve(char *, int, struct sockaddr_in *, int, int);
char *safe_strncpy(char *, char *, int);
char *INET_sprint(struct sockaddr *sap, int numeric) {
  static char buff[128];
  if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
    return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
  if (INET_rresolve(buff, sizeof(buff), (struct sockaddr_in *)sap, numeric,
                    0xffffff00) != 0)
    return (NULL);
  return (buff);
}


x86 assembly (clang, -O0):
<INET_sprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0xffff,(%rax)
je     114c <INET_sprint+0x2c>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    116d <INET_sprint+0x4d>
lea    0x2eed(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x80,%edx
call   1030 <safe_strncpy@plt>
mov    %rax,-0x8(%rbp)
jmp    11ad <INET_sprint+0x8d>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0x2ec5(%rip),%rdi
mov    $0x80,%esi
mov    $0xffffff00,%r8d
call   1040 <INET_rresolve@plt>
cmp    $0x0,%rax
je     11a2 <INET_sprint+0x82>
movq   $0x0,-0x8(%rbp)
jmp    11ad <INET_sprint+0x8d>
lea    0x2e97(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<INET_sprint>:
push   %rbx
mov    (%rdi),%eax
cmp    $0xffff,%eax
je     112e <INET_sprint+0xe>
test   %eax,%eax
jne    1147 <INET_sprint+0x27>
lea    0x2f0b(%rip),%rdi
lea    0xec4(%rip),%rsi
mov    $0x80,%edx
pop    %rbx
jmp    1030 <safe_strncpy@plt>
mov    %esi,%ecx
mov    %rdi,%rdx
lea    0x2eed(%rip),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0xffffff00,%r8d
call   1040 <INET_rresolve@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmove  %rbx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i32 }
@INET_sprint.buff = internal global [128 x i8] zeroinitializer
@.str = [11 x i8] c"[NONE SET]\00"
define i8* @INET_sprint(%struct.sockaddr* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr*
%5 = alloca i32
store %struct.sockaddr* %0, %struct.sockaddr** %4
store i32 %1, i32* %5
%6 = load %struct.sockaddr*, %struct.sockaddr** %4
%7 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 65535
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load %struct.sockaddr*, %struct.sockaddr** %4
%12 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10, %2
%16 = call i8* @safe_strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 128)
store i8* %16, i8** %3
br label %25
17: ; preds = %10
%18 = load %struct.sockaddr*, %struct.sockaddr** %4
%19 = bitcast %struct.sockaddr* %18 to %struct.sockaddr_in*
%20 = load i32, i32* %5
%21 = call i64 @INET_rresolve(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i32 128, %struct.sockaddr_in* %19, i32 %20, i32 -256)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i8* null, i8** %3
br label %25
24: ; preds = %17
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i8** %3
br label %25
25: ; preds = %24, %23, %15
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i32 }
@INET_sprint.buff = internal global [128 x i8] zeroinitializer
@.str = [11 x i8] c"[NONE SET]\00"
define i8* @INET_sprint(%struct.sockaddr* %0, i32 %1) {
%3 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%4 = load i32, i32* %3
switch i32 %4, label %7 [
i32 65535, label %5
i32 0, label %5
]
5: ; preds = %2, %2
%6 = tail call i8* @safe_strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 128)
br label %12
7: ; preds = %2
%8 = bitcast %struct.sockaddr* %0 to %struct.sockaddr_in*
%9 = tail call i64 @INET_rresolve(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i32 128, %struct.sockaddr_in* %8, i32 %1, i32 -256)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @INET_sprint.buff, i64 0, i64 0), i8* null
br label %12
12: ; preds = %7, %5
%13 = phi i8* [ %6, %5 ], [ %11, %7 ]
ret i8* %13
}