#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int PM_Accsee_IP(char *interface, char *ipaddr) {
  int fd;
  int in_len = 0;
  struct sockaddr_in servaddr;
  in_len = sizeof(struct sockaddr_in);
  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    return -1;
  }
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons(8080);
  servaddr.sin_addr.s_addr = inet_addr(ipaddr);
  memset(servaddr.sin_zero, 0, sizeof(servaddr.sin_zero));
  if (connect(fd, (struct sockaddr *)&servaddr, in_len) < 0) {
    do {
      printf("%s, ", "info");
      printf("IP:%s don't Access \n", ipaddr);
      printf("\n");
    } while (0);
    close(fd);
    return -1;
  } else {
    do {
      printf("%s, ", "info");
      printf("IP:%s is Accsee\n", ipaddr);
      printf("\n");
    } while (0);
    close(fd);
    return 0;
  }
}


x86 assembly (clang, -O0):
<PM_Accsee_IP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x10,-0x20(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11db <PM_Accsee_IP+0x5b>
lea    0xe36(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12bf <PM_Accsee_IP+0x13f>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    $0x1f90,%edi
call   1030 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1090 <connect@plt>
cmp    $0x0,%rax
jge    1276 <PM_Accsee_IP+0xf6>
jmp    122d <PM_Accsee_IP+0xad>
lea    0xdd3(%rip),%rdi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12bf <PM_Accsee_IP+0x13f>
jmp    127b <PM_Accsee_IP+0xfb>
lea    0xd85(%rip),%rdi
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PM_Accsee_IP>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    0x2e44(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     1279 <PM_Accsee_IP+0xe9>
mov    %eax,%ebx
mov    0x0(%rbp),%eax
mov    %eax,0x14(%rsp)
mov    $0x1f90,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r14,%rdi
call   1080 <inet_addr@plt>
mov    %eax,0xc(%rsp)
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10a0 <connect@plt>
mov    %rax,%rbp
lea    0xdfb(%rip),%rdi
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbp,%rbp
js     1243 <PM_Accsee_IP+0xb3>
lea    0xe00(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    126b <PM_Accsee_IP+0xdb>
lea    0xdc7(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd80(%rip),%rdi
call   1090 <perror@plt>
jmp    1265 <PM_Accsee_IP+0xd5>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"%s, \00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [21 x i8] c"IP:%s don't Access \0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [17 x i8] c"IP:%s is Accsee\0A\00"
define i32 @PM_Accsee_IP(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %7
store i32 16, i32* %7
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %6
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
15: ; preds = %2
%16 = load i32, i32* @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 3
store i32 %16, i32* %17
%18 = call i32 @htons(i32 8080)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %18, i32* %19
%20 = load i8*, i8** %5
%21 = call i32 @inet_addr(i8* %20)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
store i32 %21, i32* %23
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @memset(i32 %25, i32 0, i32 4)
%27 = load i32, i32* %6
%28 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%29 = load i32, i32* %7
%30 = call i64 @connect(i32 %27, %struct.sockaddr* %28, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %15
br label %33
33: ; preds = %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %33
%39 = load i32, i32* %6
%40 = call i32 @close(i32 %39)
store i32 -1, i32* %3
br label %50
41: ; preds = %15
br label %42
42: ; preds = %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%44 = load i8*, i8** %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %42
%48 = load i32, i32* %6
%49 = call i32 @close(i32 %48)
store i32 0, i32* %3
br label %50
50: ; preds = %47, %38, %13
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"%s, \00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [21 x i8] c"IP:%s don't Access \0A\00"
@.str.5 = [17 x i8] c"IP:%s is Accsee\0A\00"
define i32 @PM_Accsee_IP(i8* nocapture readnone %0, i8* %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %31
11: ; preds = %2
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 3
store i32 %12, i32* %13
%14 = tail call i32 @htons(i32 8080)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %14, i32* %15
%16 = tail call i32 @inet_addr(i8* %1)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %16, i32* %17
%18 = tail call i32 @memset(i32 undef, i32 0, i32 4)
%19 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%20 = call i64 @connect(i32 %7, %struct.sockaddr* %19, i32 16)
%21 = icmp slt i64 %20, 0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br i1 %21, label %23, label %27
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%25 = call i32 @putchar(i32 10)
%26 = call i32 @close(i32 %7)
br label %31
27: ; preds = %11
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%29 = call i32 @putchar(i32 10)
%30 = call i32 @close(i32 %7)
br label %31
31: ; preds = %27, %23, %9
%32 = phi i32 [ -1, %9 ], [ -1, %23 ], [ 0, %27 ]
ret i32 %32
}