#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 */
typedef int /*<<< orphan*/ tv;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ sendbuf;
typedef int /*<<< orphan*/ recvbuf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ printf(char *);
int readMessage(int, char *, int, struct sockaddr *, int);
int sendMessage(int, char *, int, struct sockaddr *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              struct timeval *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("usage: client <IPaddress> <Port>\n");
    exit(1);
  }
  int sockfd, msg, attempts, success;
  char recvbuf[1024];
  struct sockaddr_in servaddr;
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = inet_addr(argv[1]);
  servaddr.sin_port = htons(atoi(argv[2]));
  if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    printf("Call to socket failed\n");
    exit(1);
  }
  struct timeval tv;
  tv.tv_sec = 10;
  tv.tv_usec = 0;
  setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
  char sendbuf[] = {
      0x16, 0x06, 0xfe, 0xff, 0xcf, 0xe0, 0x21, 0x16, 0x06, 0x03, 0x00, 0x20,
      0x01, 0x00, 0xfb, 0x06, 0x01, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
      0xfb, 0x3e, 0x02, 0x00, 0x04, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04,
      0x00, 0x00, 0x00, 0x45, 0x51, 0x4f, 0x41, 0x0a, 0x00, 0x00, 0x00, 0x6b,
      0x69, 0x65, 0x73, 0x68, 0x61, 0x65, 0x73, 0x68, 0x61, 0x01, 0xfa, 0x10,
      0x69, 0x22, 0x1c, 0xd4, 0x45, 0xbc, 0xfd, 0x68, 0x3c, 0x56, 0x22, 0x87,
      0xd9, 0x70, 0xb7, 0x1c, 0x12, 0xae, 0x76, 0xc4, 0x98, 0xfd, 0xf3, 0xce,
      0xeb, 0x44, 0x4a, 0x0a, 0x49, 0xb5, 0xcb, 0x2e, 0xa2, 0x49};
  attempts = 5;
  success = 0;
  while (attempts > 0 && !success) {
    if ((msg = sendMessage(sockfd, sendbuf, sizeof(sendbuf),
                           (struct sockaddr *)&servaddr, sizeof(servaddr))) !=
        0) {
      printf("Function sendMessage failed\n");
      exit(1);
    }
    if ((msg = readMessage(sockfd, recvbuf, sizeof(recvbuf),
                           (struct sockaddr *)&servaddr, sizeof(servaddr))) ==
        0) {
      printf("Success!\n");
      success = 1;
    } else if (msg == 1) {
      printf("Function readMessage failed\n");
      exit(1);
    }
    attempts -= 1;
  }
  close(sockfd);
  if (attempts == 0) {
    printf("Your attempts were unsuccessful\n");
    return 1;
  } else {
    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)
