#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int type;
  int /*<<< orphan*/ instance;
};
struct TYPE_5__ {
  int /*<<< orphan*/ domain;
  TYPE_1__ name;
};
struct TYPE_6__ {
  TYPE_2__ name;
};
struct sockaddr_tipc {
  TYPE_3__ addr;
  int /*<<< orphan*/ addrtype;
  int /*<<< orphan*/ family;
};
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ off;

/* Variables and functions */
int /*<<< orphan*/ AF_TIPC;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_RDM;
int /*<<< orphan*/ SOL_TIPC;
int /*<<< orphan*/ TIPC_ADDR_NAME;
int /*<<< orphan*/ TIPC_DEST_DROPPABLE;
void *atoi(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
int getpid();
char *malloc(size_t);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int const *,
                      int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ transaction_send(int, struct sockaddr_tipc *, char *, size_t,
                                    size_t);
scalar_t__ wait(int *);
int main(int argc, char *argv[]) {
  struct sockaddr_tipc sa_remote = {.family = AF_TIPC,
                                    .addrtype = TIPC_ADDR_NAME,
                                    .addr.name.name.type = 1234,
                                    .addr.name.name.instance = 0,
                                    .addr.name.domain = 0};
  size_t bufsize = 65535;
  size_t segsize = 512;
  int c;
  int nclients = 1;
  int iterations = 1;
  int sid;
  int i = 0;
  while ((c = getopt(argc, argv, "hn:i:t:s:")) != -1) {
    switch (c) {
    case 'n':
      nclients = atoi(optarg);
      break;
    case 'i':
      iterations = atoi(optarg);
      break;
    case 't':
      bufsize = atoi(optarg);
      break;
    case 's':
      segsize = atoi(optarg);
      break;
    case 'h':
    default:
      printf("Usage: %s\n", argv[0]);
      printf("-n <number of clients>\n");
      printf("-i <iterations>\n");
      printf("-t <bufsize in bytes>\n");
      printf("-s <segment size in bytes>\n");
      return -1;
      break;
    }
  }
  printf("Running %d iterations on %d clients\n", iterations, nclients);
  printf("Transaction size = %d bytes\n", (int)bufsize);
  printf("Segment size=%d bytes\n", (int)segsize);
  srand(time(NULL));
  while (i++ < nclients) {
    {
      printf("Client %d: ", getpid());
      printf("Spawned %d\n", i);
    };
    if (!fork()) {
      int sd;
      char *buf = malloc(bufsize);
      int k = iterations;
      if (!buf) {
        perror("malloc()");
        return EXIT_FAILURE;
      }
      sd = socket(AF_TIPC, SOCK_RDM, 0);
      static const int off = 0;
      if (setsockopt(sd, SOL_TIPC, TIPC_DEST_DROPPABLE, &off, sizeof(off)) !=
          0) {
        perror("setsockopt");
        return EXIT_FAILURE;
      }
      while (k-- > 0) {
        {
          printf("Client %d: ", getpid());
          printf("iteration %d\n", iterations);
        };
        if (!transaction_send(sd, &sa_remote, buf, bufsize, segsize)) {
          {
            printf("Client %d: ", getpid());
            printf("transaction_send error");
          };
          close(sd);
          free(buf);
          return EXIT_FAILURE;
        }
      }
      {
        printf("Client %d: ", getpid());
        printf("Finished transmission successfully\n");
      };
      close(sd);
      free(buf);
      return EXIT_SUCCESS;
    }
  }
  pid_t wpid;
  int wstatus;
  while ((wpid = wait(&wstatus)) > 0) {
    printf("Exit status of %d was %d (%s)\n", (int)wpid, wstatus,
           (wstatus >= 0) ? "OK" : "FAIL");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x4d2,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0xffff,-0x30(%rbp)
movq   $0x200,-0x38(%rbp)
movl   $0x1,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdcf(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     1360 <main+0x170>
mov    -0x3c(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0xc,%eax
ja     1302 <main+0x112>
mov    -0x78(%rbp),%rax
lea    0xd66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   10e0 <atoi@plt>
mov    %eax,-0x40(%rbp)
jmp    135b <main+0x16b>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
call   10e0 <atoi@plt>
mov    %eax,-0x44(%rbp)
jmp    135b <main+0x16b>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
call   10e0 <atoi@plt>
mov    %rax,-0x30(%rbp)
jmp    135b <main+0x16b>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   10e0 <atoi@plt>
mov    %rax,-0x38(%rbp)
jmp    135b <main+0x16b>
jmp    1302 <main+0x112>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15f3 <main+0x403>
jmp    125b <main+0x6b>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %eax,%esi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x4c(%rbp)
cmp    -0x40(%rbp),%eax
jge    1597 <main+0x3a7>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1100 <fork@plt>
cmp    $0x0,%eax
jne    1592 <main+0x3a2>
mov    -0x30(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1433 <main+0x243>
lea    0xcfd(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2b97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <main+0x403>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
mov    0x2b6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edi
mov    0x2b77(%rip),%rax
mov    (%rax),%esi
mov    0x2b76(%rip),%rax
mov    (%rax),%edx
lea    0xbc9(%rip),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
je     149d <main+0x2ad>
lea    0xc9c(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2b2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <main+0x403>
jmp    14a2 <main+0x2b2>
mov    -0x5c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x5c(%rbp)
cmp    $0x0,%eax
jle    154b <main+0x35b>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
lea    -0x28(%rbp),%rsi
call   1030 <transaction_send@plt>
cmp    $0x0,%eax
jne    1546 <main+0x356>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2a84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <main+0x403>
jmp    14a2 <main+0x2b2>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2a20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <main+0x403>
jmp    13ac <main+0x1bc>
jmp    159c <main+0x3ac>
lea    -0x6c(%rbp),%rdi
call   10f0 <wait@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jle    15e7 <main+0x3f7>
mov    -0x68(%rbp),%rax
mov    %eax,%esi
mov    -0x6c(%rbp),%edx
mov    -0x6c(%rbp),%edi
lea    0xbd3(%rip),%rcx
lea    0xbc9(%rip),%rax
cmp    $0x0,%edi
cmovge %rax,%rcx
lea    0xb9c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    159c <main+0x3ac>
mov    0x29ba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movabs $0x4d200000000,%rax
mov    %rax,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    $0xffff,%r13d
mov    $0x200,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%eax
mov    %rax,0x8(%rsp)
lea    0xd9b(%rip),%r14
mov    0x2d8c(%rip),%r15
mov    $0x1,%r12d
jmp    128b <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
call   10f0 <atoi@plt>
mov    %rax,%r13
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
cmp    $0x74,%eax
je     1280 <main+0x80>
cmp    $0x6d,%eax
jg     12bf <main+0xbf>
cmp    $0xffffffff,%eax
je     12e9 <main+0xe9>
cmp    $0x69,%eax
jne    149c <main+0x29c>
mov    (%r15),%edi
call   10f0 <atoi@plt>
mov    %rax,0x8(%rsp)
jmp    128b <main+0x8b>
cmp    $0x73,%eax
je     12da <main+0xda>
cmp    $0x6e,%eax
jne    149c <main+0x29c>
mov    (%r15),%edi
call   10f0 <atoi@plt>
mov    %rax,%r12
jmp    128b <main+0x8b>
mov    (%r15),%edi
call   10f0 <atoi@plt>
mov    %rax,0x18(%rsp)
jmp    128b <main+0x8b>
lea    0xd25(%rip),%rdi
xor    %ebx,%ebx
mov    0x8(%rsp),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd32(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd3e(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   10a0 <srand@plt>
test   %r12d,%r12d
cmovle %ebx,%r12d
neg    %r12d
mov    $0x1,%ebx
lea    0xd25(%rip),%r14
lea    0xd2a(%rip),%rbp
lea    (%r12,%rbx,1),%eax
cmp    $0x1,%eax
je     14e7 <main+0x2e7>
xor    %eax,%eax
call   1070 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1110 <fork@plt>
add    $0x1,%ebx
test   %eax,%eax
jne    1350 <main+0x150>
mov    %r13,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1582 <main+0x382>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
mov    0x2c00(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%ebx
mov    0x2c0e(%rip),%rax
mov    (%rax),%esi
mov    0x2c0d(%rip),%rax
mov    (%rax),%edx
lea    0xd90(%rip),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
test   %rax,%rax
jne    158b <main+0x38b>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%r12d
lea    0xc74(%rip),%r14
lea    0xc99(%rip),%rbp
lea    0x20(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%r12d
xor    %eax,%eax
test   %r12d,%r12d
jle    1538 <main+0x338>
call   1070 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    0x18(%rsp),%r8
call   1030 <transaction_send@plt>
test   %eax,%eax
jne    1410 <main+0x210>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xc06(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc30(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    0x2b29(%rip),%rax
jmp    1571 <main+0x371>
mov    (%rbx),%rsi
lea    0xb64(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc55(%rip),%rdi
call   1050 <puts@plt>
lea    0xc60(%rip),%rdi
call   1050 <puts@plt>
lea    0xc64(%rip),%rdi
call   1050 <puts@plt>
lea    0xc6e(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
jmp    1573 <main+0x373>
lea    0x4(%rsp),%rdi
call   1100 <wait@plt>
test   %rax,%rax
jle    156a <main+0x36a>
lea    0xbe1(%rip),%r14
lea    0xbdd(%rip),%r15
lea    0xbb4(%rip),%rbx
lea    0x4(%rsp),%rbp
mov    0x4(%rsp),%edx
test   %edx,%edx
mov    %r15,%rcx
cmovns %r14,%rcx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
call   1100 <wait@plt>
test   %rax,%rax
jg     1510 <main+0x310>
jmp    156a <main+0x36a>
call   1070 <getpid@plt>
lea    0xb2a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb92(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    0x2a37(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xafd(%rip),%rdi
jmp    1592 <main+0x392>
lea    0xafd(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2a22(%rip),%rax
jmp    1571 <main+0x371>

LLVM IR (-O0):
%struct.sockaddr_tipc = type { %struct.TYPE_6__, i32, i32 }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32 }
@TIPC_ADDR_NAME = global i32 0
@AF_TIPC = global i32 0
@.str = [10 x i8] c"hn:i:t:s:\00"
@optarg = global i32 0
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@.str.2 = [24 x i8] c"-n <number of clients>\0A\00"
@.str.3 = [17 x i8] c"-i <iterations>\0A\00"
@.str.4 = [23 x i8] c"-t <bufsize in bytes>\0A\00"
@.str.5 = [28 x i8] c"-s <segment size in bytes>\0A\00"
@.str.6 = [37 x i8] c"Running %d iterations on %d clients\0A\00"
@.str.7 = [29 x i8] c"Transaction size = %d bytes\0A\00"
@.str.8 = [23 x i8] c"Segment size=%d bytes\0A\00"
@.str.9 = [12 x i8] c"Client %d: \00"
@.str.10 = [12 x i8] c"Spawned %d\0A\00"
@.str.11 = [9 x i8] c"malloc()\00"
@EXIT_FAILURE = global i32 0
@SOCK_RDM = global i32 0
@main.off = internal constant i32 0
@SOL_TIPC = global i32 0
@TIPC_DEST_DROPPABLE = global i32 0
@.str.12 = [11 x i8] c"setsockopt\00"
@.str.13 = [14 x i8] c"iteration %d\0A\00"
@.str.14 = [23 x i8] c"transaction_send error\00"
@.str.15 = [36 x i8] c"Finished transmission successfully\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.16 = [31 x i8] c"Exit status of %d was %d (%s)\0A\00"
@.str.17 = [3 x i8] c"OK\00"
@.str.18 = [5 x i8] c"FAIL\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_tipc
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %6, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
store i32 0, i32* %21
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 0
store i32 1234, i32* %23
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 1
store i32 0, i32* %24
%25 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %6, i32 0, i32 1
%26 = load i32, i32* @TIPC_ADDR_NAME
store i32 %26, i32* %25
%27 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %6, i32 0, i32 2
%28 = load i32, i32* @AF_TIPC
store i32 %28, i32* %27
store i64 65535, i64* %7
store i64 512, i64* %8
store i32 1, i32* %10
store i32 1, i32* %11
store i32 0, i32* %13
br label %29
29: ; preds = %62, %2
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @getopt(i32 %30, i8** %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %32, i32* %9
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %63
34: ; preds = %29
%35 = load i32, i32* %9
switch i32 %35, label %53 [
i32 110, label %36
i32 105, label %40
i32 116, label %44
i32 115, label %48
i32 104, label %52
]
36: ; preds = %34
%37 = load i32, i32* @optarg
%38 = call i8* @atoi(i32 %37)
%39 = ptrtoint i8* %38 to i32
store i32 %39, i32* %10
br label %62
40: ; preds = %34
%41 = load i32, i32* @optarg
%42 = call i8* @atoi(i32 %41)
%43 = ptrtoint i8* %42 to i32
store i32 %43, i32* %11
br label %62
44: ; preds = %34
%45 = load i32, i32* @optarg
%46 = call i8* @atoi(i32 %45)
%47 = ptrtoint i8* %46 to i64
store i64 %47, i64* %7
br label %62
48: ; preds = %34
%49 = load i32, i32* @optarg
%50 = call i8* @atoi(i32 %49)
%51 = ptrtoint i8* %50 to i64
store i64 %51, i64* %8
br label %62
52: ; preds = %34
br label %53
53: ; preds = %34, %52
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %159
62: ; preds = %48, %44, %40, %36
br label %29
63: ; preds = %29
%64 = load i32, i32* %11
%65 = load i32, i32* %10
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %64, i32 %65)
%67 = load i64, i64* %7
%68 = trunc i64 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %68)
%70 = load i64, i64* %8
%71 = trunc i64 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %71)
%73 = call i32 @time(i32* null)
%74 = call i32 @srand(i32 %73)
br label %75
75: ; preds = %143, %63
%76 = load i32, i32* %13
%77 = add nsw i32 %76, 1
store i32 %77, i32* %13
%78 = load i32, i32* %10
%79 = icmp slt i32 %76, %78
br i1 %79, label %80, label %144
80: ; preds = %75
%81 = call i32 (...) @getpid()
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %81)
%83 = load i32, i32* %13
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %83)
%85 = call i32 (...) @fork()
%86 = icmp ne i32 %85, 0
br i1 %86, label %143, label %87
87: ; preds = %80
%88 = load i64, i64* %7
%89 = call i8* @malloc(i64 %88)
store i8* %89, i8** %15
%90 = load i32, i32* %11
store i32 %90, i32* %16
%91 = load i8*, i8** %15
%92 = icmp ne i8* %91, null
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
store i32 %95, i32* %3
br label %159
96: ; preds = %87
%97 = load i32, i32* @AF_TIPC
%98 = load i32, i32* @SOCK_RDM
%99 = call i32 @socket(i32 %97, i32 %98, i32 0)
store i32 %99, i32* %14
%100 = load i32, i32* %14
%101 = load i32, i32* @SOL_TIPC
%102 = load i32, i32* @TIPC_DEST_DROPPABLE
%103 = call i64 @setsockopt(i32 %100, i32 %101, i32 %102, i32* @main.off, i32 4)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %96
%106 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%107 = load i32, i32* @EXIT_FAILURE
store i32 %107, i32* %3
br label %159
108: ; preds = %96
br label %109
109: ; preds = %133, %108
%110 = load i32, i32* %16
%111 = add nsw i32 %110, -1
store i32 %111, i32* %16
%112 = icmp sgt i32 %110, 0
br i1 %112, label %113, label %134
113: ; preds = %109
%114 = call i32 (...) @getpid()
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %11
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %14
%119 = load i8*, i8** %15
%120 = load i64, i64* %7
%121 = load i64, i64* %8
%122 = call i32 @transaction_send(i32 %118, %struct.sockaddr_tipc* %6, i8* %119, i64 %120, i64 %121)
%123 = icmp ne i32 %122, 0
br i1 %123, label %133, label %124
124: ; preds = %113
%125 = call i32 (...) @getpid()
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %125)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
%128 = load i32, i32* %14
%129 = call i32 @close(i32 %128)
%130 = load i8*, i8** %15
%131 = call i32 @free(i8* %130)
%132 = load i32, i32* @EXIT_FAILURE
store i32 %132, i32* %3
br label %159
133: ; preds = %113
br label %109
134: ; preds = %109
%135 = call i32 (...) @getpid()
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %135)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0))
%138 = load i32, i32* %14
%139 = call i32 @close(i32 %138)
%140 = load i8*, i8** %15
%141 = call i32 @free(i8* %140)
%142 = load i32, i32* @EXIT_SUCCESS
store i32 %142, i32* %3
br label %159
143: ; preds = %80
br label %75
144: ; preds = %75
br label %145
145: ; preds = %148, %144
%146 = call i64 @wait(i32* %18)
store i64 %146, i64* %17
%147 = icmp sgt i64 %146, 0
br i1 %147, label %148, label %157
148: ; preds = %145
%149 = load i64, i64* %17
%150 = trunc i64 %149 to i32
%151 = load i32, i32* %18
%152 = load i32, i32* %18
%153 = icmp sge i32 %152, 0
%154 = zext i1 %153 to i64
%155 = select i1 %153, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0)
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0), i32 %150, i32 %151, i8* %155)
br label %145
157: ; preds = %145
%158 = load i32, i32* @EXIT_SUCCESS
store i32 %158, i32* %3
br label %159
159: ; preds = %157, %134, %124, %105, %93, %53
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
%struct.sockaddr_tipc = type { %struct.TYPE_6__, i32, i32 }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32 }
@TIPC_ADDR_NAME = global i32 0
@AF_TIPC = global i32 0
@.str = [10 x i8] c"hn:i:t:s:\00"
@optarg = global i32 0
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@.str.6 = [37 x i8] c"Running %d iterations on %d clients\0A\00"
@.str.7 = [29 x i8] c"Transaction size = %d bytes\0A\00"
@.str.8 = [23 x i8] c"Segment size=%d bytes\0A\00"
@.str.9 = [12 x i8] c"Client %d: \00"
@.str.10 = [12 x i8] c"Spawned %d\0A\00"
@.str.11 = [9 x i8] c"malloc()\00"
@EXIT_FAILURE = global i32 0
@SOCK_RDM = global i32 0
@main.off = internal constant i32 0
@SOL_TIPC = global i32 0
@TIPC_DEST_DROPPABLE = global i32 0
@.str.12 = [11 x i8] c"setsockopt\00"
@.str.13 = [14 x i8] c"iteration %d\0A\00"
@.str.14 = [23 x i8] c"transaction_send error\00"
@EXIT_SUCCESS = global i32 0
@.str.16 = [31 x i8] c"Exit status of %d was %d (%s)\0A\00"
@.str.17 = [3 x i8] c"OK\00"
@.str.18 = [5 x i8] c"FAIL\00"
@str = [35 x i8] c"Finished transmission successfully\00"
@str.19 = [23 x i8] c"-n <number of clients>\00"
@str.20 = [16 x i8] c"-i <iterations>\00"
@str.21 = [22 x i8] c"-t <bufsize in bytes>\00"
@str.22 = [27 x i8] c"-s <segment size in bytes>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_tipc
%4 = alloca i32
%5 = bitcast %struct.sockaddr_tipc* %3 to i8*
%6 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 0
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 1, i32 0
store i32 1234, i32* %7
%8 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 1, i32 1
store i32 0, i32* %8
%9 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 1
%10 = load i32, i32* @TIPC_ADDR_NAME
store i32 %10, i32* %9
%11 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 2
%12 = load i32, i32* @AF_TIPC
store i32 %12, i32* %11
br label %13
13: ; preds = %33, %2
%14 = phi i32 [ %37, %33 ], [ 1, %2 ]
%15 = phi i32 [ %19, %33 ], [ 1, %2 ]
%16 = phi i64 [ %23, %33 ], [ 512, %2 ]
%17 = phi i64 [ %26, %33 ], [ 65535, %2 ]
br label %18
18: ; preds = %13, %28
%19 = phi i32 [ %15, %13 ], [ %32, %28 ]
%20 = phi i64 [ %16, %13 ], [ %23, %28 ]
%21 = phi i64 [ %17, %13 ], [ %26, %28 ]
br label %22
22: ; preds = %18, %42
%23 = phi i64 [ %20, %18 ], [ %45, %42 ]
%24 = phi i64 [ %21, %18 ], [ %26, %42 ]
br label %25
25: ; preds = %22, %38
%26 = phi i64 [ %41, %38 ], [ %24, %22 ]
%27 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
switch i32 %27, label %46 [
i32 -1, label %53
i32 110, label %28
i32 105, label %33
i32 116, label %38
i32 115, label %42
]
28: ; preds = %25
%29 = load i32, i32* @optarg
%30 = tail call i8* @atoi(i32 %29)
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i32
br label %18
33: ; preds = %25
%34 = load i32, i32* @optarg
%35 = tail call i8* @atoi(i32 %34)
%36 = ptrtoint i8* %35 to i64
%37 = trunc i64 %36 to i32
br label %13
38: ; preds = %25
%39 = load i32, i32* @optarg
%40 = tail call i8* @atoi(i32 %39)
%41 = ptrtoint i8* %40 to i64
br label %25
42: ; preds = %25
%43 = load i32, i32* @optarg
%44 = tail call i8* @atoi(i32 %43)
%45 = ptrtoint i8* %44 to i64
br label %22
46: ; preds = %25
%47 = load i8*, i8** %1
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.19, i64 0, i64 0))
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.20, i64 0, i64 0))
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.21, i64 0, i64 0))
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
br label %127
53: ; preds = %25
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %14, i32 %19)
%55 = trunc i64 %26 to i32
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = trunc i64 %23 to i32
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %57)
%59 = tail call i32 @time(i32* null)
%60 = tail call i32 @srand(i32 %59)
%61 = call i32 @llvm.smax.i32(i32 %19, i32 0)
br label %62
62: ; preds = %66, %53
%63 = phi i32 [ 0, %53 ], [ %64, %66 ]
%64 = add nuw i32 %63, 1
%65 = icmp eq i32 %63, %61
br i1 %65, label %112, label %66
66: ; preds = %62
%67 = tail call i32 (...) @getpid()
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %67)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %64)
%70 = tail call i32 (...) @fork()
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %62
72: ; preds = %66
%73 = tail call i8* @malloc(i64 %26)
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %109
77: ; preds = %72
%78 = load i32, i32* @AF_TIPC
%79 = load i32, i32* @SOCK_RDM
%80 = tail call i32 @socket(i32 %78, i32 %79, i32 0)
%81 = load i32, i32* @SOL_TIPC
%82 = load i32, i32* @TIPC_DEST_DROPPABLE
%83 = tail call i64 @setsockopt(i32 %80, i32 %81, i32 %82, i32* @main.off, i32 4)
%84 = icmp eq i64 %83, 0
br i1 %84, label %87, label %85
85: ; preds = %77
%86 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %109
87: ; preds = %77, %90
%88 = phi i32 [ %91, %90 ], [ %14, %77 ]
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %103
90: ; preds = %87
%91 = add nsw i32 %88, -1
%92 = call i32 (...) @getpid()
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %14)
%95 = call i32 @transaction_send(i32 %80, %struct.sockaddr_tipc* %3, i8* %73, i64 %26, i64 %23)
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %87
97: ; preds = %90
%98 = call i32 (...) @getpid()
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %98)
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
%101 = call i32 @close(i32 %80)
%102 = call i32 @free(i8* %73)
br label %109
103: ; preds = %87
%104 = call i32 (...) @getpid()
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %104)
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%107 = call i32 @close(i32 %80)
%108 = call i32 @free(i8* %73)
br label %109
109: ; preds = %103, %97, %85, %75
%110 = phi i32* [ @EXIT_FAILURE, %85 ], [ @EXIT_FAILURE, %97 ], [ @EXIT_SUCCESS, %103 ], [ @EXIT_FAILURE, %75 ]
%111 = load i32, i32* %110
br label %127
112: ; preds = %62
%113 = bitcast i32* %4 to i8*
%114 = call i64 @wait(i32* %4)
%115 = icmp sgt i64 %114, 0
br i1 %115, label %116, label %125
116: ; preds = %112, %116
%117 = phi i64 [ %123, %116 ], [ %114, %112 ]
%118 = trunc i64 %117 to i32
%119 = load i32, i32* %4
%120 = icmp sgt i32 %119, -1
%121 = select i1 %120, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0)
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0), i32 %118, i32 %119, i8* %121)
%123 = call i64 @wait(i32* %4)
%124 = icmp sgt i64 %123, 0
br i1 %124, label %116, label %125
125: ; preds = %116, %112
%126 = load i32, i32* @EXIT_SUCCESS
br label %127
127: ; preds = %125, %109, %46
%128 = phi i32 [ -1, %46 ], [ %111, %109 ], [ %126, %125 ]
ret i32 %128
}