#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ remote_addr;
typedef int /*<<< orphan*/ buff2;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int sockfd;
  int retval;
  struct sockaddr_in remote_addr;
  socklen_t addr_len;
  char buff[256];
  char buff2[256];
  if (argc != 3) {
    fprintf(stderr, "Invocation: %s <IPv4 ADDRESS> <PORT>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  sockfd = socket(PF_INET, SOCK_DGRAM, 0);
  if (sockfd == -1) {
    perror("socket()");
    exit(EXIT_FAILURE);
  }
  memset(&remote_addr, 0, sizeof(remote_addr));
  remote_addr.sin_family = AF_INET;
  retval = inet_pton(AF_INET, argv[1], &remote_addr.sin_addr);
  if (retval == 0) {
    fprintf(stderr, "inet_pton(): invalid network address!\n");
    exit(EXIT_FAILURE);
  } else if (retval == -1) {
    perror("inet_pton()");
    exit(EXIT_FAILURE);
  }
  remote_addr.sin_port = htons(atoi(argv[2]));
  addr_len = sizeof(remote_addr);
  fprintf(stdout, "Sending message to %s.\nWaiting for server response...\n",
          argv[1]);
  connect(sockfd, (struct sockaddr *)&remote_addr, addr_len);
  while (1) {
    fprintf(stdout, "Podaj liczbe: ");
    fgets(buff2, 100, stdin);
    if (buff2[0] == '\0' || buff2[0] == '\n') {
      fprintf(stdout,
              "Pusta wiadomosc! Wysylamy pusta do servera i konczymy "
              "dzialanie!: %s",
              buff2);
    }
    retval = send(sockfd, buff2, sizeof(buff2), 0);
    if (retval == -1) {
      perror("sendto()");
      exit(EXIT_FAILURE);
    }
    if (buff2[0] == '\0' || buff2[0] == '\n') {
      break;
    }
    retval = recv(sockfd, buff2, sizeof(buff2), 0);
    if (retval == -1) {
      perror("recvfrom()");
      exit(EXIT_FAILURE);
    }
    fprintf(stdout, "Server response: '%s'\n", buff2);
    buff2[retval] = '\0';
    buff2[0] = '\0';
  }
  close(sockfd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     121f <main+0x4f>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2da9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    125f <main+0x8f>
lea    0xdda(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x28(%rbp),%rdx
add    $0x4,%rdx
call   10a0 <inet_pton@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    12cb <main+0xfb>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    12ef <main+0x11f>
lea    0xd7a(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
jmp    12f4 <main+0x124>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0xc,-0x2c(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   10e0 <connect@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x230(%rbp),%rdi
mov    0x2c7b(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1080 <fgets@plt>
movsbl -0x230(%rbp),%eax
cmp    $0x0,%eax
je     1391 <main+0x1c1>
movsbl -0x230(%rbp),%eax
cmp    $0xa,%eax
jne    13af <main+0x1df>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
lea    -0x230(%rbp),%rdx
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x14(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    13ec <main+0x21c>
lea    0xd14(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
movsbl -0x230(%rbp),%eax
cmp    $0x0,%eax
je     140c <main+0x23c>
movsbl -0x230(%rbp),%eax
cmp    $0xa,%eax
jne    1411 <main+0x241>
jmp    1484 <main+0x2b4>
mov    -0x14(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    144e <main+0x27e>
lea    0xcbb(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    0x2b5b(%rip),%rax
mov    (%rax),%edi
lea    -0x230(%rbp),%rdx
lea    0xc9c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x230(%rbp,%rax,1)
movb   $0x0,-0x230(%rbp)
jmp    1340 <main+0x170>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1213 <main+0x43>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
jne    1232 <main+0x62>
lea    0xe18(%rip),%rdi
jmp    13b9 <main+0x1e9>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdda(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13be <main+0x1ee>
mov    %eax,%r13d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    %edi,0x8(%rsp)
mov    0x8(%rbx),%rsi
lea    0x4(%rsp),%rdx
call   10a0 <inet_pton@plt>
cmp    $0xffffffff,%eax
je     1284 <main+0xb4>
test   %eax,%eax
jne    1290 <main+0xc0>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13be <main+0x1ee>
lea    0xdcb(%rip),%rdi
jmp    13b9 <main+0x1e9>
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    0x2d06(%rip),%r15
mov    (%r15),%edi
mov    0x8(%rbx),%rdx
lea    0xdaa(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rsp,%rsi
mov    %r13d,%edi
mov    $0xc,%edx
call   10e0 <connect@plt>
lea    0xdc3(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe1f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
movzbl 0x10(%rsp),%eax
cmp    $0xa,%al
je     1320 <main+0x150>
test   %al,%al
jne    1334 <main+0x164>
mov    (%r15),%edi
lea    0xd7e(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
je     13a9 <main+0x1d9>
movzbl 0x10(%rsp),%eax
test   %al,%al
je     1393 <main+0x1c3>
cmp    $0xa,%al
je     1393 <main+0x1c3>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     13b2 <main+0x1e2>
mov    %eax,%ebp
mov    (%r15),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
movslq %ebp,%rax
movb   $0x0,0x10(%rsp,%rax,1)
movb   $0x0,0x10(%rsp)
jmp    12f0 <main+0x120>
mov    %r13d,%edi
call   1070 <close@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xd3d(%rip),%rdi
jmp    13b9 <main+0x1e9>
lea    0xd3d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [38 x i8] c"Invocation: %s <IPv4 ADDRESS> <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [9 x i8] c"socket()\00"
@AF_INET = global i32 0
@.str.2 = [39 x i8] c"inet_pton(): invalid network address!\0A\00"
@.str.3 = [12 x i8] c"inet_pton()\00"
@stdout = global i32 0
@.str.4 = [55 x i8] c"Sending message to %s.\0AWaiting for server response...\0A\00"
@.str.5 = [15 x i8] c"Podaj liczbe: \00"
@stdin = global i32 0
@.str.6 = [69 x i8] c"Pusta wiadomosc! Wysylamy pusta do servera i konczymy dzialanie!: %s\00"
@.str.7 = [9 x i8] c"sendto()\00"
@.str.8 = [11 x i8] c"recvfrom()\00"
@.str.9 = [23 x i8] c"Server response: '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i32, i32* @PF_INET
%24 = load i32, i32* @SOCK_DGRAM
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @AF_INET
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%41 = call i32 @inet_pton(i32 %36, i8* %39, i32* %40)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %32
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %32
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %49
br label %57
57: ; preds = %56
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = call i32 @atoi(i8* %60)
%62 = call i32 @htons(i32 %61)
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %62, i32* %63
store i32 12, i32* %9
%64 = load i32, i32* @stdout
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i8* %67)
%69 = load i32, i32* %6
%70 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%71 = load i32, i32* %9
%72 = call i32 @connect(i32 %69, %struct.sockaddr* %70, i32 %71)
br label %73
73: ; preds = %57, %123
%74 = load i32, i32* @stdout
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%76 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%77 = load i32, i32* @stdin
%78 = call i32 @fgets(i8* %76, i32 100, i32 %77)
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 0
br i1 %82, label %88, label %83
83: ; preds = %73
%84 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 10
br i1 %87, label %88, label %92
88: ; preds = %83, %73
%89 = load i32, i32* @stdout
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %88, %83
%93 = load i32, i32* %6
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%95 = call i32 @send(i32 %93, i8* %94, i32 256, i32 0)
store i32 %95, i32* %7
%96 = load i32, i32* %7
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %102
98: ; preds = %92
%99 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %92
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 0
br i1 %106, label %112, label %107
107: ; preds = %102
%108 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 10
br i1 %111, label %112, label %113
112: ; preds = %107, %102
br label %131
113: ; preds = %107
%114 = load i32, i32* %6
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%116 = call i32 @recv(i32 %114, i8* %115, i32 256, i32 0)
store i32 %116, i32* %7
%117 = load i32, i32* %7
%118 = icmp eq i32 %117, -1
br i1 %118, label %119, label %123
119: ; preds = %113
%120 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %113
%124 = load i32, i32* @stdout
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %125)
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %128
store i8 0, i8* %129
%130 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8 0, i8* %130
br label %73
131: ; preds = %112
%132 = load i32, i32* %6
%133 = call i32 @close(i32 %132)
%134 = load i32, i32* @EXIT_SUCCESS
%135 = call i32 @exit(i32 %134)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [38 x i8] c"Invocation: %s <IPv4 ADDRESS> <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [9 x i8] c"socket()\00"
@AF_INET = global i32 0
@.str.2 = [39 x i8] c"inet_pton(): invalid network address!\0A\00"
@.str.3 = [12 x i8] c"inet_pton()\00"
@stdout = global i32 0
@.str.4 = [55 x i8] c"Sending message to %s.\0AWaiting for server response...\0A\00"
@.str.5 = [15 x i8] c"Podaj liczbe: \00"
@stdin = global i32 0
@.str.6 = [69 x i8] c"Pusta wiadomosc! Wysylamy pusta do servera i konczymy dzialanie!: %s\00"
@.str.7 = [9 x i8] c"sendto()\00"
@.str.8 = [11 x i8] c"recvfrom()\00"
@.str.9 = [23 x i8] c"Server response: '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i32, i32* @PF_INET
%16 = load i32, i32* @SOCK_DGRAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
%24 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %25, i32* %26
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%30 = call i32 @inet_pton(i32 %25, i8* %28, i32* %29)
switch i32 %30, label %40 [
i32 0, label %31
i32 -1, label %36
]
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %23
%37 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %23
%41 = getelementptr inbounds i8*, i8** %1, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
%44 = call i32 @htons(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %44, i32* %45
%46 = load i32, i32* @stdout
%47 = load i8*, i8** %27
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%50 = call i32 @connect(i32 %17, %struct.sockaddr* %49, i32 12)
br label %51
51: ; preds = %76, %40
%52 = load i32, i32* @stdout
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%54 = load i32, i32* @stdin
%55 = call i32 @fgets(i8* %6, i32 100, i32 %54)
%56 = load i8, i8* %6
switch i8 %56, label %60 [
i8 10, label %57
i8 0, label %57
]
57: ; preds = %51, %51
%58 = load i32, i32* @stdout
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0), i8* %6)
br label %60
60: ; preds = %51, %57
%61 = call i32 @send(i32 %17, i8* %6, i32 256, i32 0)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %60
%68 = load i8, i8* %6
switch i8 %68, label %69 [
i8 10, label %81
i8 0, label %81
]
69: ; preds = %67
%70 = call i32 @recv(i32 %17, i8* %6, i32 256, i32 0)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %69
%77 = load i32, i32* @stdout
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%79 = sext i32 %70 to i64
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %79
store i8 0, i8* %80
store i8 0, i8* %6
br label %51
81: ; preds = %67, %67
%82 = call i32 @close(i32 %17)
%83 = load i32, i32* @EXIT_SUCCESS
%84 = call i32 @exit(i32 %83)
unreachable
}