#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 */
struct hv_start_fcopy {
  int dummy;
};
struct hv_fcopy_hdr {
  int operation;
};
struct hv_do_fcopy {
  int dummy;
};

/* Variables and functions */
#define CANCEL_FCOPY 131
#define COMPLETE_FCOPY 130
int /*<<< orphan*/ EXIT_FAILURE;
int FCOPY_CURRENT_VERSION;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ O_RDWR;
#define START_FILE_COPY 129
#define WRITE_TO_FILE 128
scalar_t__ daemon(int, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int hv_copy_cancel();
int hv_copy_data(struct hv_do_fcopy *);
int hv_copy_finished();
int hv_start_fcopy(struct hv_start_fcopy *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int pread(int, char **, int, int /*<<< orphan*/);
int pwrite(int, int *, int, int /*<<< orphan*/);
int strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int, ...);
int write(int, int *, int);
int main(void) {
  int fd, fcopy_fd, len;
  int error;
  int version = FCOPY_CURRENT_VERSION;
  char *buffer[4096 * 2];
  struct hv_fcopy_hdr *in_msg;
  if (daemon(1, 0)) {
    syslog(LOG_ERR, "daemon() failed; error: %s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  openlog("HV_FCOPY", 0, LOG_USER);
  syslog(LOG_INFO, "HV_FCOPY starting; pid is:%d", getpid());
  fcopy_fd = open("/dev/vmbus/hv_fcopy", O_RDWR);
  if (fcopy_fd < 0) {
    syslog(LOG_ERR, "open /dev/vmbus/hv_fcopy failed; error: %d %s", errno,
           strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((write(fcopy_fd, &version, sizeof(int))) != sizeof(int)) {
    syslog(LOG_ERR, "Registration failed: %s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (1) {
    len = pread(fcopy_fd, buffer, (4096 * 2), 0);
    if (len < 0) {
      syslog(LOG_ERR, "pread failed: %s", strerror(errno));
      exit(EXIT_FAILURE);
    }
    in_msg = (struct hv_fcopy_hdr *)buffer;
    switch (in_msg->operation) {
    case START_FILE_COPY:
      error = hv_start_fcopy((struct hv_start_fcopy *)in_msg);
      break;
    case WRITE_TO_FILE:
      error = hv_copy_data((struct hv_do_fcopy *)in_msg);
      break;
    case COMPLETE_FCOPY:
      error = hv_copy_finished();
      break;
    case CANCEL_FCOPY:
      error = hv_copy_cancel();
      break;
    default:
      syslog(LOG_ERR, "Unknown operation: %d", in_msg->operation);
    }
    if (pwrite(fcopy_fd, &error, sizeof(int), 0) != sizeof(int)) {
      syslog(LOG_ERR, "pwrite failed: %s", strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10050,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <daemon@plt>
cmp    $0x0,%rax
je     1255 <main+0x75>
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1002c(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1002c(%rbp),%edi
mov    %eax,%edx
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edx
lea    0xdc6(%rip),%rdi
xor    %esi,%esi
call   10d0 <openlog@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10030(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x10030(%rbp),%edi
mov    %eax,%edx
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
lea    0xda9(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1310 <main+0x130>
mov    0x2cef(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10038(%rbp)
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10034(%rbp)
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x10038(%rbp),%edi
mov    -0x10034(%rbp),%edx
mov    %eax,%ecx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cltq
cmp    $0x4,%rax
je     136e <main+0x18e>
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1003c(%rbp)
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1003c(%rbp),%edi
mov    %eax,%edx
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1373 <main+0x193>
mov    -0xc(%rbp),%edi
lea    -0x10020(%rbp),%rsi
mov    $0x2000,%edx
xor    %ecx,%ecx
call   10c0 <pread@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    13d7 <main+0x1f7>
mov    0x2c13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10040(%rbp)
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x10040(%rbp),%edi
mov    %eax,%edx
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0x10020(%rbp),%rax
mov    %rax,-0x10028(%rbp)
mov    -0x10028(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10048(%rbp)
sub    $0x3,%eax
ja     1460 <main+0x280>
mov    -0x10048(%rbp),%rax
lea    0xbef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10028(%rbp),%rdi
call   1060 <hv_start_fcopy@plt>
mov    %eax,-0x14(%rbp)
jmp    1480 <main+0x2a0>
mov    -0x10028(%rbp),%rdi
call   10f0 <hv_copy_data@plt>
mov    %eax,-0x14(%rbp)
jmp    1480 <main+0x2a0>
mov    $0x0,%al
call   1080 <hv_copy_finished@plt>
mov    %eax,-0x14(%rbp)
jmp    1480 <main+0x2a0>
mov    $0x0,%al
call   1050 <hv_copy_cancel@plt>
mov    %eax,-0x14(%rbp)
jmp    1480 <main+0x2a0>
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
mov    -0x10028(%rbp),%rax
mov    (%rax),%edx
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    -0xc(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <pwrite@plt>
cltq
cmp    $0x4,%rax
je     14e0 <main+0x300>
mov    0x2b0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1004c(%rbp)
mov    0x2b1b(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1004c(%rbp),%edi
mov    %eax,%edx
lea    0xc07(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1373 <main+0x193>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10018,%rsp
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <daemon@plt>
test   %rax,%rax
jne    1297 <main+0xb7>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
lea    0xe08(%rip),%rdi
xor    %esi,%esi
call   10d0 <openlog@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdf3(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
lea    0xdf5(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
jns    12ba <main+0xda>
mov    0x2d44(%rip),%rax
mov    (%rax),%ebx
mov    0x2d5b(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1100 <strerror@plt>
lea    0xde0(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <syslog@plt>
jmp    13ee <main+0x20e>
mov    0x2d12(%rip),%rax
mov    (%rax),%ebx
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xd5b(%rip),%rsi
jmp    13e3 <main+0x203>
mov    %eax,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0x4,%eax
jne    138f <main+0x1af>
lea    0x10(%rsp),%r14
mov    0x2cce(%rip),%r13
lea    0xdd3(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xd0b(%rip),%rbp
jmp    132a <main+0x14a>
mov    0x0(%r13),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <syslog@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <pwrite@plt>
cmp    $0x4,%eax
jne    13af <main+0x1cf>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x2000,%edx
xor    %ecx,%ecx
call   10c0 <pread@plt>
test   %eax,%eax
js     13ca <main+0x1ea>
mov    0x10(%rsp),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
ja     12f7 <main+0x117>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r14,%rdi
call   10f0 <hv_copy_data@plt>
mov    %eax,0x8(%rsp)
jmp    1310 <main+0x130>
mov    %r14,%rdi
call   1060 <hv_start_fcopy@plt>
mov    %eax,0x8(%rsp)
jmp    1310 <main+0x130>
xor    %eax,%eax
call   1080 <hv_copy_finished@plt>
mov    %eax,0x8(%rsp)
jmp    1310 <main+0x130>
xor    %eax,%eax
call   1050 <hv_copy_cancel@plt>
mov    %eax,0x8(%rsp)
jmp    1310 <main+0x130>
mov    0x2c1a(%rip),%rax
mov    (%rax),%ebx
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xce6(%rip),%rsi
jmp    13e3 <main+0x203>
mov    0x0(%r13),%ebx
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xd0a(%rip),%rsi
jmp    13e3 <main+0x203>
mov    0x0(%r13),%ebx
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xcc8(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.hv_fcopy_hdr = type { i32 }
%struct.hv_start_fcopy = type { i32 }
%struct.hv_do_fcopy = type { i32 }
@FCOPY_CURRENT_VERSION = global i32 0
@LOG_ERR = global i32 0
@.str = [27 x i8] c"daemon() failed; error: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"HV_FCOPY\00"
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.2 = [29 x i8] c"HV_FCOPY starting; pid is:%d\00"
@.str.3 = [20 x i8] c"/dev/vmbus/hv_fcopy\00"
@O_RDWR = global i32 0
@.str.4 = [46 x i8] c"open /dev/vmbus/hv_fcopy failed; error: %d %s\00"
@.str.5 = [24 x i8] c"Registration failed: %s\00"
@.str.6 = [17 x i8] c"pread failed: %s\00"
@.str.7 = [22 x i8] c"Unknown operation: %d\00"
@.str.8 = [18 x i8] c"pwrite failed: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8192 x i8*]
%8 = alloca %struct.hv_fcopy_hdr*
store i32 0, i32* %1
%9 = load i32, i32* @FCOPY_CURRENT_VERSION
store i32 %9, i32* %6
%10 = call i64 @daemon(i32 1, i32 0)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %0
%13 = load i32, i32* @LOG_ERR
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 (i32, i8*, i32, ...) @syslog(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %0
%20 = load i32, i32* @LOG_USER
%21 = call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %20)
%22 = load i32, i32* @LOG_INFO
%23 = call i32 (...) @getpid()
%24 = call i32 (i32, i8*, i32, ...) @syslog(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @O_RDWR
%26 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %25)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %19
%30 = load i32, i32* @LOG_ERR
%31 = load i32, i32* @errno
%32 = load i32, i32* @errno
%33 = call i32 @strerror(i32 %32)
%34 = call i32 (i32, i8*, i32, ...) @syslog(i32 %30, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %19
%38 = load i32, i32* %3
%39 = call i32 @write(i32 %38, i32* %6, i32 4)
%40 = sext i32 %39 to i64
%41 = icmp ne i64 %40, 4
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i32, i32* @LOG_ERR
%44 = load i32, i32* @errno
%45 = call i32 @strerror(i32 %44)
%46 = call i32 (i32, i8*, i32, ...) @syslog(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %37
br label %50
50: ; preds = %49, %99
%51 = load i32, i32* %3
%52 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %7, i64 0, i64 0
%53 = call i32 @pread(i32 %51, i8** %52, i32 8192, i32 0)
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %50
%57 = load i32, i32* @LOG_ERR
%58 = load i32, i32* @errno
%59 = call i32 @strerror(i32 %58)
%60 = call i32 (i32, i8*, i32, ...) @syslog(i32 %57, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %50
%64 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %7, i64 0, i64 0
%65 = bitcast i8** %64 to %struct.hv_fcopy_hdr*
store %struct.hv_fcopy_hdr* %65, %struct.hv_fcopy_hdr** %8
%66 = load %struct.hv_fcopy_hdr*, %struct.hv_fcopy_hdr** %8
%67 = getelementptr inbounds %struct.hv_fcopy_hdr, %struct.hv_fcopy_hdr* %66, i32 0, i32 0
%68 = load i32, i32* %67
switch i32 %68, label %81 [
i32 129, label %69
i32 128, label %73
i32 130, label %77
i32 131, label %79
]
69: ; preds = %63
%70 = load %struct.hv_fcopy_hdr*, %struct.hv_fcopy_hdr** %8
%71 = bitcast %struct.hv_fcopy_hdr* %70 to %struct.hv_start_fcopy*
%72 = call i32 @hv_start_fcopy(%struct.hv_start_fcopy* %71)
store i32 %72, i32* %5
br label %87
73: ; preds = %63
%74 = load %struct.hv_fcopy_hdr*, %struct.hv_fcopy_hdr** %8
%75 = bitcast %struct.hv_fcopy_hdr* %74 to %struct.hv_do_fcopy*
%76 = call i32 @hv_copy_data(%struct.hv_do_fcopy* %75)
store i32 %76, i32* %5
br label %87
77: ; preds = %63
%78 = call i32 (...) @hv_copy_finished()
store i32 %78, i32* %5
br label %87
79: ; preds = %63
%80 = call i32 (...) @hv_copy_cancel()
store i32 %80, i32* %5
br label %87
81: ; preds = %63
%82 = load i32, i32* @LOG_ERR
%83 = load %struct.hv_fcopy_hdr*, %struct.hv_fcopy_hdr** %8
%84 = getelementptr inbounds %struct.hv_fcopy_hdr, %struct.hv_fcopy_hdr* %83, i32 0, i32 0
%85 = load i32, i32* %84
%86 = call i32 (i32, i8*, i32, ...) @syslog(i32 %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %81, %79, %77, %73, %69
%88 = load i32, i32* %3
%89 = call i32 @pwrite(i32 %88, i32* %5, i32 4, i32 0)
%90 = sext i32 %89 to i64
%91 = icmp ne i64 %90, 4
br i1 %91, label %92, label %99
92: ; preds = %87
%93 = load i32, i32* @LOG_ERR
%94 = load i32, i32* @errno
%95 = call i32 @strerror(i32 %94)
%96 = call i32 (i32, i8*, i32, ...) @syslog(i32 %93, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %95)
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %87
br label %50
}

LLVM IR (-O2):
%struct.hv_do_fcopy = type { i32 }
%struct.hv_start_fcopy = type { i32 }
@FCOPY_CURRENT_VERSION = global i32 0
@LOG_ERR = global i32 0
@.str = [27 x i8] c"daemon() failed; error: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"HV_FCOPY\00"
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.2 = [29 x i8] c"HV_FCOPY starting; pid is:%d\00"
@.str.3 = [20 x i8] c"/dev/vmbus/hv_fcopy\00"
@O_RDWR = global i32 0
@.str.4 = [46 x i8] c"open /dev/vmbus/hv_fcopy failed; error: %d %s\00"
@.str.5 = [24 x i8] c"Registration failed: %s\00"
@.str.6 = [17 x i8] c"pread failed: %s\00"
@.str.7 = [22 x i8] c"Unknown operation: %d\00"
@.str.8 = [18 x i8] c"pwrite failed: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8192 x i8*]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = load i32, i32* @FCOPY_CURRENT_VERSION
store i32 %6, i32* %2
%7 = bitcast [8192 x i8*]* %3 to i8*
%8 = tail call i64 @daemon(i32 1, i32 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %0
%11 = load i32, i32* @LOG_ERR
%12 = load i32, i32* @errno
%13 = tail call i32 @strerror(i32 %12)
%14 = tail call i32 (i32, i8*, i32, ...) @syslog(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %0
%18 = load i32, i32* @LOG_USER
%19 = tail call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %18)
%20 = load i32, i32* @LOG_INFO
%21 = tail call i32 (...) @getpid()
%22 = tail call i32 (i32, i8*, i32, ...) @syslog(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @O_RDWR
%24 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %17
%27 = load i32, i32* @LOG_ERR
%28 = load i32, i32* @errno
%29 = tail call i32 @strerror(i32 %28)
%30 = tail call i32 (i32, i8*, i32, ...) @syslog(i32 %27, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %17
%34 = call i32 @write(i32 %24, i32* %2, i32 4)
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %3, i64 0, i64 0
%38 = bitcast [8192 x i8*]* %3 to i32*
%39 = bitcast [8192 x i8*]* %3 to %struct.hv_do_fcopy*
%40 = bitcast [8192 x i8*]* %3 to %struct.hv_start_fcopy*
br label %48
41: ; preds = %33
%42 = load i32, i32* @LOG_ERR
%43 = load i32, i32* @errno
%44 = tail call i32 @strerror(i32 %43)
%45 = tail call i32 (i32, i8*, i32, ...) @syslog(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %36, %71
%49 = call i32 @pread(i32 %24, i8** %37, i32 8192, i32 0)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i32, i32* @LOG_ERR
%53 = load i32, i32* @errno
%54 = call i32 @strerror(i32 %53)
%55 = call i32 (i32, i8*, i32, ...) @syslog(i32 %52, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %48
%59 = load i32, i32* %38
switch i32 %59, label %68 [
i32 129, label %60
i32 128, label %62
i32 130, label %64
i32 131, label %66
]
60: ; preds = %58
%61 = call i32 @hv_start_fcopy(%struct.hv_start_fcopy* %40)
store i32 %61, i32* %1
br label %71
62: ; preds = %58
%63 = call i32 @hv_copy_data(%struct.hv_do_fcopy* %39)
store i32 %63, i32* %1
br label %71
64: ; preds = %58
%65 = call i32 (...) @hv_copy_finished()
store i32 %65, i32* %1
br label %71
66: ; preds = %58
%67 = call i32 (...) @hv_copy_cancel()
store i32 %67, i32* %1
br label %71
68: ; preds = %58
%69 = load i32, i32* @LOG_ERR
%70 = call i32 (i32, i8*, i32, ...) @syslog(i32 %69, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %59)
br label %71
71: ; preds = %68, %66, %64, %62, %60
%72 = call i32 @pwrite(i32 %24, i32* %1, i32 4, i32 0)
%73 = icmp eq i32 %72, 4
br i1 %73, label %48, label %74
74: ; preds = %71
%75 = load i32, i32* @LOG_ERR
%76 = load i32, i32* @errno
%77 = call i32 @strerror(i32 %76)
%78 = call i32 (i32, i8*, i32, ...) @syslog(i32 %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
}