#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;
  int /*<<< orphan*/ sin_family;
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  fd_set readfds;
  struct sockaddr_in server;
  int s, port, slen = sizeof(server);
  char user[50], ip[50], message[512], server_message[512];
  strcpy(ip, "127.0.0.1");
  strcpy(user, "user");
  port = 8080;
  if (argc > 4) {
    strcpy(ip, argv[1]);
    port = atoi(argv[2]);
    strcpy(user, argv[3]);
  } else if (argc > 3) {
    strcpy(ip, argv[1]);
    port = atoi(argv[2]);
  } else if (argc > 2) {
    strcpy(ip, argv[1]);
  }
  s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if (s == -1) {
    perror("socket failed");
    return 1;
  }
  memset((char *)&server, 0, sizeof(server));
  server.sin_addr.s_addr = inet_addr(ip);
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  sendto(s, "init", 512, 0, (struct sockaddr *)&server, slen);
  while (1) {
    FD_ZERO(&readfds);
    FD_SET(s, &readfds);
    FD_SET(0, &readfds);
    int rc = select(s + 1, &readfds, NULL, NULL, NULL);
    if (rc == 0)
      break;
    if (rc == -1)
      break;
    if (FD_ISSET(0, &readfds)) {
      if (fgets(message, 512, stdin) != NULL) {
        if (sendto(s, message, 512, 0, (struct sockaddr *)&server,
                   (socklen_t)sizeof(server)) < 0) {
          perror("send failed");
          return 1;
        }
        bzero(message, 512);
        printf("wyslano\n");
      }
    }
    if (FD_ISSET(s, &readfds)) {
      if (recvfrom(s, server_message, 512, 0, NULL, NULL) < 0) {
        perror("recv failed");
        return 1;
      }
      printf("%s", server_message);
      bzero(server_message, 512);
    }
  }
  close(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x2c(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xdbc(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1f90,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    129e <main+0x8e>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <strcpy@plt>
jmp    12f9 <main+0xe9>
cmpl   $0x3,-0x8(%rbp)
jle    12d1 <main+0xc1>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    12f4 <main+0xe4>
cmpl   $0x2,-0x8(%rbp)
jle    12ef <main+0xdf>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    12f4 <main+0xe4>
jmp    12f9 <main+0xe9>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
mov    0x2ccf(%rip),%rax
mov    (%rax),%esi
mov    0x2cae(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    133e <main+0x12e>
lea    0xce2(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1525 <main+0x315>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
lea    -0xa0(%rbp),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x18(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    0xc97(%rip),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
lea    -0x14(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0x24(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1120 <FD_SET@plt>
xor    %edi,%edi
lea    -0x14(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
mov    %eax,-0x4a4(%rbp)
cmpl   $0x0,-0x4a4(%rbp)
jne    13e4 <main+0x1d4>
jmp    1516 <main+0x306>
cmpl   $0xffffffff,-0x4a4(%rbp)
jne    13f6 <main+0x1e6>
jmp    1516 <main+0x306>
xor    %edi,%edi
lea    -0x14(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1495 <main+0x285>
lea    -0x2a0(%rbp),%rdi
mov    0x2bc7(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1490 <main+0x280>
mov    -0x24(%rbp),%edi
lea    -0x2a0(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    $0x200,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1080 <sendto@plt>
cmp    $0x0,%rax
jge    1471 <main+0x261>
lea    0xbc2(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1525 <main+0x315>
lea    -0x2a0(%rbp),%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1495 <main+0x285>
mov    -0x24(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1511 <main+0x301>
mov    -0x24(%rbp),%edi
lea    -0x4a0(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10e0 <recvfrom@plt>
cmp    $0x0,%rax
jge    14eb <main+0x2db>
lea    0xb5d(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1525 <main+0x315>
lea    -0x4a0(%rbp),%rsi
lea    0xb4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4a0(%rbp),%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
jmp    1392 <main+0x182>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdc3(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xdbc(%rip),%rsi
lea    0x50(%rsp),%rdi
call   1030 <strcpy@plt>
cmp    $0x5,%ebp
jl     1282 <main+0x62>
mov    0x8(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   1120 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rsi
lea    0x50(%rsp),%rdi
jmp    12b7 <main+0x97>
cmp    $0x4,%ebp
jne    12a3 <main+0x83>
mov    0x8(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   1120 <atoi@plt>
mov    %eax,%r14d
jmp    12bc <main+0x9c>
mov    $0x1f90,%r14d
cmp    $0x3,%ebp
jl     12bc <main+0x9c>
mov    0x8(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x2d25(%rip),%r15
mov    (%r15),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
mov    0x2cea(%rip),%rax
mov    (%rax),%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
je     1469 <main+0x249>
mov    %eax,%ebx
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
lea    0x10(%rsp),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0x8(%rsp)
mov    (%r15),%eax
mov    %eax,0x4(%rsp)
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
lea    0xcfc(%rip),%rsi
mov    %ebx,%edi
mov    $0x200,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
mov    $0xc,%r9d
call   1090 <sendto@plt>
mov    %ebx,%r15d
add    $0x1,%r15d
lea    0xc(%rsp),%rbp
lea    0x90(%rsp),%r12
lea    0xce7(%rip),%r13
lea    0x290(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   10d0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
add    $0x1,%eax
cmp    $0x2,%eax
jb     144e <main+0x22e>
xor    %edi,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1400 <main+0x1e0>
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x200,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
je     1400 <main+0x1e0>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
mov    %rsp,%r8
mov    $0xc,%r9d
call   1090 <sendto@plt>
test   %rax,%rax
js     147b <main+0x25b>
mov    %r14,%rdi
mov    $0x200,%esi
call   1110 <bzero@plt>
lea    0xc42(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1360 <main+0x140>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10f0 <recvfrom@plt>
test   %rax,%rax
js     1472 <main+0x252>
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    $0x200,%esi
call   1110 <bzero@plt>
jmp    1360 <main+0x140>
mov    %ebx,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb9f(%rip),%rdi
jmp    1482 <main+0x262>
lea    0xbb5(%rip),%rdi
jmp    1482 <main+0x262>
lea    0xba0(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%eax
jmp    1457 <main+0x237>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"user\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.2 = [14 x i8] c"socket failed\00"
@.str.3 = [5 x i8] c"init\00"
@stdin = global i32 0
@.str.4 = [12 x i8] c"send failed\00"
@.str.5 = [9 x i8] c"wyslano\0A\00"
@.str.6 = [12 x i8] c"recv failed\00"
@.str.7 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [50 x i8]
%12 = alloca [50 x i8]
%13 = alloca [512 x i8]
%14 = alloca [512 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %10
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 8080, i32* %9
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 4
br i1 %21, label %22, label %37
22: ; preds = %2
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @strcpy(i8* %23, i8* %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %9
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %32, i8* %35)
br label %61
37: ; preds = %2
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 3
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @strcpy(i8* %41, i8* %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %9
br label %60
50: ; preds = %37
%51 = load i32, i32* %4
%52 = icmp sgt i32 %51, 2
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 @strcpy(i8* %54, i8* %57)
br label %59
59: ; preds = %53, %50
br label %60
60: ; preds = %59, %40
br label %61
61: ; preds = %60, %22
%62 = load i32, i32* @AF_INET
%63 = load i32, i32* @SOCK_DGRAM
%64 = load i32, i32* @IPPROTO_UDP
%65 = call i32 @socket(i32 %62, i32 %63, i32 %64)
store i32 %65, i32* %8
%66 = load i32, i32* %8
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %70
68: ; preds = %61
%69 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %142
70: ; preds = %61
%71 = bitcast %struct.sockaddr_in* %7 to i8*
%72 = call i32 @memset(i8* %71, i32 0, i32 12)
%73 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%74 = call i32 @inet_addr(i8* %73)
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
%76 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %75, i32 0, i32 0
store i32 %74, i32* %76
%77 = load i32, i32* @AF_INET
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %77, i32* %78
%79 = load i32, i32* %9
%80 = call i32 @htons(i32 %79)
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %80, i32* %81
%82 = load i32, i32* %8
%83 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%84 = load i32, i32* %10
%85 = call i64 @sendto(i32 %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 512, i32 0, %struct.sockaddr* %83, i32 %84)
br label %86
86: ; preds = %70, %138
%87 = call i32 @FD_ZERO(i32* %6)
%88 = load i32, i32* %8
%89 = call i32 @FD_SET(i32 %88, i32* %6)
%90 = call i32 @FD_SET(i32 0, i32* %6)
%91 = load i32, i32* %8
%92 = add nsw i32 %91, 1
%93 = call i32 @select(i32 %92, i32* %6, i32* null, i32* null, i32* null)
store i32 %93, i32* %15
%94 = load i32, i32* %15
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %86
br label %139
97: ; preds = %86
%98 = load i32, i32* %15
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %101
100: ; preds = %97
br label %139
101: ; preds = %97
%102 = call i64 @FD_ISSET(i32 0, i32* %6)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %122
104: ; preds = %101
%105 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%106 = load i32, i32* @stdin
%107 = call i32* @fgets(i8* %105, i32 512, i32 %106)
%108 = icmp ne i32* %107, null
br i1 %108, label %109, label %121
109: ; preds = %104
%110 = load i32, i32* %8
%111 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%112 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%113 = call i64 @sendto(i32 %110, i8* %111, i32 512, i32 0, %struct.sockaddr* %112, i32 12)
%114 = icmp slt i64 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %142
117: ; preds = %109
%118 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%119 = call i32 @bzero(i8* %118, i32 512)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %121
121: ; preds = %117, %104
br label %122
122: ; preds = %121, %101
%123 = load i32, i32* %8
%124 = call i64 @FD_ISSET(i32 %123, i32* %6)
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %138
126: ; preds = %122
%127 = load i32, i32* %8
%128 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%129 = call i64 @recvfrom(i32 %127, i8* %128, i32 512, i32 0, i32* null, i32* null)
%130 = icmp slt i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %126
%132 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %142
133: ; preds = %126
%134 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %134)
%136 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%137 = call i32 @bzero(i8* %136, i32 512)
br label %138
138: ; preds = %133, %122
br label %86
139: ; preds = %100, %96
%140 = load i32, i32* %8
%141 = call i32 @close(i32 %140)
store i32 0, i32* %3
br label %142
142: ; preds = %139, %131, %115, %68
%143 = load i32, i32* %3
ret i32 %143
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"user\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.2 = [14 x i8] c"socket failed\00"
@.str.3 = [5 x i8] c"init\00"
@stdin = global i32 0
@.str.4 = [12 x i8] c"send failed\00"
@.str.6 = [12 x i8] c"recv failed\00"
@.str.7 = [3 x i8] c"%s\00"
@str = [8 x i8] c"wyslano\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [50 x i8]
%6 = alloca [50 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = bitcast i32* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%15 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp sgt i32 %0, 4
br i1 %17, label %18, label %28
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %12, i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = call i32 @strcpy(i8* %11, i8* %26)
br label %43
28: ; preds = %2
%29 = icmp eq i32 %0, 4
br i1 %29, label %30, label %37
30: ; preds = %28
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcpy(i8* %12, i8* %32)
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
br label %43
37: ; preds = %28
%38 = icmp sgt i32 %0, 2
br i1 %38, label %39, label %43
39: ; preds = %37
%40 = getelementptr inbounds i8*, i8** %1, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @strcpy(i8* %12, i8* %41)
br label %43
43: ; preds = %30, %39, %37, %18
%44 = phi i32 [ %24, %18 ], [ %36, %30 ], [ 8080, %39 ], [ 8080, %37 ]
%45 = load i32, i32* @AF_INET
%46 = load i32, i32* @SOCK_DGRAM
%47 = load i32, i32* @IPPROTO_UDP
%48 = call i32 @socket(i32 %45, i32 %46, i32 %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %97
52: ; preds = %43
%53 = call i32 @memset(i8* %10, i32 0, i32 12)
%54 = call i32 @inet_addr(i8* %12)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2, i32 0
store i32 %54, i32* %55
%56 = load i32, i32* @AF_INET
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %56, i32* %57
%58 = call i32 @htons(i32 %44)
%59 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %58, i32* %59
%60 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%61 = call i64 @sendto(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 512, i32 0, %struct.sockaddr* %60, i32 12)
%62 = add nuw nsw i32 %48, 1
br label %63
63: ; preds = %86, %52
%64 = call i32 @FD_ZERO(i32* %3)
%65 = call i32 @FD_SET(i32 %48, i32* %3)
%66 = call i32 @FD_SET(i32 0, i32* %3)
%67 = call i32 @select(i32 %62, i32* %3, i32* null, i32* null, i32* null)
switch i32 %67, label %68 [
i32 0, label %95
i32 -1, label %95
]
68: ; preds = %63
%69 = call i64 @FD_ISSET(i32 0, i32* %3)
%70 = icmp eq i64 %69, 0
br i1 %70, label %83, label %71
71: ; preds = %68
%72 = load i32, i32* @stdin
%73 = call i32* @fgets(i8* %13, i32 512, i32 %72)
%74 = icmp eq i32* %73, null
br i1 %74, label %83, label %75
75: ; preds = %71
%76 = call i64 @sendto(i32 %48, i8* %13, i32 512, i32 0, %struct.sockaddr* %60, i32 12)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %97
80: ; preds = %75
%81 = call i32 @bzero(i8* %13, i32 512)
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %83
83: ; preds = %71, %80, %68
%84 = call i64 @FD_ISSET(i32 %48, i32* %3)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %83, %92
br label %63
87: ; preds = %83
%88 = call i64 @recvfrom(i32 %48, i8* %14, i32 512, i32 0, i32* null, i32* null)
%89 = icmp slt i64 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %87
%91 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %97
92: ; preds = %87
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %14)
%94 = call i32 @bzero(i8* %14, i32 512)
br label %86
95: ; preds = %63, %63
%96 = call i32 @close(i32 %48)
br label %97
97: ; preds = %90, %78, %95, %50
%98 = phi i32 [ 1, %50 ], [ 0, %95 ], [ 1, %78 ], [ 1, %90 ]
ret i32 %98
}