#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ svm;
struct sockaddr_vm {
  unsigned int svm_port;
  unsigned int svm_cid;
  int /*<<< orphan*/ svm_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_VSOCK;
int /*<<< orphan*/ SHUT_WR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SO_VM_SOCKETS_BUFFER_SIZE;
int /*<<< orphan*/ bzero(struct sockaddr_vm *, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
int getopt(int, char **, char *);
int getsockname(int, struct sockaddr *, int *);
int getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
               int /*<<< orphan*/ *, int *);
int optind;
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
               int /*<<< orphan*/ *, int);
int shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
unsigned int strtoull(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ usage(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  unsigned cid;
  unsigned port;
  int sock;
  int opt;
  int result;
  char byte;
  socklen_t len;
  uint64_t bufsize;
  struct sockaddr_vm svm;
  while ((opt = getopt(argc, argv, ":")) != -1) {
    switch (opt) {
    default:
      usage(argv[0]);
      break;
    }
  }
  if ((argc - optind) != 2)
    usage(argv[0]);
  cid = strtoul(argv[optind], NULL, 10);
  if (!cid)
    usage(argv[0]);
  port = strtoull(argv[optind + 1], NULL, 10);
  if (!port)
    usage(argv[0]);
  sock = socket(AF_VSOCK, SOCK_STREAM, 0);
  if (sock < 0) {
    perror("socket");
    exit(2);
  }
  bzero(&svm, sizeof(svm));
  svm.svm_family = AF_VSOCK;
  svm.svm_port = port;
  svm.svm_cid = cid;
  result = connect(sock, (struct sockaddr *)&svm, sizeof(svm));
  if (result < 0) {
    perror("connect");
    close(sock);
    exit(3);
  }
  byte = 42;
  result = write(sock, &byte, 1);
  if (result < 0) {
    perror("write");
    close(sock);
    exit(4);
  }
  result = shutdown(sock, SHUT_WR);
  if (result < 0) {
    perror("shutdown");
    close(sock);
    exit(5);
  }
  result = read(sock, &byte, 1);
  if (result < 0) {
    perror("read");
    close(sock);
    exit(6);
  } else if (result != 1) {
    fprintf(stderr, "%s: expected 1 byte, got %d\n", argv[0], result);
    close(sock);
    exit(1);
  } else if (byte != 42) {
    fprintf(stderr, "%s: expected %d, got %d\n", argv[0], 42, byte);
    exit(1);
  }
  len = sizeof(svm);
  result = getsockname(sock, (struct sockaddr *)&svm, &len);
  if (result < 0) {
    perror("getsockname");
    close(sock);
    exit(7);
  }
  result =
      getsockopt(sock, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, &bufsize, &len);
  if (result < 0) {
    perror("getsockopt");
    close(sock);
    exit(8);
  }
  result = setsockopt(sock, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, &bufsize, len);
  if (result < 0) {
    perror("setsockopt");
    close(sock);
    exit(9);
  }
  close(sock);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdcc(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
je     1256 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
jmp    1226 <main+0x16>
mov    -0x8(%rbp),%eax
mov    0x2d80(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
je     1277 <main+0x67>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d5e(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12b0 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d25(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtoull@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    12ee <main+0xde>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    132a <main+0x11a>
lea    0xce7(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
lea    -0x40(%rbp),%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    138c <main+0x17c>
lea    0xc94(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
movb   $0x2a,-0x25(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x25(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    13cc <main+0x1bc>
lea    0xc5c(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x4,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2c12(%rip),%rax
mov    (%rax),%esi
call   1050 <shutdown@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1408 <main+0x1f8>
lea    0xc26(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x5,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
lea    -0x25(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1444 <main+0x234>
lea    0xbf3(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x6,%edi
call   1110 <exit@plt>
cmpl   $0x1,-0x24(%rbp)
je     1481 <main+0x271>
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x24(%rbp),%ecx
lea    0xbbd(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
je     14c0 <main+0x2b0>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
movsbl -0x25(%rbp),%r8d
lea    0xb98(%rip),%rsi
mov    $0x2a,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    14c5 <main+0x2b5>
jmp    14ca <main+0x2ba>
movl   $0xc,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10f0 <getsockname@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    150c <main+0x2fc>
lea    0xb66(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x7,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2aa2(%rip),%rax
mov    (%rax),%esi
mov    0x2aa1(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1080 <getsockopt@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1559 <main+0x349>
lea    0xb25(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x8,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2a55(%rip),%rax
mov    (%rax),%esi
mov    0x2a54(%rip),%rax
mov    (%rax),%edx
mov    -0x2c(%rbp),%r8d
lea    -0x30(%rbp),%rcx
call   1030 <setsockopt@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    15a6 <main+0x396>
lea    0xae3(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x9,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
lea    0xdd6(%rip),%rdx
call   10e0 <getopt@plt>
cmp    $0xffffffff,%eax
je     125b <main+0x4b>
lea    0xdc5(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rdi
call   10b0 <usage@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10e0 <getopt@plt>
cmp    $0xffffffff,%eax
jne    1240 <main+0x30>
mov    0x2d7e(%rip),%rbx
mov    (%rbx),%eax
sub    %eax,%ebp
cmp    $0x2,%ebp
je     1276 <main+0x66>
mov    (%r12),%rdi
call   10b0 <usage@plt>
mov    (%rbx),%eax
cltq
mov    (%r12,%rax,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    1298 <main+0x88>
mov    (%r12),%rdi
call   10b0 <usage@plt>
movslq (%rbx),%rax
mov    0x8(%r12,%rax,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtoull@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    12bb <main+0xab>
mov    (%r12),%rdi
call   10b0 <usage@plt>
mov    0x2cf6(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
jns    12f0 <main+0xe0>
lea    0xd21(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    %eax,%r14d
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    0x0(%r13),%eax
mov    %eax,0x20(%rsp)
mov    %ebp,0x18(%rsp)
mov    %r15d,0x1c(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
test   %eax,%eax
jns    1348 <main+0x138>
lea    0xcd8(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
movb   $0x2a,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    1381 <main+0x171>
lea    0xca7(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x4,%edi
call   1110 <exit@plt>
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1050 <shutdown@plt>
test   %eax,%eax
jns    13b4 <main+0x1a4>
lea    0xc7a(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x5,%edi
call   1110 <exit@plt>
lea    0xf(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   1070 <read@plt>
test   %eax,%eax
jns    13e8 <main+0x1d8>
lea    0xc4f(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x6,%edi
call   1110 <exit@plt>
cmp    $0x1,%eax
jne    1435 <main+0x225>
movsbl 0xf(%rsp),%r8d
cmp    $0x2a,%r8d
jne    1464 <main+0x254>
movl   $0xc,0x10(%rsp)
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
call   10f0 <getsockname@plt>
test   %eax,%eax
jns    148e <main+0x27e>
lea    0xc3d(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x7,%edi
call   1110 <exit@plt>
mov    0x2b94(%rip),%rcx
mov    (%rcx),%edi
mov    (%r12),%rdx
lea    0xbdc(%rip),%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2b65(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xbca(%rip),%rsi
mov    $0x2a,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x0(%r13),%esi
mov    0x2b27(%rip),%rbx
mov    (%rbx),%edx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %r14d,%edi
call   1080 <getsockopt@plt>
test   %eax,%eax
jns    14cf <main+0x2bf>
lea    0xbaf(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x8,%edi
call   1110 <exit@plt>
mov    0x0(%r13),%esi
mov    (%rbx),%edx
mov    0x10(%rsp),%r8d
lea    0x14(%rsp),%rcx
mov    %r14d,%edi
call   1030 <setsockopt@plt>
test   %eax,%eax
jns    1509 <main+0x2f9>
lea    0xb80(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x9,%edi
call   1110 <exit@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_vm = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [2 x i8] c":\00"
@optind = global i32 0
@AF_VSOCK = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [8 x i8] c"connect\00"
@.str.3 = [6 x i8] c"write\00"
@SHUT_WR = global i32 0
@.str.4 = [9 x i8] c"shutdown\00"
@.str.5 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"%s: expected 1 byte, got %d\0A\00"
@.str.7 = [25 x i8] c"%s: expected %d, got %d\0A\00"
@.str.8 = [12 x i8] c"getsockname\00"
@SO_VM_SOCKETS_BUFFER_SIZE = global i32 0
@.str.9 = [11 x i8] c"getsockopt\00"
@.str.10 = [11 x i8] c"setsockopt\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 i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.sockaddr_vm
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %15
15: ; preds = %27, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %9
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = load i32, i32* %9
switch i32 %21, label %22 [
]
22: ; preds = %20
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @usage(i8* %25)
br label %27
27: ; preds = %22
br label %15
28: ; preds = %15
%29 = load i32, i32* %4
%30 = load i32, i32* @optind
%31 = sub nsw i32 %29, %30
%32 = icmp ne i32 %31, 2
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @usage(i8* %36)
br label %38
38: ; preds = %33, %28
%39 = load i8**, i8*** %5
%40 = load i32, i32* @optind
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @strtoul(i8* %43, i32* null, i32 10)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %38
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = call i32 @usage(i8* %50)
br label %52
52: ; preds = %47, %38
%53 = load i8**, i8*** %5
%54 = load i32, i32* @optind
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %53, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @strtoull(i8* %58, i32* null, i32 10)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp ne i32 %60, 0
br i1 %61, label %67, label %62
62: ; preds = %52
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = call i32 @usage(i8* %65)
br label %67
67: ; preds = %62, %52
%68 = load i32, i32* @AF_VSOCK
%69 = load i32, i32* @SOCK_STREAM
%70 = call i32 @socket(i32 %68, i32 %69, i32 0)
store i32 %70, i32* %8
%71 = load i32, i32* %8
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%75 = call i32 @exit(i32 2)
unreachable
76: ; preds = %67
%77 = call i32 @bzero(%struct.sockaddr_vm* %14, i32 12)
%78 = load i32, i32* @AF_VSOCK
%79 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %14, i32 0, i32 2
store i32 %78, i32* %79
%80 = load i32, i32* %7
%81 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %14, i32 0, i32 0
store i32 %80, i32* %81
%82 = load i32, i32* %6
%83 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %14, i32 0, i32 1
store i32 %82, i32* %83
%84 = load i32, i32* %8
%85 = bitcast %struct.sockaddr_vm* %14 to %struct.sockaddr*
%86 = call i32 @connect(i32 %84, %struct.sockaddr* %85, i32 12)
store i32 %86, i32* %10
%87 = load i32, i32* %10
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %76
%90 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%91 = load i32, i32* %8
%92 = call i32 @close(i32 %91)
%93 = call i32 @exit(i32 3)
unreachable
94: ; preds = %76
store i8 42, i8* %11
%95 = load i32, i32* %8
%96 = call i32 @write(i32 %95, i8* %11, i32 1)
store i32 %96, i32* %10
%97 = load i32, i32* %10
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %94
%100 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%101 = load i32, i32* %8
%102 = call i32 @close(i32 %101)
%103 = call i32 @exit(i32 4)
unreachable
104: ; preds = %94
%105 = load i32, i32* %8
%106 = load i32, i32* @SHUT_WR
%107 = call i32 @shutdown(i32 %105, i32 %106)
store i32 %107, i32* %10
%108 = load i32, i32* %10
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %104
%111 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%112 = load i32, i32* %8
%113 = call i32 @close(i32 %112)
%114 = call i32 @exit(i32 5)
unreachable
115: ; preds = %104
%116 = load i32, i32* %8
%117 = call i32 @read(i32 %116, i8* %11, i32 1)
store i32 %117, i32* %10
%118 = load i32, i32* %10
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %115
%121 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%122 = load i32, i32* %8
%123 = call i32 @close(i32 %122)
%124 = call i32 @exit(i32 6)
unreachable
125: ; preds = %115
%126 = load i32, i32* %10
%127 = icmp ne i32 %126, 1
br i1 %127, label %128, label %138
128: ; preds = %125
%129 = load i32, i32* @stderr
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 0
%132 = load i8*, i8** %131
%133 = load i32, i32* %10
%134 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %132, i32 %133)
%135 = load i32, i32* %8
%136 = call i32 @close(i32 %135)
%137 = call i32 @exit(i32 1)
unreachable
138: ; preds = %125
%139 = load i8, i8* %11
%140 = sext i8 %139 to i32
%141 = icmp ne i32 %140, 42
br i1 %141, label %142, label %151
142: ; preds = %138
%143 = load i32, i32* @stderr
%144 = load i8**, i8*** %5
%145 = getelementptr inbounds i8*, i8** %144, i64 0
%146 = load i8*, i8** %145
%147 = load i8, i8* %11
%148 = sext i8 %147 to i32
%149 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %146, i32 42, i32 %148)
%150 = call i32 @exit(i32 1)
unreachable
151: ; preds = %138
br label %152
152: ; preds = %151
br label %153
153: ; preds = %152
store i32 12, i32* %12
%154 = load i32, i32* %8
%155 = bitcast %struct.sockaddr_vm* %14 to %struct.sockaddr*
%156 = call i32 @getsockname(i32 %154, %struct.sockaddr* %155, i32* %12)
store i32 %156, i32* %10
%157 = load i32, i32* %10
%158 = icmp slt i32 %157, 0
br i1 %158, label %159, label %164
159: ; preds = %153
%160 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%161 = load i32, i32* %8
%162 = call i32 @close(i32 %161)
%163 = call i32 @exit(i32 7)
unreachable
164: ; preds = %153
%165 = load i32, i32* %8
%166 = load i32, i32* @AF_VSOCK
%167 = load i32, i32* @SO_VM_SOCKETS_BUFFER_SIZE
%168 = call i32 @getsockopt(i32 %165, i32 %166, i32 %167, i32* %13, i32* %12)
store i32 %168, i32* %10
%169 = load i32, i32* %10
%170 = icmp slt i32 %169, 0
br i1 %170, label %171, label %176
171: ; preds = %164
%172 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%173 = load i32, i32* %8
%174 = call i32 @close(i32 %173)
%175 = call i32 @exit(i32 8)
unreachable
176: ; preds = %164
%177 = load i32, i32* %8
%178 = load i32, i32* @AF_VSOCK
%179 = load i32, i32* @SO_VM_SOCKETS_BUFFER_SIZE
%180 = load i32, i32* %12
%181 = call i32 @setsockopt(i32 %177, i32 %178, i32 %179, i32* %13, i32 %180)
store i32 %181, i32* %10
%182 = load i32, i32* %10
%183 = icmp slt i32 %182, 0
br i1 %183, label %184, label %189
184: ; preds = %176
%185 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%186 = load i32, i32* %8
%187 = call i32 @close(i32 %186)
%188 = call i32 @exit(i32 9)
unreachable
189: ; preds = %176
%190 = load i32, i32* %8
%191 = call i32 @close(i32 %190)
%192 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_vm = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [2 x i8] c":\00"
@optind = global i32 0
@AF_VSOCK = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [8 x i8] c"connect\00"
@.str.3 = [6 x i8] c"write\00"
@SHUT_WR = global i32 0
@.str.4 = [9 x i8] c"shutdown\00"
@.str.5 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"%s: expected 1 byte, got %d\0A\00"
@.str.7 = [25 x i8] c"%s: expected %d, got %d\0A\00"
@.str.8 = [12 x i8] c"getsockname\00"
@SO_VM_SOCKETS_BUFFER_SIZE = global i32 0
@.str.9 = [11 x i8] c"getsockopt\00"
@.str.10 = [11 x i8] c"setsockopt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_vm
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast %struct.sockaddr_vm* %6 to i8*
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, -1
br i1 %11, label %17, label %12
12: ; preds = %2, %12
%13 = load i8*, i8** %1
%14 = tail call i32 @usage(i8* %13)
%15 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %12
17: ; preds = %12, %2
%18 = load i32, i32* @optind
%19 = sub nsw i32 %0, %18
%20 = icmp eq i32 %19, 2
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8*, i8** %1
%23 = tail call i32 @usage(i8* %22)
%24 = load i32, i32* @optind
br label %25
25: ; preds = %21, %17
%26 = phi i32 [ %24, %21 ], [ %18, %17 ]
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 @strtoul(i8* nocapture %29, i32* null, i32 10)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load i8*, i8** %1
%34 = tail call i32 @usage(i8* %33)
br label %35
35: ; preds = %32, %25
%36 = load i32, i32* @optind
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i32 @strtoull(i8* nocapture %40, i32* null, i32 10)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i8*, i8** %1
%45 = tail call i32 @usage(i8* %44)
br label %46
46: ; preds = %43, %35
%47 = load i32, i32* @AF_VSOCK
%48 = load i32, i32* @SOCK_STREAM
%49 = tail call i32 @socket(i32 %47, i32 %48, i32 0)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%53 = tail call i32 @exit(i32 2)
unreachable
54: ; preds = %46
%55 = call i32 @bzero(%struct.sockaddr_vm* %6, i32 12)
%56 = load i32, i32* @AF_VSOCK
%57 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %6, i64 0, i32 2
store i32 %56, i32* %57
%58 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %6, i64 0, i32 0
store i32 %41, i32* %58
%59 = getelementptr inbounds %struct.sockaddr_vm, %struct.sockaddr_vm* %6, i64 0, i32 1
store i32 %30, i32* %59
%60 = bitcast %struct.sockaddr_vm* %6 to %struct.sockaddr*
%61 = call i32 @connect(i32 %49, %struct.sockaddr* %60, i32 12)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %54
%64 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%65 = call i32 @close(i32 %49)
%66 = call i32 @exit(i32 3)
unreachable
67: ; preds = %54
store i8 42, i8* %3
%68 = call i32 @write(i32 %49, i8* %3, i32 1)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%72 = call i32 @close(i32 %49)
%73 = call i32 @exit(i32 4)
unreachable
74: ; preds = %67
%75 = load i32, i32* @SHUT_WR
%76 = call i32 @shutdown(i32 %49, i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%80 = call i32 @close(i32 %49)
%81 = call i32 @exit(i32 5)
unreachable
82: ; preds = %74
%83 = call i32 @read(i32 %49, i8* %3, i32 1)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%87 = call i32 @close(i32 %49)
%88 = call i32 @exit(i32 6)
unreachable
89: ; preds = %82
%90 = icmp eq i32 %83, 1
br i1 %90, label %97, label %91
91: ; preds = %89
%92 = load i32, i32* @stderr
%93 = load i8*, i8** %1
%94 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %93, i32 %83)
%95 = call i32 @close(i32 %49)
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %89
%98 = load i8, i8* %3
%99 = icmp eq i8 %98, 42
br i1 %99, label %106, label %100
100: ; preds = %97
%101 = sext i8 %98 to i32
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %1
%104 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %103, i32 42, i32 %101)
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %97
store i32 12, i32* %4
%107 = call i32 @getsockname(i32 %49, %struct.sockaddr* %60, i32* %4)
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %113
109: ; preds = %106
%110 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%111 = call i32 @close(i32 %49)
%112 = call i32 @exit(i32 7)
unreachable
113: ; preds = %106
%114 = load i32, i32* @AF_VSOCK
%115 = load i32, i32* @SO_VM_SOCKETS_BUFFER_SIZE
%116 = call i32 @getsockopt(i32 %49, i32 %114, i32 %115, i32* %5, i32* %4)
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %113
%119 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%120 = call i32 @close(i32 %49)
%121 = call i32 @exit(i32 8)
unreachable
122: ; preds = %113
%123 = load i32, i32* @AF_VSOCK
%124 = load i32, i32* @SO_VM_SOCKETS_BUFFER_SIZE
%125 = load i32, i32* %4
%126 = call i32 @setsockopt(i32 %49, i32 %123, i32 %124, i32* %5, i32 %125)
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %122
%129 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%130 = call i32 @close(i32 %49)
%131 = call i32 @exit(i32 9)
unreachable
132: ; preds = %122
%133 = call i32 @close(i32 %49)
%134 = call i32 @exit(i32 0)
unreachable
}