#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_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  void *ai_socktype;
  void *ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;

/* Variables and functions */
void *AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
void *SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int /*<<< orphan*/ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
char getchar();
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(void *, void *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strndup(char *, int);
int main() {
  struct SContact {
    char ipAddr[16];
    char portNr[6];
  } friend;
  char listeningPortNr[6];
  int myRole = 0;
  int i = 0;
  char myCommand[101];
  char exitString[5] = "exit";
  char sendString[6] = "send:";
  char receiveString[8] = "receive";
  char stringToSend[100];
  int length;
  char lengthAnnouncementString[3];
  char stringJustReceived[100];
  int status;
  struct addrinfo hints;
  struct addrinfo *servinfo;
  int sockFd;
  int socketReuse = 1;
  struct sockaddr_storage their_addr;
  socklen_t addr_size;
  int newFd;
  int messageFd;
  printf("\nWhat do you want to be? Please enter \"1\" for server or \"2\" for "
         "client:\n\n");
  scanf("%d", &myRole);
  getchar();
  if (myRole == 1) {
    printf("\nPlease enter the number of the port to listen on for incoming "
           "connections ( > 1024 ):\n\n");
    while ((listeningPortNr[i] = getchar()) != '\n') {
      if (i == 5) {
        printf("You entered more than 5 characters. Please enter a number "
               "between 1025 and 65536!\n");
        return 1;
      }
      i++;
    }
    listeningPortNr[i] = '\0';
  } else {
    printf("\nPlease enter the ip-address of your friend's server (e.g. "
           "\"192.168.0.12\"):\n\n");
    while ((friend.ipAddr[i] = getchar()) != '\n') {
      if (i == 15) {
        printf("You entered more than 15 characters. Please use the dotted "
               "quad notation!\n");
        return 1;
      }
      i++;
    }
    printf("\nPlease enter the port number of your friend's server ( > 1024 "
           "):\n\n");
    i = 0;
    while ((friend.portNr[i] = getchar()) != '\n') {
      if (i == 5) {
        printf("You entered more than 5 characters. Please enter a number "
               "between 1025 and 65536!\n");
        return 1;
      }
      i++;
    }
    friend.portNr[i] = '\0';
  }
  if (myRole == 1) {
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;
    if ((status = getaddrinfo(NULL, listeningPortNr, &hints, &servinfo)) != 0) {
      fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
      exit(1);
    }
    sockFd = socket(servinfo->ai_family, servinfo->ai_socktype,
                    servinfo->ai_protocol);
    setsockopt(sockFd, SOL_SOCKET, SO_REUSEADDR, &socketReuse,
               sizeof socketReuse);
    bind(sockFd, servinfo->ai_addr, servinfo->ai_addrlen);
    listen(sockFd, 1);
    addr_size = sizeof their_addr;
    newFd = accept(sockFd, (struct sockaddr *)&their_addr, &addr_size);
    freeaddrinfo(servinfo);
    close(sockFd);
  } else {
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    status = getaddrinfo(friend.ipAddr, friend.portNr, &hints, &servinfo);
    sockFd = socket(servinfo->ai_family, servinfo->ai_socktype,
                    servinfo->ai_protocol);
    connect(sockFd, servinfo->ai_addr, servinfo->ai_addrlen);
    freeaddrinfo(servinfo);
  }
  do {
    printf("\nPlease enter one of the following commands:\n\n");
    printf(
        "send:message (e.g. \"send:Hi! How are you?\" - max. 70 characters)\n");
    printf("receive\n");
    printf("exit\n\n");
    i = 0;
    while ((myCommand[i] = getchar()) != '\n') {
      i++;
      if (i == 100) {
        printf("\nPlease do not enter more then 100 characters!\n");
        return 1;
      }
    }
    myCommand[i] = '\0';
    if (myRole == 1) {
      messageFd = newFd;
    } else {
      messageFd = sockFd;
    }
    if (strcmp(strndup(myCommand, 5), sendString) == 0) {
      for (i = 0, length = 0; (stringToSend[i] = myCommand[i + 5]) != '\0';
           i++, length++)
        ;
      length++;
      sprintf(lengthAnnouncementString, "%02d", length);
      send(messageFd, lengthAnnouncementString, 3, 0);
      send(messageFd, stringToSend, length, 0);
      printf("\nYour message has been sent.\n");
    }
    if (strcmp(myCommand, receiveString) == 0) {
      recv(messageFd, stringJustReceived, 3, 0);
      length = atoi(stringJustReceived);
      recv(messageFd, stringJustReceived, length, 0);
      printf("\nReceived message: %s\n", stringJustReceived);
    }
  } while (strcmp(myCommand, exitString) != 0);
  close(sockFd);
  close(newFd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0xd7a(%rip),%eax
mov    %eax,-0xa5(%rbp)
mov    0xd72(%rip),%al
mov    %al,-0xa1(%rbp)
mov    0xd67(%rip),%eax
mov    %eax,-0xab(%rbp)
mov    0xd5e(%rip),%ax
mov    %ax,-0xa7(%rbp)
mov    0xd52(%rip),%rax
mov    %rax,-0xb3(%rbp)
movl   $0x1,-0x1d0(%rbp)
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd7e(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10f0 <scanf@plt>
mov    $0x0,%al
call   10c0 <getchar@plt>
cmpl   $0x1,-0x2c(%rbp)
jne    1362 <main+0x102>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10c0 <getchar@plt>
movslq -0x30(%rbp),%rcx
mov    %al,-0x26(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     1354 <main+0xf4>
cmpl   $0x5,-0x30(%rbp)
jne    1346 <main+0xe6>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b9 <main+0x659>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1307 <main+0xa7>
movslq -0x30(%rbp),%rax
movb   $0x0,-0x26(%rbp,%rax,1)
jmp    1428 <main+0x1c8>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10c0 <getchar@plt>
movslq -0x30(%rbp),%rcx
mov    %al,-0x20(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     13bd <main+0x15d>
cmpl   $0xf,-0x30(%rbp)
jne    13af <main+0x14f>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b9 <main+0x659>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1370 <main+0x110>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   10c0 <getchar@plt>
movslq -0x30(%rbp),%rcx
mov    %al,-0x10(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     141f <main+0x1bf>
cmpl   $0x5,-0x30(%rbp)
jne    1411 <main+0x1b1>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b9 <main+0x659>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13d2 <main+0x172>
movslq -0x30(%rbp),%rax
movb   $0x0,-0x10(%rbp,%rax,1)
cmpl   $0x1,-0x2c(%rbp)
jne    15a1 <main+0x341>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2b8c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1a8(%rbp)
mov    0x2b63(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1b0(%rbp)
mov    0x2b72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1a0(%rbp)
lea    -0x26(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x1c0(%rbp),%rdx
lea    -0x1c8(%rbp),%rcx
call   1160 <getaddrinfo@plt>
mov    %eax,-0x194(%rbp)
cmp    $0x0,%eax
je     14d9 <main+0x279>
mov    0x2b21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1e8(%rbp)
mov    -0x194(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x1e8(%rbp),%edi
mov    %rax,%rdx
lea    0xd1f(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    -0x1c8(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x1c8(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x1c8(%rbp),%rax
mov    0x8(%rax),%edx
call   1180 <socket@plt>
mov    %eax,-0x1cc(%rbp)
mov    -0x1cc(%rbp),%edi
mov    0x2ad7(%rip),%rax
mov    (%rax),%esi
mov    0x2a9e(%rip),%rax
mov    (%rax),%edx
lea    -0x1d0(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x1cc(%rbp),%edi
mov    -0x1c8(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x1c8(%rbp),%rax
mov    (%rax),%edx
call   1100 <bind@plt>
mov    -0x1cc(%rbp),%edi
mov    $0x1,%esi
call   10e0 <listen@plt>
movl   $0x4,-0x1dc(%rbp)
mov    -0x1cc(%rbp),%edi
lea    -0x1d8(%rbp),%rsi
lea    -0x1dc(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x1e0(%rbp)
mov    -0x1c8(%rbp),%rdi
call   1170 <freeaddrinfo@plt>
mov    -0x1cc(%rbp),%edi
call   1090 <close@plt>
jmp    1650 <main+0x3f0>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2a1d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1a8(%rbp)
mov    0x29f4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1b0(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x10,%rsi
lea    -0x1c0(%rbp),%rdx
lea    -0x1c8(%rbp),%rcx
call   1160 <getaddrinfo@plt>
mov    %eax,-0x194(%rbp)
mov    -0x1c8(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x1c8(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x1c8(%rbp),%rax
mov    0x8(%rax),%edx
call   1180 <socket@plt>
mov    %eax,-0x1cc(%rbp)
mov    -0x1cc(%rbp),%edi
mov    -0x1c8(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x1c8(%rbp),%rax
mov    (%rax),%edx
call   1150 <connect@plt>
mov    -0x1c8(%rbp),%rdi
call   1170 <freeaddrinfo@plt>
jmp    1655 <main+0x3f5>
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbf4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   10c0 <getchar@plt>
movslq -0x30(%rbp),%rcx
mov    %al,-0xa0(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     16e4 <main+0x484>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x64,-0x30(%rbp)
jne    16df <main+0x47f>
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b9 <main+0x659>
jmp    1694 <main+0x434>
movslq -0x30(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
cmpl   $0x1,-0x2c(%rbp)
jne    170b <main+0x4ab>
mov    -0x1e0(%rbp),%eax
mov    %eax,-0x1e4(%rbp)
jmp    1717 <main+0x4b7>
mov    -0x1cc(%rbp),%eax
mov    %eax,-0x1e4(%rbp)
lea    -0xa0(%rbp),%rdi
mov    $0x5,%esi
call   10a0 <strndup@plt>
mov    %rax,%rdi
lea    -0xab(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1803 <main+0x5a3>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x124(%rbp)
mov    -0x30(%rbp),%eax
add    $0x5,%eax
cltq
mov    -0xa0(%rbp,%rax,1),%al
movslq -0x30(%rbp),%rcx
mov    %al,-0x120(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0x0,%eax
je     179a <main+0x53a>
jmp    177d <main+0x51d>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1752 <main+0x4f2>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
lea    -0x127(%rbp),%rdi
mov    -0x124(%rbp),%edx
lea    0xaf4(%rip),%rsi
call   1130 <sprintf@plt>
mov    -0x1e4(%rbp),%edi
lea    -0x127(%rbp),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x1e4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0xaba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xb3(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    187a <main+0x61a>
mov    -0x1e4(%rbp),%edi
lea    -0x190(%rbp),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    -0x190(%rbp),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x124(%rbp)
mov    -0x1e4(%rbp),%edi
lea    -0x190(%rbp),%rsi
mov    -0x124(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    -0x190(%rbp),%rsi
lea    0xa61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    187f <main+0x61f>
lea    -0xa0(%rbp),%rdi
lea    -0xa5(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1655 <main+0x3f5>
mov    -0x1cc(%rbp),%edi
call   1090 <close@plt>
mov    -0x1e0(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
movl   $0x0,0xc(%rsp)
movb   $0x0,0x44(%rsp)
movl   $0x74697865,0x40(%rsp)
74
movw   $0x3a,0x3c(%rsp)
movl   $0x646e6573,0x38(%rsp)
64
movabs $0x65766965636572,%rax
mov    %rax,0x60(%rsp)
movl   $0x1,0x50(%rsp)
lea    0xd7e(%rip),%rdi
call   1040 <puts@plt>
lea    0xd3c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1100 <scanf@plt>
xor    %eax,%eax
call   10d0 <getchar@plt>
cmpl   $0x1,0xc(%rsp)
jne    137d <main+0x10d>
lea    0xf3b(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x6(%rsp)
cmp    $0xa,%al
je     1370 <main+0x100>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x7(%rsp)
mov    $0x1,%ebx
cmp    $0xa,%al
je     1370 <main+0x100>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x8(%rsp)
mov    $0x2,%ebx
cmp    $0xa,%al
je     1370 <main+0x100>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x9(%rsp)
mov    $0x3,%ebx
cmp    $0xa,%al
je     1370 <main+0x100>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0xa(%rsp)
mov    $0x4,%ebx
cmp    $0xa,%al
je     1370 <main+0x100>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0xb(%rsp)
mov    $0x5,%ebx
cmp    $0xa,%al
jne    1871 <main+0x601>
lea    (%rsp,%rbx,1),%rax
add    $0x6,%rax
jmp    1526 <main+0x2b6>
lea    0xd06(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x10(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x11(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x12(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x13(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x14(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x15(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x16(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x17(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x18(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x19(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1a(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1b(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1c(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1d(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1e(%rsp)
cmp    $0xa,%al
je     1499 <main+0x229>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x1f(%rsp)
cmp    $0xa,%al
jne    187a <main+0x60a>
lea    0xc37(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x20(%rsp)
cmp    $0xa,%al
je     151e <main+0x2ae>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x21(%rsp)
mov    $0x1,%ebx
cmp    $0xa,%al
je     151e <main+0x2ae>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x22(%rsp)
mov    $0x2,%ebx
cmp    $0xa,%al
je     151e <main+0x2ae>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x23(%rsp)
mov    $0x3,%ebx
cmp    $0xa,%al
je     151e <main+0x2ae>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x24(%rsp)
mov    $0x4,%ebx
cmp    $0xa,%al
je     151e <main+0x2ae>
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x25(%rsp)
mov    $0x5,%ebx
cmp    $0xa,%al
jne    1871 <main+0x601>
lea    (%rsp,%rbx,1),%rax
add    $0x20,%rax
movb   $0x0,(%rax)
mov    0xc(%rsp),%ebx
lea    0x68(%rsp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1090 <memset@plt>
mov    0x2a93(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x80(%rsp)
mov    0x2a69(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x78(%rsp)
cmp    $0x1,%ebx
jne    1624 <main+0x3b4>
mov    0x2a71(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x88(%rsp)
lea    0x6(%rsp),%rsi
lea    0x68(%rsp),%rdx
lea    0x28(%rsp),%rcx
xor    %edi,%edi
call   1170 <getaddrinfo@plt>
test   %eax,%eax
jne    1883 <main+0x613>
mov    0x28(%rsp),%rax
mov    0x18(%rax),%rdi
mov    0x10(%rax),%rsi
mov    0x8(%rax),%edx
call   1190 <socket@plt>
mov    %eax,%r15d
mov    0x2a33(%rip),%rax
mov    (%rax),%esi
mov    0x29fa(%rip),%rax
mov    (%rax),%edx
lea    0x50(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
mov    0x28(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r15d,%edi
call   1110 <bind@plt>
mov    %r15d,%edi
mov    $0x1,%esi
call   10f0 <listen@plt>
movl   $0x4,0x4c(%rsp)
lea    0x58(%rsp),%rsi
lea    0x4c(%rsp),%rdx
mov    %r15d,%edi
call   1120 <accept@plt>
mov    %eax,0x34(%rsp)
mov    0x28(%rsp),%rdi
call   1180 <freeaddrinfo@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
jmp    1671 <main+0x401>
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdi
lea    0x68(%rsp),%rdx
lea    0x28(%rsp),%rcx
call   1170 <getaddrinfo@plt>
mov    0x28(%rsp),%rax
mov    0x18(%rax),%rdi
mov    0x10(%rax),%rsi
mov    0x8(%rax),%edx
call   1190 <socket@plt>
mov    %eax,%r15d
mov    0x28(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r15d,%edi
call   1160 <connect@plt>
mov    0x28(%rsp),%rdi
call   1180 <freeaddrinfo@plt>
lea    0xaa2(%rip),%r13
lea    0xac9(%rip),%r14
lea    0xb03(%rip),%rbx
lea    0xb04(%rip),%rbp
lea    0x38(%rsp),%r12
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
lea    0x90(%rsp),%rbp
nopl   0x0(%rax)
xor    %eax,%eax
call   10d0 <getchar@plt>
mov    %al,0x90(%rsp,%rbx,1)
cmp    $0xa,%al
je     16f0 <main+0x480>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    16c0 <main+0x450>
jmp    184e <main+0x5de>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,0x90(%rsp,%rbx,1)
cmpl   $0x1,0xc(%rsp)
mov    %r15d,%ebx
cmove  0x34(%rsp),%ebx
mov    %rbp,%rdi
mov    $0x5,%esi
call   10b0 <strndup@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    17b9 <main+0x549>
mov    0x95(%rsp),%al
mov    %al,0x100(%rsp)
xor    %r12d,%r12d
test   %al,%al
je     1759 <main+0x4e9>
nopl   0x0(%rax,%rax,1)
movzbl 0x96(%rsp,%r12,1),%eax
mov    %al,0x101(%rsp,%r12,1)
add    $0x1,%r12
test   %al,%al
jne    1740 <main+0x4d0>
add    $0x1,%r12d
lea    0x55(%rsp),%rbp
mov    %rbp,%rdi
lea    0x8b9(%rip),%rsi
mov    %r12d,%edx
call   1140 <sprintf@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %ebx,%edi
lea    0x100(%rsp),%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    0x9f7(%rip),%rdi
call   1040 <puts@plt>
lea    0x99c(%rip),%r14
lea    0x90(%rsp),%rbp
lea    0x38(%rsp),%r12
mov    %rbp,%rdi
lea    0x60(%rsp),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    1815 <main+0x5a5>
mov    %ebx,%edi
mov    %r15d,0x48(%rsp)
lea    0x170(%rsp),%r15
mov    %r15,%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r15,%rdi
call   1130 <atoi@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0x824(%rip),%rdi
mov    %r15,%rsi
mov    0x48(%rsp),%r15d
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
lea    0x40(%rsp),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
lea    0x95d(%rip),%rbx
lea    0x95e(%rip),%rbp
jne    1692 <main+0x422>
mov    %r15d,%edi
call   10a0 <close@plt>
mov    0x34(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
jmp    185f <main+0x5ef>
lea    0x95f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa0d(%rip),%rdi
jmp    1855 <main+0x5e5>
lea    0x962(%rip),%rdi
jmp    1855 <main+0x5e5>
mov    0x273e(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1080 <gai_strerror@plt>
lea    0x774(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.SContact = type { [16 x i8], [6 x i8] }
%struct.addrinfo = type { i32, i32, i32, i8*, i8*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.exitString = [5 x i8] c"exit\00"
@__const.main.sendString = [6 x i8] c"send:\00"
@__const.main.receiveString = [8 x i8] c"receive\00"
@.str = [74 x i8] c"\0AWhat do you want to be? Please enter \221\22 for server or \222\22 for client:\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [89 x i8] c"\0APlease enter the number of the port to listen on for incoming connections ( > 1024 ):\0A\0A\00"
@.str.3 = [83 x i8] c"You entered more than 5 characters. Please enter a number between 1025 and 65536!\0A\00"
@.str.4 = [78 x i8] c"\0APlease enter the ip-address of your friend's server (e.g. \22192.168.0.12\22):\0A\0A\00"
@.str.5 = [75 x i8] c"You entered more than 15 characters. Please use the dotted quad notation!\0A\00"
@.str.6 = [68 x i8] c"\0APlease enter the port number of your friend's server ( > 1024 ):\0A\0A\00"
@AF_UNSPEC = global i8* null
@SOCK_STREAM = global i8* null
@AI_PASSIVE = global i32 0
@stderr = global i32 0
@.str.7 = [23 x i8] c"getaddrinfo error: %s\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.8 = [47 x i8] c"\0APlease enter one of the following commands:\0A\0A\00"
@.str.9 = [66 x i8] c"send:message (e.g. \22send:Hi! How are you?\22 - max. 70 characters)\0A\00"
@.str.10 = [9 x i8] c"receive\0A\00"
@.str.11 = [7 x i8] c"exit\0A\0A\00"
@.str.12 = [48 x i8] c"\0APlease do not enter more then 100 characters!\0A\00"
@.str.13 = [5 x i8] c"%02d\00"
@.str.14 = [30 x i8] c"\0AYour message has been sent.\0A\00"
@.str.15 = [23 x i8] c"\0AReceived message: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.SContact
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [101 x i8]
%7 = alloca [5 x i8]
%8 = alloca [6 x i8]
%9 = alloca [8 x i8]
%10 = alloca [100 x i8]
%11 = alloca i32
%12 = alloca [3 x i8]
%13 = alloca [100 x i8]
%14 = alloca i32
%15 = alloca %struct.addrinfo
%16 = alloca %struct.addrinfo*
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.sockaddr_storage
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%23 = bitcast [5 x i8]* %7 to i8*
%24 = bitcast [6 x i8]* %8 to i8*
%25 = bitcast [8 x i8]* %9 to i8*
store i32 1, i32* %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%28 = call signext i8 (...) @getchar()
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %52
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %45, %31
%34 = call signext i8 (...) @getchar()
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %36
store i8 %34, i8* %37
%38 = sext i8 %34 to i32
%39 = icmp ne i32 %38, 10
br i1 %39, label %40, label %48
40: ; preds = %33
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 5
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %273
45: ; preds = %40
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %33
48: ; preds = %33
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %50
store i8 0, i8* %51
br label %93
52: ; preds = %0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %67, %52
%55 = call signext i8 (...) @getchar()
%56 = getelementptr inbounds %struct.SContact, %struct.SContact* %2, i32 0, i32 0
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %56, i64 0, i64 %58
store i8 %55, i8* %59
%60 = sext i8 %55 to i32
%61 = icmp ne i32 %60, 10
br i1 %61, label %62, label %70
62: ; preds = %54
%63 = load i32, i32* %5
%64 = icmp eq i32 %63, 15
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %273
67: ; preds = %62
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %54
70: ; preds = %54
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %5
br label %72
72: ; preds = %85, %70
%73 = call signext i8 (...) @getchar()
%74 = getelementptr inbounds %struct.SContact, %struct.SContact* %2, i32 0, i32 1
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [6 x i8], [6 x i8]* %74, i64 0, i64 %76
store i8 %73, i8* %77
%78 = sext i8 %73 to i32
%79 = icmp ne i32 %78, 10
br i1 %79, label %80, label %88
80: ; preds = %72
%81 = load i32, i32* %5
%82 = icmp eq i32 %81, 5
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %273
85: ; preds = %80
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %72
88: ; preds = %72
%89 = getelementptr inbounds %struct.SContact, %struct.SContact* %2, i32 0, i32 1
%90 = load i32, i32* %5
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [6 x i8], [6 x i8]* %89, i64 0, i64 %91
store i8 0, i8* %92
br label %93
93: ; preds = %88, %48
%94 = load i32, i32* %4
%95 = icmp eq i32 %94, 1
br i1 %95, label %96, label %145
96: ; preds = %93
%97 = call i32 @memset(%struct.addrinfo* %15, i32 0, i32 40)
%98 = load i8*, i8** @AF_UNSPEC
%99 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 4
store i8* %98, i8** %99
%100 = load i8*, i8** @SOCK_STREAM
%101 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 3
store i8* %100, i8** %101
%102 = load i32, i32* @AI_PASSIVE
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 5
store i32 %102, i32* %103
%104 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%105 = call i32 @getaddrinfo(i8* null, i8* %104, %struct.addrinfo* %15, %struct.addrinfo** %16)
store i32 %105, i32* %14
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %96
%108 = load i32, i32* @stderr
%109 = load i32, i32* %14
%110 = call i8* @gai_strerror(i32 %109)
%111 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %96
%114 = load %struct.addrinfo*, %struct.addrinfo** %16
%115 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %114, i32 0, i32 4
%116 = load i8*, i8** %115
%117 = load %struct.addrinfo*, %struct.addrinfo** %16
%118 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %117, i32 0, i32 3
%119 = load i8*, i8** %118
%120 = load %struct.addrinfo*, %struct.addrinfo** %16
%121 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %120, i32 0, i32 2
%122 = load i32, i32* %121
%123 = call i32 @socket(i8* %116, i8* %119, i32 %122)
store i32 %123, i32* %17
%124 = load i32, i32* %17
%125 = load i32, i32* @SOL_SOCKET
%126 = load i32, i32* @SO_REUSEADDR
%127 = call i32 @setsockopt(i32 %124, i32 %125, i32 %126, i32* %18, i32 4)
%128 = load i32, i32* %17
%129 = load %struct.addrinfo*, %struct.addrinfo** %16
%130 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i32 0, i32 1
%131 = load i32, i32* %130
%132 = load %struct.addrinfo*, %struct.addrinfo** %16
%133 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %132, i32 0, i32 0
%134 = load i32, i32* %133
%135 = call i32 @bind(i32 %128, i32 %131, i32 %134)
%136 = load i32, i32* %17
%137 = call i32 @listen(i32 %136, i32 1)
store i32 4, i32* %20
%138 = load i32, i32* %17
%139 = bitcast %struct.sockaddr_storage* %19 to %struct.sockaddr*
%140 = call i32 @accept(i32 %138, %struct.sockaddr* %139, i32* %20)
store i32 %140, i32* %21
%141 = load %struct.addrinfo*, %struct.addrinfo** %16
%142 = call i32 @freeaddrinfo(%struct.addrinfo* %141)
%143 = load i32, i32* %17
%144 = call i32 @close(i32 %143)
br label %176
145: ; preds = %93
%146 = call i32 @memset(%struct.addrinfo* %15, i32 0, i32 40)
%147 = load i8*, i8** @AF_UNSPEC
%148 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 4
store i8* %147, i8** %148
%149 = load i8*, i8** @SOCK_STREAM
%150 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 3
store i8* %149, i8** %150
%151 = getelementptr inbounds %struct.SContact, %struct.SContact* %2, i32 0, i32 0
%152 = getelementptr inbounds [16 x i8], [16 x i8]* %151, i64 0, i64 0
%153 = getelementptr inbounds %struct.SContact, %struct.SContact* %2, i32 0, i32 1
%154 = getelementptr inbounds [6 x i8], [6 x i8]* %153, i64 0, i64 0
%155 = call i32 @getaddrinfo(i8* %152, i8* %154, %struct.addrinfo* %15, %struct.addrinfo** %16)
store i32 %155, i32* %14
%156 = load %struct.addrinfo*, %struct.addrinfo** %16
%157 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %156, i32 0, i32 4
%158 = load i8*, i8** %157
%159 = load %struct.addrinfo*, %struct.addrinfo** %16
%160 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %159, i32 0, i32 3
%161 = load i8*, i8** %160
%162 = load %struct.addrinfo*, %struct.addrinfo** %16
%163 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %162, i32 0, i32 2
%164 = load i32, i32* %163
%165 = call i32 @socket(i8* %158, i8* %161, i32 %164)
store i32 %165, i32* %17
%166 = load i32, i32* %17
%167 = load %struct.addrinfo*, %struct.addrinfo** %16
%168 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %167, i32 0, i32 1
%169 = load i32, i32* %168
%170 = load %struct.addrinfo*, %struct.addrinfo** %16
%171 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %170, i32 0, i32 0
%172 = load i32, i32* %171
%173 = call i32 @connect(i32 %166, i32 %169, i32 %172)
%174 = load %struct.addrinfo*, %struct.addrinfo** %16
%175 = call i32 @freeaddrinfo(%struct.addrinfo* %174)
br label %176
176: ; preds = %145, %113
br label %177
177: ; preds = %263, %176
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0))
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %5
br label %182
182: ; preds = %196, %177
%183 = call signext i8 (...) @getchar()
%184 = load i32, i32* %5
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 %185
store i8 %183, i8* %186
%187 = sext i8 %183 to i32
%188 = icmp ne i32 %187, 10
br i1 %188, label %189, label %197
189: ; preds = %182
%190 = load i32, i32* %5
%191 = add nsw i32 %190, 1
store i32 %191, i32* %5
%192 = load i32, i32* %5
%193 = icmp eq i32 %192, 100
br i1 %193, label %194, label %196
194: ; preds = %189
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %1
br label %273
196: ; preds = %189
br label %182
197: ; preds = %182
%198 = load i32, i32* %5
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 %199
store i8 0, i8* %200
%201 = load i32, i32* %4
%202 = icmp eq i32 %201, 1
br i1 %202, label %203, label %205
203: ; preds = %197
%204 = load i32, i32* %21
store i32 %204, i32* %22
br label %207
205: ; preds = %197
%206 = load i32, i32* %17
store i32 %206, i32* %22
br label %207
207: ; preds = %205, %203
%208 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%209 = call i8* @strndup(i8* %208, i32 5)
%210 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%211 = call i64 @strcmp(i8* %209, i8* %210)
%212 = icmp eq i64 %211, 0
br i1 %212, label %213, label %245
213: ; preds = %207
store i32 0, i32* %5
store i32 0, i32* %11
br label %214
214: ; preds = %226, %213
%215 = load i32, i32* %5
%216 = add nsw i32 %215, 5
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 %217
%219 = load i8, i8* %218
%220 = load i32, i32* %5
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 %221
store i8 %219, i8* %222
%223 = sext i8 %219 to i32
%224 = icmp ne i32 %223, 0
br i1 %224, label %225, label %231
225: ; preds = %214
br label %226
226: ; preds = %225
%227 = load i32, i32* %5
%228 = add nsw i32 %227, 1
store i32 %228, i32* %5
%229 = load i32, i32* %11
%230 = add nsw i32 %229, 1
store i32 %230, i32* %11
br label %214
231: ; preds = %214
%232 = load i32, i32* %11
%233 = add nsw i32 %232, 1
store i32 %233, i32* %11
%234 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%235 = load i32, i32* %11
%236 = call i32 @sprintf(i8* %234, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %235)
%237 = load i32, i32* %22
%238 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%239 = call i32 @send(i32 %237, i8* %238, i32 3, i32 0)
%240 = load i32, i32* %22
%241 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%242 = load i32, i32* %11
%243 = call i32 @send(i32 %240, i8* %241, i32 %242, i32 0)
%244 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0))
br label %245
245: ; preds = %231, %207
%246 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%247 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%248 = call i64 @strcmp(i8* %246, i8* %247)
%249 = icmp eq i64 %248, 0
br i1 %249, label %250, label %262
250: ; preds = %245
%251 = load i32, i32* %22
%252 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%253 = call i32 @recv(i32 %251, i8* %252, i32 3, i32 0)
%254 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%255 = call i32 @atoi(i8* %254)
store i32 %255, i32* %11
%256 = load i32, i32* %22
%257 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%258 = load i32, i32* %11
%259 = call i32 @recv(i32 %256, i8* %257, i32 %258, i32 0)
%260 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%261 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i8* %260)
br label %262
262: ; preds = %250, %245
br label %263
263: ; preds = %262
%264 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%265 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%266 = call i64 @strcmp(i8* %264, i8* %265)
%267 = icmp ne i64 %266, 0
br i1 %267, label %177, label %268
268: ; preds = %263
%269 = load i32, i32* %17
%270 = call i32 @close(i32 %269)
%271 = load i32, i32* %21
%272 = call i32 @close(i32 %271)
store i32 0, i32* %1
br label %273
273: ; preds = %268, %194, %83, %65, %43
%274 = load i32, i32* %1
ret i32 %274
}

LLVM IR (-O2):
%struct.SContact = type { [16 x i8], [6 x i8] }
%struct.addrinfo = type { i32, i32, i32, i8*, i8*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.exitString = [5 x i8] c"exit\00"
@__const.main.sendString = [6 x i8] c"send:\00"
@.str.1 = [3 x i8] c"%d\00"
@AF_UNSPEC = global i8* null
@SOCK_STREAM = global i8* null
@AI_PASSIVE = global i32 0
@stderr = global i32 0
@.str.7 = [23 x i8] c"getaddrinfo error: %s\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.13 = [5 x i8] c"%02d\00"
@.str.15 = [23 x i8] c"\0AReceived message: %s\0A\00"
@str = [73 x i8] c"\0AWhat do you want to be? Please enter \221\22 for server or \222\22 for client:\0A\00"
@str.16 = [77 x i8] c"\0APlease enter the ip-address of your friend's server (e.g. \22192.168.0.12\22):\0A\00"
@str.17 = [67 x i8] c"\0APlease enter the port number of your friend's server ( > 1024 ):\0A\00"
@str.18 = [46 x i8] c"\0APlease enter one of the following commands:\0A\00"
@str.19 = [65 x i8] c"send:message (e.g. \22send:Hi! How are you?\22 - max. 70 characters)\00"
@str.20 = [8 x i8] c"receive\00"
@str.21 = [6 x i8] c"exit\0A\00"
@str.22 = [29 x i8] c"\0AYour message has been sent.\00"
@str.23 = [47 x i8] c"\0APlease do not enter more then 100 characters!\00"
@str.25 = [74 x i8] c"You entered more than 15 characters. Please use the dotted quad notation!\00"
@str.26 = [88 x i8] c"\0APlease enter the number of the port to listen on for incoming connections ( > 1024 ):\0A\00"
@str.27 = [82 x i8] c"You entered more than 5 characters. Please enter a number between 1025 and 65536!\00"
define i32 @main() {
%1 = alloca %struct.SContact
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = alloca [101 x i8]
%5 = alloca [5 x i8]
%6 = alloca [6 x i8]
%7 = alloca i64
%8 = alloca [100 x i8]
%9 = alloca [3 x i8]
%10 = alloca [100 x i8]
%11 = alloca %struct.addrinfo
%12 = alloca %struct.addrinfo*
%13 = alloca i32
%14 = alloca %struct.sockaddr_storage
%15 = alloca i32
%16 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 0
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%18 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%19 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%22 = bitcast i64* %7 to i8*
store i64 28559167692432754, i64* %7
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%26 = bitcast %struct.addrinfo* %11 to i8*
%27 = bitcast %struct.addrinfo** %12 to i8*
%28 = bitcast i32* %13 to i8*
store i32 1, i32* %13
%29 = bitcast %struct.sockaddr_storage* %14 to i8*
%30 = bitcast i32* %15 to i8*
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%33 = call signext i8 (...) @getchar()
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %65
36: ; preds = %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @str.26, i64 0, i64 0))
%38 = call signext i8 (...) @getchar()
store i8 %38, i8* %17
%39 = icmp eq i8 %38, 10
br i1 %39, label %62, label %40
40: ; preds = %36
%41 = call signext i8 (...) @getchar()
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 1
store i8 %41, i8* %42
%43 = icmp eq i8 %41, 10
br i1 %43, label %62, label %46
44: ; preds = %58
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.27, i64 0, i64 0))
br label %285
46: ; preds = %40
%47 = call signext i8 (...) @getchar()
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 2
store i8 %47, i8* %48
%49 = icmp eq i8 %47, 10
br i1 %49, label %62, label %50
50: ; preds = %46
%51 = call signext i8 (...) @getchar()
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 3
store i8 %51, i8* %52
%53 = icmp eq i8 %51, 10
br i1 %53, label %62, label %54
54: ; preds = %50
%55 = call signext i8 (...) @getchar()
%56 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 4
store i8 %55, i8* %56
%57 = icmp eq i8 %55, 10
br i1 %57, label %62, label %58
58: ; preds = %54
%59 = call signext i8 (...) @getchar()
%60 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 5
store i8 %59, i8* %60
%61 = icmp eq i8 %59, 10
br i1 %61, label %62, label %44
62: ; preds = %40, %46, %50, %54, %58, %36
%63 = phi i64 [ 0, %36 ], [ 1, %40 ], [ 2, %46 ], [ 3, %50 ], [ 4, %54 ], [ 5, %58 ]
%64 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %63
br label %161
65: ; preds = %0
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.16, i64 0, i64 0))
%67 = call signext i8 (...) @getchar()
store i8 %67, i8* %16
%68 = icmp eq i8 %67, 10
br i1 %68, label %131, label %69
69: ; preds = %65
%70 = call signext i8 (...) @getchar()
%71 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 1
store i8 %70, i8* %71
%72 = icmp eq i8 %70, 10
br i1 %72, label %131, label %73
73: ; preds = %69
%74 = call signext i8 (...) @getchar()
%75 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 2
store i8 %74, i8* %75
%76 = icmp eq i8 %74, 10
br i1 %76, label %131, label %77
77: ; preds = %73
%78 = call signext i8 (...) @getchar()
%79 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 3
store i8 %78, i8* %79
%80 = icmp eq i8 %78, 10
br i1 %80, label %131, label %81
81: ; preds = %77
%82 = call signext i8 (...) @getchar()
%83 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 4
store i8 %82, i8* %83
%84 = icmp eq i8 %82, 10
br i1 %84, label %131, label %85
85: ; preds = %81
%86 = call signext i8 (...) @getchar()
%87 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 5
store i8 %86, i8* %87
%88 = icmp eq i8 %86, 10
br i1 %88, label %131, label %89
89: ; preds = %85
%90 = call signext i8 (...) @getchar()
%91 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 6
store i8 %90, i8* %91
%92 = icmp eq i8 %90, 10
br i1 %92, label %131, label %93
93: ; preds = %89
%94 = call signext i8 (...) @getchar()
%95 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 7
store i8 %94, i8* %95
%96 = icmp eq i8 %94, 10
br i1 %96, label %131, label %97
97: ; preds = %93
%98 = call signext i8 (...) @getchar()
%99 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 8
store i8 %98, i8* %99
%100 = icmp eq i8 %98, 10
br i1 %100, label %131, label %101
101: ; preds = %97
%102 = call signext i8 (...) @getchar()
%103 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 9
store i8 %102, i8* %103
%104 = icmp eq i8 %102, 10
br i1 %104, label %131, label %105
105: ; preds = %101
%106 = call signext i8 (...) @getchar()
%107 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 10
store i8 %106, i8* %107
%108 = icmp eq i8 %106, 10
br i1 %108, label %131, label %109
109: ; preds = %105
%110 = call signext i8 (...) @getchar()
%111 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 11
store i8 %110, i8* %111
%112 = icmp eq i8 %110, 10
br i1 %112, label %131, label %113
113: ; preds = %109
%114 = call signext i8 (...) @getchar()
%115 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 12
store i8 %114, i8* %115
%116 = icmp eq i8 %114, 10
br i1 %116, label %131, label %117
117: ; preds = %113
%118 = call signext i8 (...) @getchar()
%119 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 13
store i8 %118, i8* %119
%120 = icmp eq i8 %118, 10
br i1 %120, label %131, label %121
121: ; preds = %117
%122 = call signext i8 (...) @getchar()
%123 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 14
store i8 %122, i8* %123
%124 = icmp eq i8 %122, 10
br i1 %124, label %131, label %125
125: ; preds = %121
%126 = call signext i8 (...) @getchar()
%127 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 0, i64 15
store i8 %126, i8* %127
%128 = icmp eq i8 %126, 10
br i1 %128, label %131, label %129
129: ; preds = %125
%130 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.25, i64 0, i64 0))
br label %285
131: ; preds = %69, %73, %77, %81, %85, %89, %93, %97, %101, %105, %109, %113, %117, %121, %125, %65
%132 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.17, i64 0, i64 0))
%133 = call signext i8 (...) @getchar()
%134 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 0
store i8 %133, i8* %134
%135 = icmp eq i8 %133, 10
br i1 %135, label %158, label %136
136: ; preds = %131
%137 = call signext i8 (...) @getchar()
%138 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 1
store i8 %137, i8* %138
%139 = icmp eq i8 %137, 10
br i1 %139, label %158, label %142
140: ; preds = %154
%141 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.27, i64 0, i64 0))
br label %285
142: ; preds = %136
%143 = call signext i8 (...) @getchar()
%144 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 2
store i8 %143, i8* %144
%145 = icmp eq i8 %143, 10
br i1 %145, label %158, label %146
146: ; preds = %142
%147 = call signext i8 (...) @getchar()
%148 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 3
store i8 %147, i8* %148
%149 = icmp eq i8 %147, 10
br i1 %149, label %158, label %150
150: ; preds = %146
%151 = call signext i8 (...) @getchar()
%152 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 4
store i8 %151, i8* %152
%153 = icmp eq i8 %151, 10
br i1 %153, label %158, label %154
154: ; preds = %150
%155 = call signext i8 (...) @getchar()
%156 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 5
store i8 %155, i8* %156
%157 = icmp eq i8 %155, 10
br i1 %157, label %158, label %140
158: ; preds = %136, %142, %146, %150, %154, %131
%159 = phi i64 [ 0, %131 ], [ 1, %136 ], [ 2, %142 ], [ 3, %146 ], [ 4, %150 ], [ 5, %154 ]
%160 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 %159
br label %161
161: ; preds = %158, %62
%162 = phi i8* [ %160, %158 ], [ %64, %62 ]
store i8 0, i8* %162
%163 = load i32, i32* %3
%164 = icmp eq i32 %163, 1
%165 = call i32 @memset(%struct.addrinfo* %11, i32 0, i32 40)
%166 = load i8*, i8** @AF_UNSPEC
%167 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 4
store i8* %166, i8** %167
%168 = load i8*, i8** @SOCK_STREAM
%169 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 3
store i8* %168, i8** %169
br i1 %164, label %170, label %204
170: ; preds = %161
%171 = load i32, i32* @AI_PASSIVE
%172 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 5
store i32 %171, i32* %172
%173 = call i32 @getaddrinfo(i8* null, i8* %17, %struct.addrinfo* %11, %struct.addrinfo** %12)
%174 = icmp eq i32 %173, 0
br i1 %174, label %180, label %175
175: ; preds = %170
%176 = load i32, i32* @stderr
%177 = call i8* @gai_strerror(i32 %173)
%178 = call i32 @fprintf(i32 %176, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %177)
%179 = call i32 @exit(i32 1)
unreachable
180: ; preds = %170
%181 = load %struct.addrinfo*, %struct.addrinfo** %12
%182 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %181, i64 0, i32 4
%183 = load i8*, i8** %182
%184 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %181, i64 0, i32 3
%185 = load i8*, i8** %184
%186 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %181, i64 0, i32 2
%187 = load i32, i32* %186
%188 = call i32 @socket(i8* %183, i8* %185, i32 %187)
%189 = load i32, i32* @SOL_SOCKET
%190 = load i32, i32* @SO_REUSEADDR
%191 = call i32 @setsockopt(i32 %188, i32 %189, i32 %190, i32* %13, i32 4)
%192 = load %struct.addrinfo*, %struct.addrinfo** %12
%193 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %192, i64 0, i32 1
%194 = load i32, i32* %193
%195 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %192, i64 0, i32 0
%196 = load i32, i32* %195
%197 = call i32 @bind(i32 %188, i32 %194, i32 %196)
%198 = call i32 @listen(i32 %188, i32 1)
store i32 4, i32* %15
%199 = bitcast %struct.sockaddr_storage* %14 to %struct.sockaddr*
%200 = call i32 @accept(i32 %188, %struct.sockaddr* %199, i32* %15)
%201 = load %struct.addrinfo*, %struct.addrinfo** %12
%202 = call i32 @freeaddrinfo(%struct.addrinfo* %201)
%203 = call i32 @close(i32 %188)
br label %223
204: ; preds = %161
%205 = getelementptr inbounds %struct.SContact, %struct.SContact* %1, i64 0, i32 1, i64 0
%206 = call i32 @getaddrinfo(i8* %16, i8* %205, %struct.addrinfo* %11, %struct.addrinfo** %12)
%207 = load %struct.addrinfo*, %struct.addrinfo** %12
%208 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %207, i64 0, i32 4
%209 = load i8*, i8** %208
%210 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %207, i64 0, i32 3
%211 = load i8*, i8** %210
%212 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %207, i64 0, i32 2
%213 = load i32, i32* %212
%214 = call i32 @socket(i8* %209, i8* %211, i32 %213)
%215 = load %struct.addrinfo*, %struct.addrinfo** %12
%216 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %215, i64 0, i32 1
%217 = load i32, i32* %216
%218 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %215, i64 0, i32 0
%219 = load i32, i32* %218
%220 = call i32 @connect(i32 %214, i32 %217, i32 %219)
%221 = load %struct.addrinfo*, %struct.addrinfo** %12
%222 = call i32 @freeaddrinfo(%struct.addrinfo* %221)
br label %223
223: ; preds = %204, %180
%224 = phi i32 [ %188, %180 ], [ %214, %204 ]
%225 = phi i32 [ %200, %180 ], [ undef, %204 ]
%226 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 5
br label %227
227: ; preds = %279, %223
%228 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%229 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.19, i64 0, i64 0))
%230 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%231 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.21, i64 0, i64 0))
br label %232
232: ; preds = %237, %227
%233 = phi i64 [ %238, %237 ], [ 0, %227 ]
%234 = call signext i8 (...) @getchar()
%235 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %233
store i8 %234, i8* %235
%236 = icmp eq i8 %234, 10
br i1 %236, label %242, label %237
237: ; preds = %232
%238 = add nuw nsw i64 %233, 1
%239 = icmp eq i64 %238, 100
br i1 %239, label %240, label %232
240: ; preds = %237
%241 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.23, i64 0, i64 0))
br label %285
242: ; preds = %232
%243 = and i64 %233, 4294967295
%244 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %243
store i8 0, i8* %244
%245 = load i32, i32* %3
%246 = icmp eq i32 %245, 1
%247 = select i1 %246, i32 %225, i32 %224
%248 = call i8* @strndup(i8* %19, i32 5)
%249 = call i64 @strcmp(i8* %248, i8* %21)
%250 = icmp eq i64 %249, 0
br i1 %250, label %251, label %271
251: ; preds = %242
%252 = load i8, i8* %226
store i8 %252, i8* %23
%253 = icmp eq i8 %252, 0
br i1 %253, label %264, label %254
254: ; preds = %251, %254
%255 = phi i64 [ %256, %254 ], [ 0, %251 ]
%256 = add nuw nsw i64 %255, 1
%257 = add nuw nsw i64 %255, 6
%258 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %257
%259 = load i8, i8* %258
%260 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %256
store i8 %259, i8* %260
%261 = icmp eq i8 %259, 0
br i1 %261, label %262, label %254
262: ; preds = %254
%263 = trunc i64 %256 to i32
br label %264
264: ; preds = %262, %251
%265 = phi i32 [ 0, %251 ], [ %263, %262 ]
%266 = add nuw nsw i32 %265, 1
%267 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %266)
%268 = call i32 @send(i32 %247, i8* %24, i32 3, i32 0)
%269 = call i32 @send(i32 %247, i8* %23, i32 %266, i32 0)
%270 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.22, i64 0, i64 0))
br label %271
271: ; preds = %264, %242
%272 = call i64 @strcmp(i8* %19, i8* %22)
%273 = icmp eq i64 %272, 0
br i1 %273, label %274, label %279
274: ; preds = %271
%275 = call i32 @recv(i32 %247, i8* %25, i32 3, i32 0)
%276 = call i32 @atoi(i8* %25)
%277 = call i32 @recv(i32 %247, i8* %25, i32 %276, i32 0)
%278 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i8* %25)
br label %279
279: ; preds = %271, %274
%280 = call i64 @strcmp(i8* %19, i8* %20)
%281 = icmp eq i64 %280, 0
br i1 %281, label %282, label %227
282: ; preds = %279
%283 = call i32 @close(i32 %224)
%284 = call i32 @close(i32 %225)
br label %285
285: ; preds = %282, %240, %140, %129, %44
%286 = phi i32 [ 1, %44 ], [ 1, %240 ], [ 0, %282 ], [ 1, %129 ], [ 1, %140 ]
ret i32 %286
}