cmpl   $0x3,-0x8(%rbp)
je     11f9 <main+0x39>
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x430(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <bzero@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,-0x430(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1281 <main+0xc1>
lea    0xdb0(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0xa,-0x440(%rbp)
movq   $0x0,-0x438(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    0x2d1f(%rip),%rax
mov    (%rax),%edx
lea    -0x440(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
lea    -0x4a0(%rbp),%rdi
lea    0xdd5(%rip),%rsi
mov    $0x5e,%edx
call   1090 <memcpy@plt>
movl   $0x5,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x4a1(%rbp)
jle    1304 <main+0x144>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x4a1(%rbp)
mov    -0x4a1(%rbp),%al
test   $0x1,%al
jne    1317 <main+0x157>
jmp    13d2 <main+0x212>
mov    -0x14(%rbp),%edi
lea    -0x4a0(%rbp),%rsi
lea    -0x430(%rbp),%rcx
mov    $0x5e,%edx
mov    $0xc,%r8d
call   10a0 <sendMessage@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     135a <main+0x19a>
lea    0xcee(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
lea    -0x430(%rbp),%rcx
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    139f <main+0x1df>
lea    0xcc8(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x20(%rbp)
jmp    13c4 <main+0x204>
cmpl   $0x1,-0x18(%rbp)
jne    13bf <main+0x1ff>
lea    0xcb0(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    13c4 <main+0x204>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12e3 <main+0x123>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    13fc <main+0x23c>
lea    0xc92(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1403 <main+0x243>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x488,%rsp
cmp    $0x3,%edi
jne    146f <main+0x2bf>
mov    %rsi,%rbx
mov    %rsp,%rdi
mov    $0xc,%esi
call   10a0 <bzero@plt>
mov    0x2e06(%rip),%r14
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
test   %eax,%eax
js     1478 <main+0x2c8>
mov    %eax,%ebx
movl   $0xa,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
mov    0x2d89(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
movups 0xdf4(%rip),%xmm0
movups %xmm0,0x6e(%rsp)
movaps 0xdda(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xdbe(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xda2(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xd86(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xd6a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x5e,%edx
mov    $0xc,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1466 <main+0x2b6>
lea    0x80(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
test   %eax,%eax
je     1420 <main+0x270>
cmp    $0x1,%eax
je     1417 <main+0x267>
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x5e,%edx
mov    $0xc,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1466 <main+0x2b6>
lea    0x80(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
test   %eax,%eax
je     1420 <main+0x270>
cmp    $0x1,%eax
je     1417 <main+0x267>
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x5e,%edx
mov    $0xc,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1466 <main+0x2b6>
lea    0x80(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
test   %eax,%eax
je     1420 <main+0x270>
cmp    $0x1,%eax
je     1417 <main+0x267>
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x5e,%edx
mov    $0xc,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1466 <main+0x2b6>
lea    0x80(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
test   %eax,%eax
je     1420 <main+0x270>
cmp    $0x1,%eax
je     1417 <main+0x267>
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x5e,%edx
mov    $0xc,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1466 <main+0x2b6>
lea    0x80(%rsp),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x400,%edx
mov    $0xc,%r8d
call   1080 <readMessage@plt>
test   %eax,%eax
je     1440 <main+0x290>
cmp    $0x1,%eax
jne    144c <main+0x29c>
lea    0xc60(%rip),%rdi
jmp    147f <main+0x2cf>
lea    0xc73(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r14
ret
lea    0xc53(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
lea    0xc04(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1435 <main+0x285>
lea    0xc36(%rip),%rdi
jmp    147f <main+0x2cf>
lea    0xc5f(%rip),%rdi
jmp    147f <main+0x2cf>
lea    0xc40(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"usage: client <IPaddress> <Port>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [23 x i8] c"Call to socket failed\0A\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@__const.main.sendbuf = [94 x i8] c"\16\06\FE\FF\CF\E0!\16\06\03\00 \01\00\FB\06\01\00\00\00%\00\00\00\FB>\02\00\04\09\00\03\00\00\00\04\00\00\00EQOA\0A\00\00\00kieshaesha\01\FA\10i\22\1C\D4E\BC\FDh<V\22\87\D9p\B7\1C\12\AEv\C4\98\FD\F3\CE\EBDJ\0AI\B5\CB.\A2I"
@.str.2 = [29 x i8] c"Function sendMessage failed\0A\00"
@.str.3 = [10 x i8] c"Success!\0A\00"
@.str.4 = [29 x i8] c"Function readMessage failed\0A\00"
@.str.5 = [33 x i8] c"Your attempts were unsuccessful\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8]
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.timeval
%13 = alloca [94 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = call i32 @bzero(%struct.sockaddr_in* %11, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @inet_addr(i8* %25)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
store i32 %26, i32* %28
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = call i32 @htons(i32 %32)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %33, i32* %34
%35 = load i32, i32* @AF_INET
%36 = load i32, i32* @SOCK_DGRAM
%37 = call i32 @socket(i32 %35, i32 %36, i32 0)
store i32 %37, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %19
%40 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %19
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 10, i32* %43
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store i64 0, i64* %44
%45 = load i32, i32* %6
%46 = load i32, i32* @SOL_SOCKET
%47 = load i32, i32* @SO_RCVTIMEO
%48 = call i32 @setsockopt(i32 %45, i32 %46, i32 %47, %struct.timeval* %12, i32 16)
%49 = bitcast [94 x i8]* %13 to i8*
store i32 5, i32* %8
store i32 0, i32* %9
br label %50
50: ; preds = %83, %42
%51 = load i32, i32* %8
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* %9
%55 = icmp ne i32 %54, 0
%56 = xor i1 %55, true
br label %57
57: ; preds = %53, %50
%58 = phi i1 [ false, %50 ], [ %56, %53 ]
br i1 %58, label %59, label %86
59: ; preds = %57
%60 = load i32, i32* %6
%61 = getelementptr inbounds [94 x i8], [94 x i8]* %13, i64 0, i64 0
%62 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%63 = call i32 @sendMessage(i32 %60, i8* %61, i32 94, %struct.sockaddr* %62, i32 12)
store i32 %63, i32* %7
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %59
%66 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %59
%69 = load i32, i32* %6
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%71 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%72 = call i32 @readMessage(i32 %69, i8* %70, i32 1024, %struct.sockaddr* %71, i32 12)
store i32 %72, i32* %7
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %68
%75 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %9
br label %83
76: ; preds = %68
%77 = load i32, i32* %7
%78 = icmp eq i32 %77, 1
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %76
br label %83
83: ; preds = %82, %74
%84 = load i32, i32* %8
%85 = sub nsw i32 %84, 1
store i32 %85, i32* %8
br label %50
86: ; preds = %57
%87 = load i32, i32* %6
%88 = call i32 @close(i32 %87)
%89 = load i32, i32* %8
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %86
%92 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %94
93: ; preds = %86
store i32 0, i32* %3
br label %94
94: ; preds = %93, %91
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@__const.main.sendbuf = [94 x i8] c"\16\06\FE\FF\CF\E0!\16\06\03\00 \01\00\FB\06\01\00\00\00%\00\00\00\FB>\02\00\04\09\00\03\00\00\00\04\00\00\00EQOA\0A\00\00\00kieshaesha\01\FA\10i\22\1C\D4E\BC\FDh<V\22\87\D9p\B7\1C\12\AEv\C4\98\FD\F3\CE\EBDJ\0AI\B5\CB.\A2I"
@str = [32 x i8] c"Your attempts were unsuccessful\00"
@str.6 = [28 x i8] c"Function readMessage failed\00"
@str.7 = [9 x i8] c"Success!\00"
@str.8 = [28 x i8] c"Function sendMessage failed\00"
@str.9 = [22 x i8] c"Call to socket failed\00"
@str.10 = [33 x i8] c"usage: client <IPaddress> <Port>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.timeval
%6 = alloca [94 x i8]
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = bitcast %struct.sockaddr_in* %4 to i8*
%14 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %15, i32* %16
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @inet_addr(i8* %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %19, i32* %20
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = tail call i32 @htons(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_DGRAM
%28 = tail call i32 @socket(i32 %26, i32 %27, i32 0)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %11
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %11
%34 = bitcast %struct.timeval* %5 to i8*
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 10, i32* %35
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %36
%37 = load i32, i32* @SOL_SOCKET
%38 = load i32, i32* @SO_RCVTIMEO
%39 = call i32 @setsockopt(i32 %28, i32 %37, i32 %38, %struct.timeval* %5, i32 16)
%40 = getelementptr inbounds [94 x i8], [94 x i8]* %6, i64 0, i64 0
%41 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%42 = call i32 @sendMessage(i32 %28, i8* %40, i32 94, %struct.sockaddr* %41, i32 12)
%43 = icmp eq i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %70, %65, %60, %55, %33
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %33
%48 = call i32 @readMessage(i32 %28, i8* %12, i32 1024, %struct.sockaddr* %41, i32 12)
switch i32 %48, label %55 [
i32 0, label %49
i32 1, label %52
]
49: ; preds = %68, %63, %58, %47
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%51 = call i32 @close(i32 %28)
br label %82
52: ; preds = %73, %68, %63, %58, %47
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %47
%56 = call i32 @sendMessage(i32 %28, i8* %40, i32 94, %struct.sockaddr* %41, i32 12)
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %44
58: ; preds = %55
%59 = call i32 @readMessage(i32 %28, i8* %12, i32 1024, %struct.sockaddr* %41, i32 12)
switch i32 %59, label %60 [
i32 0, label %49
i32 1, label %52
]
60: ; preds = %58
%61 = call i32 @sendMessage(i32 %28, i8* %40, i32 94, %struct.sockaddr* %41, i32 12)
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %44
63: ; preds = %60
%64 = call i32 @readMessage(i32 %28, i8* %12, i32 1024, %struct.sockaddr* %41, i32 12)
switch i32 %64, label %65 [
i32 0, label %49
i32 1, label %52
]
65: ; preds = %63
%66 = call i32 @sendMessage(i32 %28, i8* %40, i32 94, %struct.sockaddr* %41, i32 12)
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %44
68: ; preds = %65
%69 = call i32 @readMessage(i32 %28, i8* %12, i32 1024, %struct.sockaddr* %41, i32 12)
switch i32 %69, label %70 [
i32 0, label %49
i32 1, label %52
]
70: ; preds = %68
%71 = call i32 @sendMessage(i32 %28, i8* %40, i32 94, %struct.sockaddr* %41, i32 12)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %44
73: ; preds = %70
%74 = call i32 @readMessage(i32 %28, i8* %12, i32 1024, %struct.sockaddr* %41, i32 12)
switch i32 %74, label %75 [
i32 0, label %77
i32 1, label %52
]
75: ; preds = %73
%76 = call i32 @close(i32 %28)
br label %80
77: ; preds = %73
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%79 = call i32 @close(i32 %28)
br label %80
80: ; preds = %77, %75
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %82
82: ; preds = %49, %80
%83 = phi i32 [ 1, %80 ], [ 0, %49 ]
ret i32 %83
}