#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 /*<<< orphan*/ server_reply;
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ message;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
char *random_message(int);
int random_priority();
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  srand(time(NULL));
  if (!argv[1] || !argv[2] || !argv[3])
    return 1;
  char *op = argv[1];
  int delay, iterations, i;
  sscanf(argv[2], "%d", &delay);
  sscanf(argv[3], "%d", &iterations);
  int socket_desc;
  struct sockaddr_in server;
  char message[2000];
  char server_reply[2000];
  socket_desc = socket(AF_INET, SOCK_STREAM, 0);
  if (socket_desc == -1) {
    printf("Could not create socket");
  }
  server.sin_addr.s_addr = inet_addr("127.0.0.1");
  server.sin_family = AF_INET;
  server.sin_port = htons(12000);
  if (connect(socket_desc, (struct sockaddr *)&server, sizeof(server)) < 0) {
    puts("connect error");
    return 1;
  }
  puts("Connected");
  for (i = 0; i < iterations; i++) {
    if (strcmp(op, "push") == 0) {
      snprintf(message, sizeof(message), "sank %s %d %s\r\n", op,
               random_priority(), random_message(10));
    } else if ((strcmp(op, "pop") == 0) || (strcmp(op, "stats") == 0) ||
               (strcmp(op, "purge") == 0)) {
      snprintf(message, sizeof(message), "sank %s\r\n", op);
    }
    printf("\nRequest: %s\n", message);
    if (send(socket_desc, message, strlen(message), 0) < 0) {
      puts("Send failed");
      return -1;
    }
    if (recv(socket_desc, server_reply, 2000, 0) < 0)
      puts("recv failed");
    printf("%s\n", server_reply);
    printf("strlen(server_reply): %zu\n", strlen(server_reply));
    printf("sizeof(server_reply): %zu\n", sizeof(server_reply));
    memset(server_reply, 0, strlen(server_reply));
    usleep(delay);
  }
  close(socket_desc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1100 <time@plt>
mov    %eax,%edi
call   10d0 <srand@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1286 <main+0x56>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1286 <main+0x56>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jne    1292 <main+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1596 <main+0x366>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd53(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1110 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd3b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1110 <sscanf@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1302 <main+0xd2>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd12(%rip),%rdi
call   10e0 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x2ee0,%edi
call   1060 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0x0,%rax
jge    135d <main+0x12d>
lea    0xcd9(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1596 <main+0x366>
lea    0xccf(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1587 <main+0x357>
mov    -0x18(%rbp),%rdi
lea    0xcb6(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    13f6 <main+0x1c6>
lea    -0x810(%rbp),%rax
mov    %rax,-0xff8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xff0(%rbp)
mov    $0x0,%al
call   1120 <random_priority@plt>
mov    %eax,-0xfe4(%rbp)
mov    $0xa,%edi
call   1090 <random_message@plt>
mov    -0xff8(%rbp),%rdi
mov    -0xff0(%rbp),%rcx
mov    -0xfe4(%rbp),%r8d
mov    %rax,%r9
mov    $0x7d0,%esi
lea    0xc58(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
jmp    1467 <main+0x237>
mov    -0x18(%rbp),%rdi
lea    0xc51(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     1444 <main+0x214>
mov    -0x18(%rbp),%rdi
lea    0xc3b(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     1444 <main+0x214>
mov    -0x18(%rbp),%rdi
lea    0xc27(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    1462 <main+0x232>
lea    -0x810(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x7d0,%esi
lea    0xc07(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
jmp    1467 <main+0x237>
lea    -0x810(%rbp),%rsi
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x1004(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x1000(%rbp)
lea    -0x810(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1004(%rbp),%edi
mov    -0x1000(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0x0,%rax
jge    14d7 <main+0x2a7>
lea    0xbb4(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1596 <main+0x366>
mov    -0x28(%rbp),%edi
lea    -0xfe0(%rbp),%rsi
mov    $0x7d0,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jge    1503 <main+0x2d3>
lea    0xb88(%rip),%rdi
call   1040 <puts@plt>
lea    -0xfe0(%rbp),%rsi
lea    0xb65(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xfe0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
lea    0xb65(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb72(%rip),%rdi
mov    $0x7d0,%esi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xfe0(%rbp),%rax
mov    %rax,-0x1010(%rbp)
lea    -0xfe0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1010(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
mov    -0x1c(%rbp),%edi
call   1140 <usleep@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1370 <main+0x140>
mov    -0x28(%rbp),%edi
call   10c0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfc8,%rsp
mov    %rsi,%rbp
xor    %edi,%edi
call   1100 <time@plt>
mov    %eax,%edi
call   10d0 <srand@plt>
mov    0x8(%rbp),%r15
mov    $0x1,%eax
test   %r15,%r15
je     14ce <main+0x29e>
mov    0x10(%rbp),%rdi
test   %rdi,%rdi
je     14ce <main+0x29e>
cmpq   $0x0,0x18(%rbp)
je     14ce <main+0x29e>
lea    0xd7d(%rip),%r14
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
call   1110 <sscanf@plt>
mov    0x18(%rbp),%rdi
lea    0x4(%rsp),%rdx
mov    %r14,%rsi
call   1110 <sscanf@plt>
mov    0x2d40(%rip),%r14
mov    (%r14),%edi
mov    0x2d26(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    12d0 <main+0xa0>
lea    0xd3a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd44(%rip),%rdi
call   10e0 <inet_addr@plt>
mov    %eax,0x18(%rsp)
mov    (%r14),%eax
mov    %eax,0x14(%rsp)
mov    $0x2ee0,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1130 <connect@plt>
test   %rax,%rax
js     14aa <main+0x27a>
lea    0xd1d(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    149f <main+0x26f>
lea    0x7f0(%rsp),%rbx
lea    0xd37(%rip),%r12
xor    %r13d,%r13d
mov    %ebp,0x8(%rsp)
jmp    139f <main+0x16f>
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xd3b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x7d0,%esi
lea    0xd41(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   10b0 <memset@plt>
mov    0xc(%rsp),%edi
call   1140 <usleep@plt>
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
jge    149f <main+0x26f>
mov    %r15,%rdi
lea    0xc94(%rip),%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
je     1410 <main+0x1e0>
mov    %r15,%rdi
lea    0xc95(%rip),%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0x1c0>
mov    %r15,%rdi
lea    0xc85(%rip),%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0x1c0>
mov    %r15,%rdi
lea    0xc77(%rip),%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1447 <main+0x217>
nop
mov    %rbx,%rdi
mov    $0x7d0,%esi
lea    0xc63(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   10a0 <snprintf@plt>
jmp    1447 <main+0x217>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1120 <random_priority@plt>
mov    %eax,%r14d
mov    $0xa,%edi
call   1090 <random_message@plt>
mov    %rbx,%rdi
mov    $0x7d0,%esi
lea    0xc0f(%rip),%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
mov    0x8(%rsp),%ebp
mov    %rax,%r9
xor    %eax,%eax
call   10a0 <snprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
js     14bd <main+0x28d>
mov    %ebp,%edi
lea    0x20(%rsp),%r14
mov    %r14,%rsi
mov    $0x7d0,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jns    1340 <main+0x110>
lea    0xbf1(%rip),%rdi
call   1040 <puts@plt>
jmp    1340 <main+0x110>
mov    %ebp,%edi
call   10c0 <close@plt>
xor    %eax,%eax
jmp    14ce <main+0x29e>
lea    0xb74(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    14ce <main+0x29e>
lea    0xbb6(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0xfc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [24 x i8] c"Could not create socket\00"
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [14 x i8] c"connect error\00"
@.str.4 = [10 x i8] c"Connected\00"
@.str.5 = [5 x i8] c"push\00"
@.str.6 = [16 x i8] c"sank %s %d %s\0D\0A\00"
@.str.7 = [4 x i8] c"pop\00"
@.str.8 = [6 x i8] c"stats\00"
@.str.9 = [6 x i8] c"purge\00"
@.str.10 = [10 x i8] c"sank %s\0D\0A\00"
@.str.11 = [14 x i8] c"\0ARequest: %s\0A\00"
@.str.12 = [12 x i8] c"Send failed\00"
@.str.13 = [12 x i8] c"recv failed\00"
@.str.14 = [4 x i8] c"%s\0A\00"
@.str.15 = [27 x i8] c"strlen(server_reply): %zu\0A\00"
@.str.16 = [27 x i8] c"sizeof(server_reply): %zu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%12 = alloca [2000 x i8]
%13 = alloca [2000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %30
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %25, %20, %2
store i32 1, i32* %3
br label %134
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
store i8* %34, i8** %6
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @sscanf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%43 = load i32, i32* @AF_INET
%44 = load i32, i32* @SOCK_STREAM
%45 = call i32 @socket(i32 %43, i32 %44, i32 0)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %31
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %48, %31
%51 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
%53 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %52, i32 0, i32 0
store i32 %51, i32* %53
%54 = load i32, i32* @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %54, i32* %55
%56 = call i32 @htons(i32 12000)
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %56, i32* %57
%58 = load i32, i32* %10
%59 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%60 = call i64 @connect(i32 %58, %struct.sockaddr* %59, i32 12)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %50
%63 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %134
64: ; preds = %50
%65 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %9
br label %66
66: ; preds = %128, %64
%67 = load i32, i32* %9
%68 = load i32, i32* %8
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %131
70: ; preds = %66
%71 = load i8*, i8** %6
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %70
%75 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%76 = load i8*, i8** %6
%77 = call i32 (...) @random_priority()
%78 = call i8* @random_message(i32 10)
%79 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %75, i32 2000, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %76, i32 %77, i8* %78)
br label %97
80: ; preds = %70
%81 = load i8*, i8** %6
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %92, label %84
84: ; preds = %80
%85 = load i8*, i8** %6
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %92, label %88
88: ; preds = %84
%89 = load i8*, i8** %6
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %88, %84, %80
%93 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%94 = load i8*, i8** %6
%95 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %93, i32 2000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %94)
br label %96
96: ; preds = %92, %88
br label %97
97: ; preds = %96, %74
%98 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %98)
%100 = load i32, i32* %10
%101 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%102 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%103 = call i32 @strlen(i8* %102)
%104 = call i64 @send(i32 %100, i8* %101, i32 %103, i32 0)
%105 = icmp slt i64 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %97
%107 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
108: ; preds = %97
%109 = load i32, i32* %10
%110 = getelementptr inbounds [2000 x i8], [2000 x i8]* %13, i64 0, i64 0
%111 = call i64 @recv(i32 %109, i8* %110, i32 2000, i32 0)
%112 = icmp slt i64 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %108
%114 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %115
115: ; preds = %113, %108
%116 = getelementptr inbounds [2000 x i8], [2000 x i8]* %13, i64 0, i64 0
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %116)
%118 = getelementptr inbounds [2000 x i8], [2000 x i8]* %13, i64 0, i64 0
%119 = call i32 @strlen(i8* %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i32 %119)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i64 2000)
%122 = getelementptr inbounds [2000 x i8], [2000 x i8]* %13, i64 0, i64 0
%123 = getelementptr inbounds [2000 x i8], [2000 x i8]* %13, i64 0, i64 0
%124 = call i32 @strlen(i8* %123)
%125 = call i32 @memset(i8* %122, i32 0, i32 %124)
%126 = load i32, i32* %7
%127 = call i32 @usleep(i32 %126)
br label %128
128: ; preds = %115
%129 = load i32, i32* %9
%130 = add nsw i32 %129, 1
store i32 %130, i32* %9
br label %66
131: ; preds = %66
%132 = load i32, i32* %10
%133 = call i32 @close(i32 %132)
store i32 0, i32* %3
br label %134
134: ; preds = %131, %106, %62, %30
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [24 x i8] c"Could not create socket\00"
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [14 x i8] c"connect error\00"
@.str.4 = [10 x i8] c"Connected\00"
@.str.5 = [5 x i8] c"push\00"
@.str.6 = [16 x i8] c"sank %s %d %s\0D\0A\00"
@.str.7 = [4 x i8] c"pop\00"
@.str.8 = [6 x i8] c"stats\00"
@.str.9 = [6 x i8] c"purge\00"
@.str.10 = [10 x i8] c"sank %s\0D\0A\00"
@.str.11 = [14 x i8] c"\0ARequest: %s\0A\00"
@.str.12 = [12 x i8] c"Send failed\00"
@.str.13 = [12 x i8] c"recv failed\00"
@.str.15 = [27 x i8] c"strlen(server_reply): %zu\0A\00"
@.str.16 = [27 x i8] c"sizeof(server_reply): %zu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca [2000 x i8]
%7 = alloca [2000 x i8]
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %99, label %13
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %99, label %17
17: ; preds = %13
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %99, label %21
21: ; preds = %17
%22 = bitcast i32* %3 to i8*
%23 = bitcast i32* %4 to i8*
%24 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i8*, i8** %18
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%27 = bitcast %struct.sockaddr_in* %5 to i8*
%28 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%30 = load i32, i32* @AF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %21
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %21
%37 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %39, i32* %40
%41 = call i32 @htons(i32 12000)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %41, i32* %42
%43 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%44 = call i64 @connect(i32 %32, %struct.sockaddr* %43, i32 12)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %36
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %97
48: ; preds = %36
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* %4
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %95
52: ; preds = %48, %83
%53 = phi i32 [ %92, %83 ], [ 0, %48 ]
%54 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = call i32 (...) @random_priority()
%58 = call i8* @random_message(i32 10)
%59 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %28, i32 2000, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %11, i32 %57, i8* %58)
br label %71
60: ; preds = %52
%61 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %69, label %63
63: ; preds = %60
%64 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %66, %63, %60
%70 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %28, i32 2000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %11)
br label %71
71: ; preds = %66, %69, %56
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %28)
%73 = call i32 @strlen(i8* %28)
%74 = call i64 @send(i32 %32, i8* %28, i32 %73, i32 0)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %97
78: ; preds = %71
%79 = call i64 @recv(i32 %32, i8* %29, i32 2000, i32 0)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
%84 = call i32 @puts(i8* %29)
%85 = call i32 @strlen(i8* %29)
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i32 %85)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i64 2000)
%88 = call i32 @strlen(i8* %29)
%89 = call i32 @memset(i8* %29, i32 0, i32 %88)
%90 = load i32, i32* %3
%91 = call i32 @usleep(i32 %90)
%92 = add nuw nsw i32 %53, 1
%93 = load i32, i32* %4
%94 = icmp slt i32 %92, %93
br i1 %94, label %52, label %95
95: ; preds = %83, %48
%96 = call i32 @close(i32 %32)
br label %97
97: ; preds = %95, %76, %46
%98 = phi i32 [ 1, %46 ], [ -1, %76 ], [ 0, %95 ]
br label %99
99: ; preds = %2, %13, %17, %97
%100 = phi i32 [ %98, %97 ], [ 1, %17 ], [ 1, %13 ], [ 1, %2 ]
ret i32 %100
}