#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 */

/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int ioctl(int, unsigned int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *, char *,
                          int /*<<< orphan*/);
int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op) {
  int ret, fd = open(dir, O_RDONLY);
  if (fd < 0)
    return 1;
  ret = ioctl(fd, cmd, 0);
  syslog(LOG_INFO, "VSS: %s of %s: %s\n", fs_op, dir, strerror(errno));
  close(fd);
  return !!ret;
}


x86 assembly (clang, -O0):
<vss_do_freeze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    118e <vss_do_freeze+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    11fd <vss_do_freeze+0xad>
mov    -0x28(%rbp),%edi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %eax,%r8d
lea    0xe23(%rip),%rsi
call   1050 <syslog@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vss_do_freeze>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
test   %eax,%eax
js     11c5 <vss_do_freeze+0x75>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15d,%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
mov    %eax,%r15d
mov    0x2e45(%rip),%rax
mov    (%rax),%r12d
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe5d(%rip),%rsi
mov    %r12d,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1050 <syslog@plt>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %eax,%eax
test   %r15d,%r15d
setne  %al
jmp    11ca <vss_do_freeze+0x7a>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@LOG_INFO = global i32 0
@.str = [19 x i8] c"VSS: %s of %s: %s\0A\00"
@errno = global i32 0
define i32 @vss_do_freeze(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 1, i32* %4
br label %33
16: ; preds = %3
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = call i32 @ioctl(i32 %17, i32 %18, i32 0)
store i32 %19, i32* %8
%20 = load i32, i32* @LOG_INFO
%21 = load i8*, i8** %7
%22 = load i8*, i8** %5
%23 = load i32, i32* @errno
%24 = call i32 @strerror(i32 %23)
%25 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22, i32 %24)
%26 = load i32, i32* %9
%27 = call i32 @close(i32 %26)
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
%31 = xor i1 %30, true
%32 = zext i1 %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %16, %15
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@LOG_INFO = global i32 0
@.str = [19 x i8] c"VSS: %s of %s: %s\0A\00"
@errno = global i32 0
define i32 @vss_do_freeze(i8* %0, i32 %1, i8* %2) {
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* %0, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = tail call i32 @ioctl(i32 %5, i32 %1, i32 0)
%9 = load i32, i32* @LOG_INFO
%10 = load i32, i32* @errno
%11 = tail call i32 @strerror(i32 %10)
%12 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %0, i32 %11)
%13 = tail call i32 @close(i32 %5)
%14 = icmp ne i32 %8, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %3, %7
%17 = phi i32 [ %15, %7 ], [ 1, %3 ]
ret i32 %17
}