#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_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ arry_port;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ exit(int);
char getchar();
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int arry_port[] = {83, 86, 89};
  int mysock[] = {0, 0, 0};
  struct sockaddr_in sin;
  struct sockaddr_in pin;
  int tmpsock;
  char str[1024] = {0};
  int addrsize;
  int len = 0;
  int i = 0;
  char c;
  printf("[jet] <<<listener enter\n");
  bzero(&sin, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = htonl(INADDR_ANY);
  for (i = 0; i < sizeof(arry_port) / sizeof(int); i++) {
    sin.sin_port = htons(arry_port[i]);
    mysock[i] = socket(AF_INET, SOCK_STREAM, 0);
    if (mysock[i] == -1) {
      perror("jet_error: call to socket\n");
      exit(1);
    }
    if (bind(mysock[i], (struct sockaddr *)&sin, sizeof(sin)) == -1) {
      perror("jet_error: call to bind\n");
      exit(1);
    }
    if (listen(mysock[i], 5) == -1) {
      perror("jet_error: call to listen\n");
      exit(1);
    }
  }
  printf("jet dedicated port [83, 86, 89] are under listenning...\n");
  while (1) {
    c = getchar();
    if (c == 'q' || c == 'Q') {
      break;
    } else {
      continue;
    }
  }
  printf("[jet] listener exit>>>\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe37(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe35(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x1c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
lea    -0x440(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movl   $0x0,-0x448(%rbp)
movl   $0x0,-0x44c(%rbp)
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <bzero@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x44c(%rbp)
movslq -0x44c(%rbp),%rax
cmp    $0x3,%rax
jae    1345 <main+0x195>
movslq -0x44c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
call   1030 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,%ecx
movslq -0x44c(%rbp),%rax
mov    %ecx,-0x1c(%rbp,%rax,4)
movslq -0x44c(%rbp),%rax
cmpl   $0xffffffff,-0x1c(%rbp,%rax,4)
jne    12c0 <main+0x110>
lea    0xd74(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movslq -0x44c(%rbp),%rax
mov    -0x1c(%rbp,%rax,4),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
cmp    $0xffffffff,%eax
jne    12f8 <main+0x148>
lea    0xd57(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movslq -0x44c(%rbp),%rax
mov    -0x1c(%rbp,%rax,4),%edi
mov    $0x5,%esi
call   1080 <listen@plt>
cmp    $0xffffffff,%eax
jne    132c <main+0x17c>
lea    0xd3c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1331 <main+0x181>
mov    -0x44c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44c(%rbp)
jmp    124e <main+0x9e>
lea    0xd28(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x44d(%rbp)
movsbl -0x44d(%rbp),%eax
cmp    $0x71,%eax
je     137e <main+0x1ce>
movsbl -0x44d(%rbp),%eax
cmp    $0x51,%eax
jne    1383 <main+0x1d3>
jmp    1388 <main+0x1d8>
jmp    1351 <main+0x1a1>
lea    0xd1e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0xc,%esi
call   10a0 <bzero@plt>
mov    0x2e1f(%rip),%r14
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x53,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    0x2dd7(%rip),%r15
mov    (%r15),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1305 <main+0x165>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1080 <bind@plt>
cmp    $0xffffffff,%eax
je     130e <main+0x16e>
mov    %ebx,%edi
mov    $0x5,%esi
call   1070 <listen@plt>
cmp    $0xffffffff,%eax
je     1317 <main+0x177>
mov    $0x56,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    (%r15),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1305 <main+0x165>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1080 <bind@plt>
cmp    $0xffffffff,%eax
je     130e <main+0x16e>
mov    %ebx,%edi
mov    $0x5,%esi
call   1070 <listen@plt>
cmp    $0xffffffff,%eax
je     1317 <main+0x177>
mov    $0x59,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    (%r15),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1305 <main+0x165>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1080 <bind@plt>
cmp    $0xffffffff,%eax
je     130e <main+0x16e>
mov    %ebx,%edi
mov    $0x5,%esi
call   1070 <listen@plt>
cmp    $0xffffffff,%eax
je     1317 <main+0x177>
lea    0xd8d(%rip),%rdi
call   1030 <puts@plt>
nop
xor    %eax,%eax
call   1060 <getchar@plt>
and    $0xdf,%al
cmp    $0x51,%al
jne    12e0 <main+0x140>
lea    0xdab(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xcf4(%rip),%rdi
jmp    131e <main+0x17e>
lea    0xd06(%rip),%rdi
jmp    131e <main+0x17e>
lea    0xd16(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.arry_port = [3 x i32] [i32 83, i32 86, i32 89]
@.str = [25 x i8] c"[jet] <<<listener enter\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [27 x i8] c"jet_error: call to socket\0A\00"
@.str.2 = [25 x i8] c"jet_error: call to bind\0A\00"
@.str.3 = [27 x i8] c"jet_error: call to listen\0A\00"
@.str.4 = [57 x i8] c"jet dedicated port [83, 86, 89] are under listenning...\0A\00"
@.str.5 = [24 x i8] c"[jet] listener exit>>>\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [3 x i32]
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store i32 0, i32* %1
%12 = bitcast [3 x i32]* %2 to i8*
%13 = bitcast [3 x i32]* %3 to i8*
%14 = bitcast [1024 x i8]* %7 to i8*
store i32 0, i32* %9
store i32 0, i32* %10
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %17, i32* %18
%19 = load i32, i32* @INADDR_ANY
%20 = call i32 @htonl(i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i32 %20, i32* %22
store i32 0, i32* %10
br label %23
23: ; preds = %70, %0
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = icmp ult i64 %25, 3
br i1 %26, label %27, label %73
27: ; preds = %23
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 @htons(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %32, i32* %33
%34 = load i32, i32* @AF_INET
%35 = load i32, i32* @SOCK_STREAM
%36 = call i32 @socket(i32 %34, i32 %35, i32 0)
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %38
store i32 %36, i32* %39
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %27
%46 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %27
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%54 = call i32 @bind(i32 %52, %struct.sockaddr* %53, i32 12)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %48
%57 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %48
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = call i32 @listen(i32 %63, i32 5)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %59
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %23
73: ; preds = %23
%74 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
br label %75
75: ; preds = %73, %85
%76 = call signext i8 (...) @getchar()
store i8 %76, i8* %11
%77 = load i8, i8* %11
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 113
br i1 %79, label %84, label %80
80: ; preds = %75
%81 = load i8, i8* %11
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 81
br i1 %83, label %84, label %85
84: ; preds = %80, %75
br label %86
85: ; preds = %80
br label %75
86: ; preds = %84
%87 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [27 x i8] c"jet_error: call to socket\0A\00"
@.str.2 = [25 x i8] c"jet_error: call to bind\0A\00"
@.str.3 = [27 x i8] c"jet_error: call to listen\0A\00"
@str = [24 x i8] c"[jet] <<<listener enter\00"
@str.6 = [56 x i8] c"jet dedicated port [83, 86, 89] are under listenning...\00"
@str.7 = [23 x i8] c"[jet] listener exit>>>\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%4 = call i32 @bzero(%struct.sockaddr_in* %1, i32 12)
%5 = load i32, i32* @AF_INET
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %5, i32* %6
%7 = load i32, i32* @INADDR_ANY
%8 = tail call i32 @htonl(i32 %7)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%11 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%12 = call i32 @htons(i32 83)
store i32 %12, i32* %10
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %43, label %46
17: ; preds = %52
%18 = call i32 @htons(i32 86)
store i32 %18, i32* %10
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = call i32 @socket(i32 %19, i32 %20, i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %43, label %23
23: ; preds = %17
%24 = call i32 @bind(i32 %21, %struct.sockaddr* %11, i32 12)
%25 = icmp eq i32 %24, -1
br i1 %25, label %49, label %26
26: ; preds = %23
%27 = call i32 @listen(i32 %21, i32 5)
%28 = icmp eq i32 %27, -1
br i1 %28, label %55, label %29
29: ; preds = %26
%30 = call i32 @htons(i32 89)
store i32 %30, i32* %10
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = call i32 @socket(i32 %31, i32 %32, i32 0)
%34 = icmp eq i32 %33, -1
br i1 %34, label %43, label %35
35: ; preds = %29
%36 = call i32 @bind(i32 %33, %struct.sockaddr* %11, i32 12)
%37 = icmp eq i32 %36, -1
br i1 %37, label %49, label %38
38: ; preds = %35
%39 = call i32 @listen(i32 %33, i32 5)
%40 = icmp eq i32 %39, -1
br i1 %40, label %55, label %41
41: ; preds = %38
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.6, i64 0, i64 0))
br label %58
43: ; preds = %29, %17, %0
%44 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %0
%47 = call i32 @bind(i32 %15, %struct.sockaddr* %11, i32 12)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %52
49: ; preds = %35, %23, %46
%50 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %46
%53 = call i32 @listen(i32 %15, i32 5)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %17
55: ; preds = %38, %26, %52
%56 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %58, %41
%59 = call signext i8 (...) @getchar()
%60 = and i8 %59, -33
%61 = icmp eq i8 %60, 81
br i1 %61, label %62, label %58
62: ; preds = %58
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}