#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 pollfd {
  int fd;
  scalar_t__ revents;
  int /*<<< orphan*/ events;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
struct TYPE_2__ {
  int operation;
};
struct hv_vss_msg {
  int error;
  TYPE_1__ vss_hdr;
};
typedef int /*<<< orphan*/ kernel_modver;
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
scalar_t__ EINVAL;
int EXIT_FAILURE;
int HV_E_FAIL;
int HV_S_OK;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ POLLIN;
#define VSS_OP_FREEZE 131
#define VSS_OP_HOT_BACKUP 130
int VSS_OP_REGISTER1;
#define VSS_OP_THAW 129
int /*<<< orphan*/ close(int);
scalar_t__ daemon(int, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ getpid();
#define no_argument 128
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ poll(struct pollfd *, int, int);
int /*<<< orphan*/ print_usage(char **);
int read(int, struct hv_vss_msg *, int);
char *strerror(scalar_t__);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int vss_operate(int const);
int write(int, struct hv_vss_msg *, int);
int main(int argc, char *argv[]) {
  int vss_fd, len;
  int error;
  struct pollfd pfd;
  int op;
  struct hv_vss_msg vss_msg[1];
  int daemonize = 1, long_index = 0, opt;
  int in_handshake = 1;
  __u32 kernel_modver;
  static struct option long_options[] = {{"help", no_argument, 0, 'h'},
                                         {"no-daemon", no_argument, 0, 'n'},
                                         {0, 0, 0, 0}};
  while ((opt = getopt_long(argc, argv, "hn", long_options, &long_index)) !=
         -1) {
    switch (opt) {
    case 'n':
      daemonize = 0;
      break;
    case 'h':
      print_usage(argv);
      exit(0);
    default:
      print_usage(argv);
      exit(EXIT_FAILURE);
    }
  }
  if (daemonize && daemon(1, 0))
    return 1;
  openlog("Hyper-V VSS", 0, LOG_USER);
  syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
  vss_fd = open("/dev/vmbus/hv_vss", O_RDWR);
  if (vss_fd < 0) {
    syslog(LOG_ERR, "open /dev/vmbus/hv_vss failed; error: %d %s", errno,
           strerror(errno));
    exit(EXIT_FAILURE);
  }
  vss_msg->vss_hdr.operation = VSS_OP_REGISTER1;
  len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
  if (len < 0) {
    syslog(LOG_ERR, "registration to kernel failed; error: %d %s", errno,
           strerror(errno));
    close(vss_fd);
    exit(EXIT_FAILURE);
  }
  pfd.fd = vss_fd;
  while (1) {
    pfd.events = POLLIN;
    pfd.revents = 0;
    if (poll(&pfd, 1, -1) < 0) {
      syslog(LOG_ERR, "poll failed; error:%d %s", errno, strerror(errno));
      if (errno == EINVAL) {
        close(vss_fd);
        exit(EXIT_FAILURE);
      } else
        continue;
    }
    len = read(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
    if (in_handshake) {
      if (len != sizeof(kernel_modver)) {
        syslog(LOG_ERR, "invalid version negotiation");
        exit(EXIT_FAILURE);
      }
      kernel_modver = *(__u32 *)vss_msg;
      in_handshake = 0;
      syslog(LOG_INFO, "VSS: kernel module version: %d", kernel_modver);
      continue;
    }
    if (len != sizeof(struct hv_vss_msg)) {
      syslog(LOG_ERR, "read failed; error:%d %s", errno, strerror(errno));
      close(vss_fd);
      return EXIT_FAILURE;
    }
    op = vss_msg->vss_hdr.operation;
    error = HV_S_OK;
    switch (op) {
    case VSS_OP_FREEZE:
    case VSS_OP_THAW:
      error = vss_operate(op);
      syslog(LOG_INFO, "VSS: op=%s: %s\n",
             op == VSS_OP_FREEZE ? "FREEZE" : "THAW",
             error ? "failed" : "succeeded");
      if (error) {
        error = HV_E_FAIL;
        syslog(LOG_ERR, "op=%d failed!", op);
        syslog(LOG_ERR, "report it with these files:");
        syslog(LOG_ERR, "/etc/fstab and /proc/mounts");
      }
      break;
    case VSS_OP_HOT_BACKUP:
      syslog(LOG_INFO, "VSS: op=CHECK HOT BACKUP\n");
      break;
    default:
      syslog(LOG_ERR, "Illegal op:%d\n", op);
    }
    vss_msg->error = error;
    len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
    if (len != sizeof(struct hv_vss_msg)) {
      syslog(LOG_ERR, "write failed; error: %d %s", errno, strerror(errno));
      if (op == VSS_OP_FREEZE)
        vss_operate(VSS_OP_THAW);
    }
  }
  close(vss_fd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x1,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdf3(%rip),%rdx
lea    0x2e7d(%rip),%rcx
lea    -0x50(%rbp),%r8
call   1050 <getopt_long@plt>
mov    %eax,-0x54(%rbp)
cmp    $0xffffffff,%eax
je     1295 <main+0xb5>
mov    -0x54(%rbp),%eax
mov    %eax,-0x60(%rbp)
sub    $0x68,%eax
je     1269 <main+0x89>
jmp    124c <main+0x6c>
mov    -0x60(%rbp),%eax
sub    $0x6e,%eax
jne    1279 <main+0x99>
jmp    125d <main+0x7d>
movl   $0x0,-0x4c(%rbp)
jmp    1290 <main+0xb0>
mov    -0x10(%rbp),%rdi
call   10f0 <print_usage@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   10f0 <print_usage@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    120e <main+0x2e>
cmpl   $0x0,-0x4c(%rbp)
je     12c1 <main+0xe1>
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <daemon@plt>
cmp    $0x0,%rax
je     12c1 <main+0xe1>
movl   $0x1,-0x4(%rbp)
jmp    177b <main+0x59b>
mov    0x2d18(%rip),%rax
mov    (%rax),%edx
lea    0xd41(%rip),%rdi
xor    %esi,%esi
call   10c0 <openlog@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%edx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%esi
lea    0xd28(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    136f <main+0x18f>
mov    0x2c61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2c8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%rdi
call   1100 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13f6 <main+0x216>
mov    0x2be8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    0x2c11(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    0x2c03(%rip),%rax
mov    (%rax),%rdi
call   1100 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xc9b(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2bcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   10a0 <poll@plt>
cmp    $0x0,%rax
jge    14af <main+0x2cf>
mov    0x2b54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    0x2b7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
mov    0x2b6c(%rip),%rax
mov    (%rax),%rdi
call   1100 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rdx
mov    %rax,%rcx
lea    0xc2d(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2b3f(%rip),%rax
mov    (%rax),%rax
mov    0x2b1d(%rip),%rcx
cmp    (%rcx),%rax
jne    14aa <main+0x2ca>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    13fc <main+0x21c>
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x8,%edx
call   1070 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x58(%rbp)
je     152c <main+0x34c>
movslq -0x18(%rbp),%rax
cmp    $0x4,%rax
je     1500 <main+0x320>
mov    0x2aa6(%rip),%rax
mov    (%rax),%edi
lea    0xbce(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2ab7(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    0x2a8c(%rip),%rax
mov    (%rax),%edi
mov    -0x5c(%rbp),%edx
lea    0xbb5(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
jmp    13fc <main+0x21c>
movslq -0x18(%rbp),%rax
cmp    $0x8,%rax
je     15a0 <main+0x3c0>
mov    0x2a47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2a70(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2a5f(%rip),%rax
mov    (%rax),%rdi
call   1100 <strerror@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rdx
mov    %rax,%rcx
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    0x2a1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    177b <main+0x59b>
mov    -0x44(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    0x29e3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0xa8(%rbp)
sub    $0x81,%eax
je     15f7 <main+0x417>
jmp    15cb <main+0x3eb>
mov    -0xa8(%rbp),%eax
sub    $0x82,%eax
je     16af <main+0x4cf>
jmp    15e1 <main+0x401>
mov    -0xa8(%rbp),%eax
sub    $0x83,%eax
jne    16cb <main+0x4eb>
jmp    15f7 <main+0x417>
mov    -0x3c(%rbp),%edi
call   10d0 <vss_operate@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2997(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%ecx
lea    0xb0f(%rip),%rdx
lea    0xb01(%rip),%rax
cmp    $0x83,%ecx
cmove  %rax,%rdx
mov    -0x1c(%rbp),%esi
lea    0xb00(%rip),%rcx
lea    0xaf2(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xac8(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
cmpl   $0x0,-0x1c(%rbp)
je     16aa <main+0x4ca>
mov    0x295b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x291f(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xac5(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2905(%rip),%rax
mov    (%rax),%edi
lea    0xabc(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x28ee(%rip),%rax
mov    (%rax),%edi
lea    0xac1(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
jmp    16e5 <main+0x505>
mov    0x28ea(%rip),%rax
mov    (%rax),%edi
lea    0xac1(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
jmp    16e5 <main+0x505>
mov    0x28b6(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xabc(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x8,%rax
je     1776 <main+0x596>
mov    0x2874(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    0x289d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    0x288c(%rip),%rax
mov    (%rax),%rdi
call   1100 <strerror@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rdx
mov    %rax,%rcx
lea    0xa56(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
cmpl   $0x83,-0x3c(%rbp)
jne    1771 <main+0x591>
mov    $0x81,%edi
call   10d0 <vss_operate@plt>
jmp    1776 <main+0x596>
jmp    13fc <main+0x21c>
mov    -0x4(%rbp),%eax
add    $0xc0,%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,%r13
mov    %edi,%ebp
movl   $0x0,0x1c(%rsp)
xor    %ecx,%ecx
lea    0xe0b(%rip),%r14
lea    0x2e95(%rip),%r15
lea    0x1c(%rsp),%r12
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <getopt_long@plt>
mov    $0x1,%cl
cmp    $0x6e,%eax
je     1210 <main+0x30>
cmp    $0xffffffff,%eax
jne    1571 <main+0x391>
test   $0x1,%bl
jne    1254 <main+0x74>
mov    $0x1,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <daemon@plt>
test   %rax,%rax
jne    1549 <main+0x369>
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
lea    0xdae(%rip),%rdi
xor    %esi,%esi
call   10c0 <openlog@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xd9c(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
lea    0xd99(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     15a0 <main+0x3c0>
mov    %eax,%ebx
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1030 <write@plt>
test   %eax,%eax
js     15d3 <main+0x3f3>
mov    %ebx,0x8(%rsp)
mov    %ebx,0x20(%rsp)
lea    0x20(%rsp),%r15
mov    0x2ca2(%rip),%r13
mov    0x2cd3(%rip),%r14
lea    0xdac(%rip),%r12
movl   $0x0,0xc(%rsp)
jmp    1334 <main+0x154>
xchg   %ax,%ax
mov    0x0(%r13),%ebp
mov    (%r14),%rbx
mov    %rbx,%rdi
call   1100 <strerror@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    (%r14),%rax
mov    0x2c7d(%rip),%rcx
cmp    (%rcx),%rax
je     155a <main+0x37a>
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
movq   $0x0,0x28(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   10a0 <poll@plt>
test   %rax,%rax
js     1300 <main+0x120>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1070 <read@plt>
testb  $0x1,0xc(%rsp)
je     144a <main+0x26a>
cmp    $0x8,%eax
jne    1512 <main+0x332>
mov    0x14(%rsp),%ebx
cmp    $0x83,%ebx
je     13b5 <main+0x1d5>
mov    0x2bf5(%rip),%rax
mov    (%rax),%ebp
cmp    $0x82,%ebx
je     1479 <main+0x299>
cmp    $0x81,%ebx
jne    1492 <main+0x2b2>
mov    %ebx,%edi
call   10d0 <vss_operate@plt>
mov    %eax,%ebp
cmp    $0x83,%ebx
lea    0xd59(%rip),%rdx
lea    0xd4b(%rip),%rax
cmove  %rax,%rdx
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
test   %ebp,%ebp
lea    0xd41(%rip),%rcx
lea    0xd41(%rip),%rax
cmove  %rax,%rcx
lea    0xd13(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
test   %ebp,%ebp
mov    $0x0,%ebp
je     14a6 <main+0x2c6>
mov    0x2ba3(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%edi
lea    0xd18(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    0x0(%r13),%edi
lea    0xd12(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
mov    0x0(%r13),%edi
lea    0xd1c(%rip),%rsi
jmp    1489 <main+0x2a9>
cmp    $0x4,%eax
jne    158c <main+0x3ac>
mov    0x10(%rsp),%edx
mov    0x2b42(%rip),%rax
mov    (%rax),%edi
lea    0xc6e(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
mov    $0x1,%al
mov    %eax,0xc(%rsp)
jmp    1334 <main+0x154>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
lea    0xcf7(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
jmp    14a6 <main+0x2c6>
mov    0x0(%r13),%edi
lea    0xcfd(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    %ebp,0x10(%rsp)
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    $0x1,%cl
mov    %ecx,0xc(%rsp)
cmp    $0x8,%eax
je     1334 <main+0x154>
mov    0x0(%r13),%eax
mov    %eax,0x18(%rsp)
mov    (%r14),%rbp
mov    %rbp,%rdi
call   1100 <strerror@plt>
mov    0x18(%rsp),%edi
lea    0xcbf(%rip),%rsi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <syslog@plt>
cmp    $0x83,%ebx
jne    1334 <main+0x154>
mov    $0x81,%edi
call   10d0 <vss_operate@plt>
jmp    1334 <main+0x154>
mov    0x0(%r13),%ebx
mov    (%r14),%rbp
mov    %rbp,%rdi
call   1100 <strerror@plt>
lea    0xbcc(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x2a69(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x2a46(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    %r13,%rdi
cmp    $0x68,%eax
jne    1585 <main+0x3a5>
call   10f0 <print_usage@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
call   10f0 <print_usage@plt>
jmp    1563 <main+0x383>
mov    0x0(%r13),%edi
lea    0xb22(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
jmp    1563 <main+0x383>
mov    0x29e1(%rip),%rax
mov    (%rax),%ebx
mov    0x2a10(%rip),%rax
mov    (%rax),%rbp
mov    %rbp,%rdi
call   1100 <strerror@plt>
lea    0xa86(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <syslog@plt>
jmp    1563 <main+0x383>
mov    0x29ae(%rip),%rax
mov    (%rax),%r14d
mov    0x29dc(%rip),%rax
mov    (%rax),%rbp
mov    %rbp,%rdi
call   1100 <strerror@plt>
lea    0xa7e(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    %ebx,%edi
jmp    155e <main+0x37e>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.pollfd = type { i32, i64, i32 }
%struct.hv_vss_msg = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [10 x i8] c"no-daemon\00"
@.str.2 = [3 x i8] c"hn\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"Hyper-V VSS\00"
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.4 = [24 x i8] c"VSS starting; pid is:%d\00"
@.str.5 = [18 x i8] c"/dev/vmbus/hv_vss\00"
@O_RDWR = global i32 0
@LOG_ERR = global i32 0
@.str.6 = [44 x i8] c"open /dev/vmbus/hv_vss failed; error: %d %s\00"
@errno = global i64 0
@VSS_OP_REGISTER1 = global i32 0
@.str.7 = [44 x i8] c"registration to kernel failed; error: %d %s\00"
@POLLIN = global i32 0
@.str.8 = [25 x i8] c"poll failed; error:%d %s\00"
@EINVAL = global i64 0
@.str.9 = [28 x i8] c"invalid version negotiation\00"
@.str.10 = [31 x i8] c"VSS: kernel module version: %d\00"
@.str.11 = [25 x i8] c"read failed; error:%d %s\00"
@HV_S_OK = global i32 0
@.str.12 = [16 x i8] c"VSS: op=%s: %s\0A\00"
@.str.13 = [7 x i8] c"FREEZE\00"
@.str.14 = [5 x i8] c"THAW\00"
@.str.15 = [7 x i8] c"failed\00"
@.str.16 = [10 x i8] c"succeeded\00"
@HV_E_FAIL = global i32 0
@.str.17 = [14 x i8] c"op=%d failed!\00"
@.str.18 = [28 x i8] c"report it with these files:\00"
@.str.19 = [28 x i8] c"/etc/fstab and /proc/mounts\00"
@.str.20 = [26 x i8] c"VSS: op=CHECK HOT BACKUP\0A\00"
@.str.21 = [15 x i8] c"Illegal op:%d\0A\00"
@.str.22 = [27 x i8] c"write failed; error: %d %s\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 %struct.pollfd
%10 = alloca i32
%11 = alloca [1 x %struct.hv_vss_msg]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %12
store i32 0, i32* %13
store i32 1, i32* %15
br label %17
17: ; preds = %34, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt_long(i32 %18, i8** %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %13)
store i32 %20, i32* %14
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = load i32, i32* %14
switch i32 %23, label %29 [
i32 110, label %24
i32 104, label %25
]
24: ; preds = %22
store i32 0, i32* %12
br label %34
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = call i32 @print_usage(i8** %26)
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = call i32 @print_usage(i8** %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %24
br label %17
35: ; preds = %17
%36 = load i32, i32* %12
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = call i64 @daemon(i32 1, i32 0)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 1, i32* %3
br label %200
42: ; preds = %38, %35
%43 = load i32, i32* @LOG_USER
%44 = call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %43)
%45 = load i32, i32* @LOG_INFO
%46 = call i32 (...) @getpid()
%47 = call i32 (i32, i8*, ...) @syslog(i32 %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @O_RDWR
%49 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %48)
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %42
%53 = load i32, i32* @LOG_ERR
%54 = load i64, i64* @errno
%55 = load i64, i64* @errno
%56 = call i8* @strerror(i64 %55)
%57 = call i32 (i32, i8*, ...) @syslog(i32 %53, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i64 %54, i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %42
%61 = load i32, i32* @VSS_OP_REGISTER1
%62 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%63 = getelementptr inbounds %struct.hv_vss_msg, %struct.hv_vss_msg* %62, i32 0, i32 1
%64 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %63, i32 0, i32 0
store i32 %61, i32* %64
%65 = load i32, i32* %6
%66 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%67 = call i32 @write(i32 %65, %struct.hv_vss_msg* %66, i32 8)
store i32 %67, i32* %7
%68 = load i32, i32* %7
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %80
70: ; preds = %60
%71 = load i32, i32* @LOG_ERR
%72 = load i64, i64* @errno
%73 = load i64, i64* @errno
%74 = call i8* @strerror(i64 %73)
%75 = call i32 (i32, i8*, ...) @syslog(i32 %71, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i64 %72, i8* %74)
%76 = load i32, i32* %6
%77 = call i32 @close(i32 %76)
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %60
%81 = load i32, i32* %6
%82 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %9, i32 0, i32 0
store i32 %81, i32* %82
br label %83
83: ; preds = %80, %103, %119, %199
%84 = load i32, i32* @POLLIN
%85 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %9, i32 0, i32 2
store i32 %84, i32* %85
%86 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %9, i32 0, i32 1
store i64 0, i64* %86
%87 = call i64 @poll(%struct.pollfd* %9, i32 1, i32 -1)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %104
89: ; preds = %83
%90 = load i32, i32* @LOG_ERR
%91 = load i64, i64* @errno
%92 = load i64, i64* @errno
%93 = call i8* @strerror(i64 %92)
%94 = call i32 (i32, i8*, ...) @syslog(i32 %90, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i64 %91, i8* %93)
%95 = load i64, i64* @errno
%96 = load i64, i64* @EINVAL
%97 = icmp eq i64 %95, %96
br i1 %97, label %98, label %103
98: ; preds = %89
%99 = load i32, i32* %6
%100 = call i32 @close(i32 %99)
%101 = load i32, i32* @EXIT_FAILURE
%102 = call i32 @exit(i32 %101)
unreachable
103: ; preds = %89
br label %83
104: ; preds = %83
%105 = load i32, i32* %6
%106 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%107 = call i32 @read(i32 %105, %struct.hv_vss_msg* %106, i32 8)
store i32 %107, i32* %7
%108 = load i32, i32* %15
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %126
110: ; preds = %104
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = icmp ne i64 %112, 4
br i1 %113, label %114, label %119
114: ; preds = %110
%115 = load i32, i32* @LOG_ERR
%116 = call i32 (i32, i8*, ...) @syslog(i32 %115, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%117 = load i32, i32* @EXIT_FAILURE
%118 = call i32 @exit(i32 %117)
unreachable
119: ; preds = %110
%120 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%121 = bitcast %struct.hv_vss_msg* %120 to i32*
%122 = load i32, i32* %121
store i32 %122, i32* %16
store i32 0, i32* %15
%123 = load i32, i32* @LOG_INFO
%124 = load i32, i32* %16
%125 = call i32 (i32, i8*, ...) @syslog(i32 %123, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %124)
br label %83
126: ; preds = %104
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = icmp ne i64 %128, 8
br i1 %129, label %130, label %139
130: ; preds = %126
%131 = load i32, i32* @LOG_ERR
%132 = load i64, i64* @errno
%133 = load i64, i64* @errno
%134 = call i8* @strerror(i64 %133)
%135 = call i32 (i32, i8*, ...) @syslog(i32 %131, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i64 %132, i8* %134)
%136 = load i32, i32* %6
%137 = call i32 @close(i32 %136)
%138 = load i32, i32* @EXIT_FAILURE
store i32 %138, i32* %3
br label %200
139: ; preds = %126
%140 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%141 = getelementptr inbounds %struct.hv_vss_msg, %struct.hv_vss_msg* %140, i32 0, i32 1
%142 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %141, i32 0, i32 0
%143 = load i32, i32* %142
store i32 %143, i32* %10
%144 = load i32, i32* @HV_S_OK
store i32 %144, i32* %8
%145 = load i32, i32* %10
switch i32 %145, label %174 [
i32 131, label %146
i32 129, label %146
i32 130, label %171
]
146: ; preds = %139, %139
%147 = load i32, i32* %10
%148 = call i32 @vss_operate(i32 %147)
store i32 %148, i32* %8
%149 = load i32, i32* @LOG_INFO
%150 = load i32, i32* %10
%151 = icmp eq i32 %150, 131
%152 = zext i1 %151 to i64
%153 = select i1 %151, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0)
%154 = load i32, i32* %8
%155 = icmp ne i32 %154, 0
%156 = zext i1 %155 to i64
%157 = select i1 %155, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0)
%158 = call i32 (i32, i8*, ...) @syslog(i32 %149, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* %153, i8* %157)
%159 = load i32, i32* %8
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %170
161: ; preds = %146
%162 = load i32, i32* @HV_E_FAIL
store i32 %162, i32* %8
%163 = load i32, i32* @LOG_ERR
%164 = load i32, i32* %10
%165 = call i32 (i32, i8*, ...) @syslog(i32 %163, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i32 %164)
%166 = load i32, i32* @LOG_ERR
%167 = call i32 (i32, i8*, ...) @syslog(i32 %166, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0))
%168 = load i32, i32* @LOG_ERR
%169 = call i32 (i32, i8*, ...) @syslog(i32 %168, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0))
br label %170
170: ; preds = %161, %146
br label %178
171: ; preds = %139
%172 = load i32, i32* @LOG_INFO
%173 = call i32 (i32, i8*, ...) @syslog(i32 %172, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.20, i64 0, i64 0))
br label %178
174: ; preds = %139
%175 = load i32, i32* @LOG_ERR
%176 = load i32, i32* %10
%177 = call i32 (i32, i8*, ...) @syslog(i32 %175, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i32 %176)
br label %178
178: ; preds = %174, %171, %170
%179 = load i32, i32* %8
%180 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%181 = getelementptr inbounds %struct.hv_vss_msg, %struct.hv_vss_msg* %180, i32 0, i32 0
store i32 %179, i32* %181
%182 = load i32, i32* %6
%183 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %11, i64 0, i64 0
%184 = call i32 @write(i32 %182, %struct.hv_vss_msg* %183, i32 8)
store i32 %184, i32* %7
%185 = load i32, i32* %7
%186 = sext i32 %185 to i64
%187 = icmp ne i64 %186, 8
br i1 %187, label %188, label %199
188: ; preds = %178
%189 = load i32, i32* @LOG_ERR
%190 = load i64, i64* @errno
%191 = load i64, i64* @errno
%192 = call i8* @strerror(i64 %191)
%193 = call i32 (i32, i8*, ...) @syslog(i32 %189, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.22, i64 0, i64 0), i64 %190, i8* %192)
%194 = load i32, i32* %10
%195 = icmp eq i32 %194, 131
br i1 %195, label %196, label %198
196: ; preds = %188
%197 = call i32 @vss_operate(i32 129)
br label %198
198: ; preds = %196, %188
br label %199
199: ; preds = %198, %178
br label %83
200: ; preds = %130, %41
%201 = load i32, i32* %3
ret i32 %201
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.pollfd = type { i32, i64, i32 }
%struct.hv_vss_msg = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [10 x i8] c"no-daemon\00"
@.str.2 = [3 x i8] c"hn\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"Hyper-V VSS\00"
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.4 = [24 x i8] c"VSS starting; pid is:%d\00"
@.str.5 = [18 x i8] c"/dev/vmbus/hv_vss\00"
@O_RDWR = global i32 0
@LOG_ERR = global i32 0
@.str.6 = [44 x i8] c"open /dev/vmbus/hv_vss failed; error: %d %s\00"
@errno = global i64 0
@VSS_OP_REGISTER1 = global i32 0
@.str.7 = [44 x i8] c"registration to kernel failed; error: %d %s\00"
@POLLIN = global i32 0
@.str.8 = [25 x i8] c"poll failed; error:%d %s\00"
@EINVAL = global i64 0
@.str.9 = [28 x i8] c"invalid version negotiation\00"
@.str.10 = [31 x i8] c"VSS: kernel module version: %d\00"
@.str.11 = [25 x i8] c"read failed; error:%d %s\00"
@HV_S_OK = global i32 0
@.str.12 = [16 x i8] c"VSS: op=%s: %s\0A\00"
@.str.13 = [7 x i8] c"FREEZE\00"
@.str.14 = [5 x i8] c"THAW\00"
@.str.15 = [7 x i8] c"failed\00"
@.str.16 = [10 x i8] c"succeeded\00"
@HV_E_FAIL = global i32 0
@.str.17 = [14 x i8] c"op=%d failed!\00"
@.str.18 = [28 x i8] c"report it with these files:\00"
@.str.19 = [28 x i8] c"/etc/fstab and /proc/mounts\00"
@.str.20 = [26 x i8] c"VSS: op=CHECK HOT BACKUP\0A\00"
@.str.21 = [15 x i8] c"Illegal op:%d\0A\00"
@.str.22 = [27 x i8] c"write failed; error: %d %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.pollfd
%4 = alloca [1 x %struct.hv_vss_msg]
%5 = alloca i32
%6 = bitcast %struct.pollfd* %3 to i8*
%7 = bitcast [1 x %struct.hv_vss_msg]* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
br label %9
9: ; preds = %9, %2
%10 = phi i1 [ false, %2 ], [ true, %9 ]
%11 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %5)
switch i32 %11, label %15 [
i32 -1, label %19
i32 110, label %9
i32 104, label %12
]
12: ; preds = %9
%13 = call i32 @print_usage(i8** %1)
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %9
%16 = call i32 @print_usage(i8** %1)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %9
br i1 %10, label %23, label %20
20: ; preds = %19
%21 = call i64 @daemon(i32 1, i32 0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %136
23: ; preds = %20, %19
%24 = load i32, i32* @LOG_USER
%25 = call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %24)
%26 = load i32, i32* @LOG_INFO
%27 = call i32 (...) @getpid()
%28 = call i32 (i32, i8*, ...) @syslog(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @O_RDWR
%30 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %23
%33 = load i32, i32* @LOG_ERR
%34 = load i64, i64* @errno
%35 = call i8* @strerror(i64 %34)
%36 = call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i64 %34, i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %23
%40 = load i32, i32* @VSS_OP_REGISTER1
%41 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %4, i64 0, i64 0
%42 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %4, i64 0, i64 0, i32 1, i32 0
store i32 %40, i32* %42
%43 = call i32 @write(i32 %30, %struct.hv_vss_msg* %41, i32 8)
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %39
%46 = load i32, i32* @LOG_ERR
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i32, i8*, ...) @syslog(i32 %46, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i64 %47, i8* %48)
%50 = call i32 @close(i32 %30)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %39
%54 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %3, i64 0, i32 0
store i32 %30, i32* %54
%55 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %3, i64 0, i32 2
%56 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %3, i64 0, i32 1
%57 = getelementptr inbounds [1 x %struct.hv_vss_msg], [1 x %struct.hv_vss_msg]* %4, i64 0, i64 0, i32 0
br label %58
58: ; preds = %127, %53
%59 = phi i1 [ false, %53 ], [ true, %127 ]
br label %60
60: ; preds = %58, %64
%61 = load i32, i32* @POLLIN
store i32 %61, i32* %55
store i64 0, i64* %56
%62 = call i64 @poll(%struct.pollfd* %3, i32 1, i32 -1)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %76
64: ; preds = %60
%65 = load i32, i32* @LOG_ERR
%66 = load i64, i64* @errno
%67 = call i8* @strerror(i64 %66)
%68 = call i32 (i32, i8*, ...) @syslog(i32 %65, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i64 %66, i8* %67)
%69 = load i64, i64* @errno
%70 = load i64, i64* @EINVAL
%71 = icmp eq i64 %69, %70
br i1 %71, label %72, label %60
72: ; preds = %64
%73 = call i32 @close(i32 %30)
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %60
%77 = call i32 @read(i32 %30, %struct.hv_vss_msg* %41, i32 8)
br i1 %59, label %89, label %78
78: ; preds = %76
%79 = icmp eq i32 %77, 4
br i1 %79, label %85, label %80
80: ; preds = %78
%81 = load i32, i32* @LOG_ERR
%82 = call i32 (i32, i8*, ...) @syslog(i32 %81, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %78
%86 = load i32, i32* %57
%87 = load i32, i32* @LOG_INFO
%88 = call i32 (i32, i8*, ...) @syslog(i32 %87, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %86)
br label %127
89: ; preds = %76
%90 = icmp eq i32 %77, 8
br i1 %90, label %98, label %91
91: ; preds = %89
%92 = load i32, i32* @LOG_ERR
%93 = load i64, i64* @errno
%94 = call i8* @strerror(i64 %93)
%95 = call i32 (i32, i8*, ...) @syslog(i32 %92, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i64 %93, i8* %94)
%96 = call i32 @close(i32 %30)
%97 = load i32, i32* @EXIT_FAILURE
br label %136
98: ; preds = %89
%99 = load i32, i32* %42
%100 = load i32, i32* @HV_S_OK
switch i32 %99, label %120 [
i32 131, label %101
i32 129, label %101
i32 130, label %117
]
101: ; preds = %98, %98
%102 = call i32 @vss_operate(i32 %99)
%103 = load i32, i32* @LOG_INFO
%104 = icmp eq i32 %99, 131
%105 = select i1 %104, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0)
%106 = icmp eq i32 %102, 0
%107 = select i1 %106, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0)
%108 = call i32 (i32, i8*, ...) @syslog(i32 %103, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* %105, i8* %107)
br i1 %106, label %123, label %109
109: ; preds = %101
%110 = load i32, i32* @HV_E_FAIL
%111 = load i32, i32* @LOG_ERR
%112 = call i32 (i32, i8*, ...) @syslog(i32 %111, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i32 %99)
%113 = load i32, i32* @LOG_ERR
%114 = call i32 (i32, i8*, ...) @syslog(i32 %113, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0))
%115 = load i32, i32* @LOG_ERR
%116 = call i32 (i32, i8*, ...) @syslog(i32 %115, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0))
br label %123
117: ; preds = %98
%118 = load i32, i32* @LOG_INFO
%119 = call i32 (i32, i8*, ...) @syslog(i32 %118, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.20, i64 0, i64 0))
br label %123
120: ; preds = %98
%121 = load i32, i32* @LOG_ERR
%122 = call i32 (i32, i8*, ...) @syslog(i32 %121, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i32 %99)
br label %123
123: ; preds = %101, %109, %120, %117
%124 = phi i32 [ %100, %120 ], [ %100, %117 ], [ %110, %109 ], [ 0, %101 ]
store i32 %124, i32* %57
%125 = call i32 @write(i32 %30, %struct.hv_vss_msg* %41, i32 8)
%126 = icmp eq i32 %125, 8
br i1 %126, label %127, label %128
127: ; preds = %123, %134, %128, %85
br label %58
128: ; preds = %123
%129 = load i32, i32* @LOG_ERR
%130 = load i64, i64* @errno
%131 = call i8* @strerror(i64 %130)
%132 = call i32 (i32, i8*, ...) @syslog(i32 %129, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.22, i64 0, i64 0), i64 %130, i8* %131)
%133 = icmp eq i32 %99, 131
br i1 %133, label %134, label %127
134: ; preds = %128
%135 = call i32 @vss_operate(i32 129)
br label %127
136: ; preds = %20, %91
%137 = phi i32 [ %97, %91 ], [ 1, %20 ]
ret i32 %137
}