#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 stat {
  int /*<<< orphan*/ st_rdev;
};
struct mntent {
  char *mnt_type;
  char *mnt_dir;
  int /*<<< orphan*/ mnt_fsname;
};
typedef int /*<<< orphan*/ errdir;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int FIFREEZE;
unsigned int FITHAW;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ MNTOPT_RO;
#define VSS_OP_FREEZE 129
#define VSS_OP_THAW 128
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
int errno;
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ *hasmntopt(struct mntent *, int /*<<< orphan*/);
scalar_t__ is_dev_loop(char *);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ *setmntent(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
scalar_t__ stat(int /*<<< orphan*/, struct stat *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int vss_do_freeze(char *, unsigned int);
int vss_operate(int operation) {
  char match[] = "/dev/";
  FILE *mounts;
  struct mntent *ent;
  struct stat sb;
  char errdir[1024] = {0};
  char blkdir[23];
  unsigned int cmd;
  int error = 0, root_seen = 0, save_errno = 0;
  switch (operation) {
  case VSS_OP_FREEZE:
    cmd = FIFREEZE;
    break;
  case VSS_OP_THAW:
    cmd = FITHAW;
    break;
  default:
    return -1;
  }
  mounts = setmntent("/proc/mounts", "r");
  if (mounts == NULL)
    return -1;
  while ((ent = getmntent(mounts))) {
    if (strncmp(ent->mnt_fsname, match, strlen(match)))
      continue;
    if (stat(ent->mnt_fsname, &sb)) {
      syslog(LOG_ERR, "Can't stat: %s; error:%d %s!", ent->mnt_fsname, errno,
             strerror(errno));
    } else {
      sprintf(blkdir, "/sys/dev/block/%d:%d", major(sb.st_rdev),
              minor(sb.st_rdev));
      if (is_dev_loop(blkdir))
        continue;
    }
    if (hasmntopt(ent, MNTOPT_RO) != NULL)
      continue;
    if (strcmp(ent->mnt_type, "vfat") == 0)
      continue;
    if (strcmp(ent->mnt_dir, "/") == 0) {
      root_seen = 1;
      continue;
    }
    error |= vss_do_freeze(ent->mnt_dir, cmd);
    if (error && operation == VSS_OP_FREEZE)
      goto err;
  }
  endmntent(mounts);
  if (root_seen) {
    error |= vss_do_freeze("/", cmd);
    if (error && operation == VSS_OP_FREEZE)
      goto err;
  }
  goto out;
err:
  save_errno = errno;
  if (ent) {
    strncpy(errdir, ent->mnt_dir, sizeof(errdir) - 1);
    endmntent(mounts);
  }
  vss_operate(VSS_OP_THAW);
  if (ent)
    syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s", errdir, save_errno,
           strerror(save_errno));
  else
    syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno,
           strerror(save_errno));
out:
  return error;
}


x86 assembly (clang, -O0):
<vss_operate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
mov    %edi,-0x8(%rbp)
movw   $0x2f,-0xc(%rbp)
movl   $0x7665642f,-0x10(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10a0 <memset@plt>
movl   $0x0,-0x458(%rbp)
movl   $0x0,-0x45c(%rbp)
movl   $0x0,-0x460(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x464(%rbp)
sub    $0x80,%eax
je     12af <vss_operate+0x8f>
jmp    1285 <vss_operate+0x65>
mov    -0x464(%rbp),%eax
sub    $0x81,%eax
jne    12c3 <vss_operate+0xa3>
jmp    129b <vss_operate+0x7b>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
jmp    12cf <vss_operate+0xaf>
mov    0x2d0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
jmp    12cf <vss_operate+0xaf>
movl   $0xffffffff,-0x4(%rbp)
jmp    1645 <vss_operate+0x425>
lea    0xd30(%rip),%rdi
lea    0xd36(%rip),%rsi
call   10f0 <setmntent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12fd <vss_operate+0xdd>
movl   $0xffffffff,-0x4(%rbp)
jmp    1645 <vss_operate+0x425>
jmp    1302 <vss_operate+0xe2>
mov    -0x18(%rbp),%rdi
call   10e0 <getmntent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     14ea <vss_operate+0x2ca>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x474(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x470(%rbp)
lea    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x474(%rbp),%edi
mov    -0x470(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     135d <vss_operate+0x13d>
jmp    1302 <vss_operate+0xe2>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%edi
lea    -0x28(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
je     13d8 <vss_operate+0x1b8>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x480(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x47c(%rbp)
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x478(%rbp)
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x480(%rbp),%edi
mov    -0x47c(%rbp),%edx
mov    -0x478(%rbp),%ecx
mov    %eax,%r8d
lea    0xc49(%rip),%rsi
mov    $0x0,%al
call   1100 <syslog@plt>
jmp    1437 <vss_operate+0x217>
lea    -0x450(%rbp),%rax
mov    %rax,-0x490(%rbp)
mov    -0x28(%rbp),%edi
call   1090 <major@plt>
mov    %eax,-0x484(%rbp)
mov    -0x28(%rbp),%edi
call   1070 <minor@plt>
mov    -0x490(%rbp),%rdi
mov    -0x484(%rbp),%edx
mov    %eax,%ecx
lea    0xc20(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x450(%rbp),%rdi
call   1060 <is_dev_loop@plt>
cmp    $0x0,%rax
je     1432 <vss_operate+0x212>
jmp    1302 <vss_operate+0xe2>
jmp    1437 <vss_operate+0x217>
mov    -0x20(%rbp),%rdi
mov    0x2ba6(%rip),%rax
mov    (%rax),%esi
call   1140 <hasmntopt@plt>
cmp    $0x0,%rax
je     1458 <vss_operate+0x238>
jmp    1302 <vss_operate+0xe2>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xbe1(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    147a <vss_operate+0x25a>
jmp    1302 <vss_operate+0xe2>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xb7b(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14a7 <vss_operate+0x287>
movl   $0x1,-0x45c(%rbp)
jmp    1302 <vss_operate+0xe2>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x454(%rbp),%esi
call   10b0 <vss_do_freeze@plt>
or     -0x458(%rbp),%eax
mov    %eax,-0x458(%rbp)
cmpl   $0x0,-0x458(%rbp)
je     14e5 <vss_operate+0x2c5>
cmpl   $0x81,-0x8(%rbp)
jne    14e5 <vss_operate+0x2c5>
jmp    1547 <vss_operate+0x327>
jmp    1302 <vss_operate+0xe2>
mov    -0x18(%rbp),%rdi
call   1030 <endmntent@plt>
cmpl   $0x0,-0x45c(%rbp)
je     1542 <vss_operate+0x322>
mov    -0x454(%rbp),%esi
lea    0xaf7(%rip),%rdi
call   10b0 <vss_do_freeze@plt>
or     -0x458(%rbp),%eax
mov    %eax,-0x458(%rbp)
cmpl   $0x0,-0x458(%rbp)
je     153d <vss_operate+0x31d>
cmpl   $0x81,-0x8(%rbp)
jne    153d <vss_operate+0x31d>
jmp    1547 <vss_operate+0x327>
jmp    1542 <vss_operate+0x322>
jmp    163c <vss_operate+0x41c>
mov    0x2a82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x460(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1583 <vss_operate+0x363>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <endmntent@plt>
mov    $0x80,%edi
call   1110 <vss_operate@plt>
cmpq   $0x0,-0x20(%rbp)
je     15f5 <vss_operate+0x3d5>
mov    0x2a19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4a4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
mov    -0x460(%rbp),%eax
mov    %eax,-0x494(%rbp)
mov    -0x460(%rbp),%edi
call   1130 <strerror@plt>
mov    -0x4a4(%rbp),%edi
mov    -0x4a0(%rbp),%rdx
mov    -0x494(%rbp),%ecx
mov    %eax,%r8d
lea    0xa63(%rip),%rsi
mov    $0x0,%al
call   1100 <syslog@plt>
jmp    1637 <vss_operate+0x417>
mov    0x29bc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4ac(%rbp)
mov    -0x460(%rbp),%eax
mov    %eax,-0x4a8(%rbp)
mov    -0x460(%rbp),%edi
call   1130 <strerror@plt>
mov    -0x4ac(%rbp),%edi
mov    -0x4a8(%rbp),%edx
mov    %eax,%ecx
lea    0xa3d(%rip),%rsi
mov    $0x0,%al
call   1100 <syslog@plt>
jmp    163c <vss_operate+0x41c>
mov    -0x458(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vss_operate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %edi,%ebx
movw   $0x2f,0x1c(%rsp)
movl   $0x7665642f,0x18(%rsp)
76
lea    0x40(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
mov    $0xffffffff,%r14d
cmp    $0x81,%ebx
je     1276 <vss_operate+0x56>
cmp    $0x80,%ebx
jne    14e3 <vss_operate+0x2c3>
mov    0x2d4c(%rip),%rax
jmp    127d <vss_operate+0x5d>
mov    0x2d63(%rip),%rax
mov    (%rax),%ebp
lea    0xd80(%rip),%rdi
lea    0xd86(%rip),%rsi
call   10f0 <setmntent@plt>
test   %rax,%rax
je     14e3 <vss_operate+0x2c3>
mov    %rax,%r12
mov    %ebp,0xc(%rsp)
mov    %ebx,0x10(%rsp)
lea    0x18(%rsp),%r15
xor    %eax,%eax
xor    %ecx,%ecx
mov    %eax,0x4(%rsp)
mov    %ecx,0x14(%rsp)
mov    %r12,%rdi
call   10e0 <getmntent@plt>
test   %rax,%rax
je     146f <vss_operate+0x24f>
mov    %rax,%r13
jmp    1324 <vss_operate+0x104>
mov    0x8(%rsp),%edi
call   1090 <major@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
call   1070 <minor@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
lea    0xd42(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
call   1120 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <is_dev_loop@plt>
test   %rax,%rax
je     138d <vss_operate+0x16d>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10e0 <getmntent@plt>
mov    %rax,%r13
test   %rax,%rax
je     146f <vss_operate+0x24f>
mov    0x10(%r13),%ebx
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    1310 <vss_operate+0xf0>
mov    0x10(%r13),%edi
lea    0x8(%rsp),%rsi
call   10d0 <stat@plt>
test   %rax,%rax
je     12cd <vss_operate+0xad>
mov    0x2c59(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%r13),%r14d
mov    0x2c64(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1130 <strerror@plt>
mov    %ebx,%edi
lea    0xc97(%rip),%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1100 <syslog@plt>
mov    0x2c54(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1140 <hasmntopt@plt>
test   %rax,%rax
jne    1310 <vss_operate+0xf0>
mov    0x0(%r13),%rdi
lea    0xc95(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1310 <vss_operate+0xf0>
mov    0x8(%r13),%rdi
lea    0xc39(%rip),%rsi
call   10c0 <strcmp@plt>
mov    $0x1,%ecx
test   %rax,%rax
je     12b3 <vss_operate+0x93>
mov    0x8(%r13),%rdi
mov    0xc(%rsp),%esi
call   10b0 <vss_do_freeze@plt>
mov    %eax,%r14d
or     0x4(%rsp),%r14d
mov    %r14d,%eax
cmpl   $0x81,0x10(%rsp)
mov    0x14(%rsp),%ecx
jne    12af <vss_operate+0x8f>
mov    %r14d,%eax
test   %r14d,%r14d
je     12af <vss_operate+0x8f>
mov    0x2bb5(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%r13),%rsi
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
mov    %r12,%rdi
call   1030 <endmntent@plt>
mov    $0x80,%edi
call   1110 <vss_operate@plt>
mov    0x2b6c(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1130 <strerror@plt>
lea    0xbf0(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1100 <syslog@plt>
jmp    14e3 <vss_operate+0x2c3>
mov    %r12,%rdi
call   1030 <endmntent@plt>
cmpl   $0x0,0x14(%rsp)
je     14de <vss_operate+0x2be>
lea    0xb7f(%rip),%rdi
mov    0xc(%rsp),%esi
call   10b0 <vss_do_freeze@plt>
mov    %eax,%r14d
or     0x4(%rsp),%r14d
cmpl   $0x81,0x10(%rsp)
jne    14e3 <vss_operate+0x2c3>
test   %r14d,%r14d
je     14e3 <vss_operate+0x2c3>
mov    0x2b24(%rip),%rax
mov    (%rax),%ebx
mov    $0x80,%edi
call   1110 <vss_operate@plt>
mov    0x2af9(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1130 <strerror@plt>
lea    0xb9e(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1100 <syslog@plt>
jmp    14e3 <vss_operate+0x2c3>
mov    0x4(%rsp),%r14d
mov    %r14d,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i8*, i8*, i32 }
%struct.stat = type { i32 }
@__const.vss_operate.match = [6 x i8] c"/dev/\00"
@FIFREEZE = global i32 0
@FITHAW = global i32 0
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@LOG_ERR = global i32 0
@.str.2 = [29 x i8] c"Can't stat: %s; error:%d %s!\00"
@errno = global i32 0
@.str.3 = [21 x i8] c"/sys/dev/block/%d:%d\00"
@MNTOPT_RO = global i32 0
@.str.4 = [5 x i8] c"vfat\00"
@.str.5 = [2 x i8] c"/\00"
@.str.6 = [33 x i8] c"FREEZE of %s failed; error:%d %s\00"
@.str.7 = [32 x i8] c"FREEZE of / failed; error:%d %s\00"
define i32 @vss_operate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
%5 = alloca i32*
%6 = alloca %struct.mntent*
%7 = alloca %struct.stat
%8 = alloca [1024 x i8]
%9 = alloca [23 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %3
%14 = bitcast [6 x i8]* %4 to i8*
%15 = bitcast [1024 x i8]* %8 to i8*
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%16 = load i32, i32* %3
switch i32 %16, label %21 [
i32 129, label %17
i32 128, label %19
]
17: ; preds = %1
%18 = load i32, i32* @FIFREEZE
store i32 %18, i32* %10
br label %22
19: ; preds = %1
%20 = load i32, i32* @FITHAW
store i32 %20, i32* %10
br label %22
21: ; preds = %1
store i32 -1, i32* %2
br label %156
22: ; preds = %19, %17
%23 = call i32* @setmntent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %5
%24 = load i32*, i32** %5
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 -1, i32* %2
br label %156
27: ; preds = %22
br label %28
28: ; preds = %105, %90, %83, %76, %69, %41, %27
%29 = load i32*, i32** %5
%30 = call %struct.mntent* @getmntent(i32* %29)
store %struct.mntent* %30, %struct.mntent** %6
%31 = icmp ne %struct.mntent* %30, null
br i1 %31, label %32, label %106
32: ; preds = %28
%33 = load %struct.mntent*, %struct.mntent** %6
%34 = getelementptr inbounds %struct.mntent, %struct.mntent* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = call i64 @strncmp(i32 %35, i8* %36, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %32
br label %28
42: ; preds = %32
%43 = load %struct.mntent*, %struct.mntent** %6
%44 = getelementptr inbounds %struct.mntent, %struct.mntent* %43, i32 0, i32 2
%45 = load i32, i32* %44
%46 = call i64 @stat(i32 %45, %struct.stat* %7)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %57
48: ; preds = %42
%49 = load i32, i32* @LOG_ERR
%50 = load %struct.mntent*, %struct.mntent** %6
%51 = getelementptr inbounds %struct.mntent, %struct.mntent* %50, i32 0, i32 2
%52 = load i32, i32* %51
%53 = load i32, i32* @errno
%54 = load i32, i32* @errno
%55 = call i32 @strerror(i32 %54)
%56 = call i32 (i32, i8*, ...) @syslog(i32 %49, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53, i32 %55)
br label %71
57: ; preds = %42
%58 = getelementptr inbounds [23 x i8], [23 x i8]* %9, i64 0, i64 0
%59 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i32 @major(i32 %60)
%62 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i32 @minor(i32 %63)
%65 = call i32 @sprintf(i8* %58, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %61, i32 %64)
%66 = getelementptr inbounds [23 x i8], [23 x i8]* %9, i64 0, i64 0
%67 = call i64 @is_dev_loop(i8* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %57
br label %28
70: ; preds = %57
br label %71
71: ; preds = %70, %48
%72 = load %struct.mntent*, %struct.mntent** %6
%73 = load i32, i32* @MNTOPT_RO
%74 = call i32* @hasmntopt(%struct.mntent* %72, i32 %73)
%75 = icmp ne i32* %74, null
br i1 %75, label %76, label %77
76: ; preds = %71
br label %28
77: ; preds = %71
%78 = load %struct.mntent*, %struct.mntent** %6
%79 = getelementptr inbounds %struct.mntent, %struct.mntent* %78, i32 0, i32 0
%80 = load i8*, i8** %79
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %77
br label %28
84: ; preds = %77
%85 = load %struct.mntent*, %struct.mntent** %6
%86 = getelementptr inbounds %struct.mntent, %struct.mntent* %85, i32 0, i32 1
%87 = load i8*, i8** %86
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %84
store i32 1, i32* %12
br label %28
91: ; preds = %84
%92 = load %struct.mntent*, %struct.mntent** %6
%93 = getelementptr inbounds %struct.mntent, %struct.mntent* %92, i32 0, i32 1
%94 = load i8*, i8** %93
%95 = load i32, i32* %10
%96 = call i32 @vss_do_freeze(i8* %94, i32 %95)
%97 = load i32, i32* %11
%98 = or i32 %97, %96
store i32 %98, i32* %11
%99 = load i32, i32* %11
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %91
%102 = load i32, i32* %3
%103 = icmp eq i32 %102, 129
br i1 %103, label %104, label %105
104: ; preds = %101
br label %124
105: ; preds = %101, %91
br label %28
106: ; preds = %28
%107 = load i32*, i32** %5
%108 = call i32 @endmntent(i32* %107)
%109 = load i32, i32* %12
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %123
111: ; preds = %106
%112 = load i32, i32* %10
%113 = call i32 @vss_do_freeze(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %112)
%114 = load i32, i32* %11
%115 = or i32 %114, %113
store i32 %115, i32* %11
%116 = load i32, i32* %11
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %111
%119 = load i32, i32* %3
%120 = icmp eq i32 %119, 129
br i1 %120, label %121, label %122
121: ; preds = %118
br label %124
122: ; preds = %118, %111
br label %123
123: ; preds = %122, %106
br label %154
124: ; preds = %121, %104
%125 = load i32, i32* @errno
store i32 %125, i32* %13
%126 = load %struct.mntent*, %struct.mntent** %6
%127 = icmp ne %struct.mntent* %126, null
br i1 %127, label %128, label %136
128: ; preds = %124
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%130 = load %struct.mntent*, %struct.mntent** %6
%131 = getelementptr inbounds %struct.mntent, %struct.mntent* %130, i32 0, i32 1
%132 = load i8*, i8** %131
%133 = call i32 @strncpy(i8* %129, i8* %132, i32 1023)
%134 = load i32*, i32** %5
%135 = call i32 @endmntent(i32* %134)
br label %136
136: ; preds = %128, %124
%137 = call i32 @vss_operate(i32 128)
%138 = load %struct.mntent*, %struct.mntent** %6
%139 = icmp ne %struct.mntent* %138, null
br i1 %139, label %140, label %147
140: ; preds = %136
%141 = load i32, i32* @LOG_ERR
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%143 = load i32, i32* %13
%144 = load i32, i32* %13
%145 = call i32 @strerror(i32 %144)
%146 = call i32 (i32, i8*, ...) @syslog(i32 %141, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %142, i32 %143, i32 %145)
br label %153
147: ; preds = %136
%148 = load i32, i32* @LOG_ERR
%149 = load i32, i32* %13
%150 = load i32, i32* %13
%151 = call i32 @strerror(i32 %150)
%152 = call i32 (i32, i8*, ...) @syslog(i32 %148, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %149, i32 %151)
br label %153
153: ; preds = %147, %140
br label %154
154: ; preds = %153, %123
%155 = load i32, i32* %11
store i32 %155, i32* %2
br label %156
156: ; preds = %154, %26, %21
%157 = load i32, i32* %2
ret i32 %157
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.mntent = type { i8*, i8*, i32 }
@__const.vss_operate.match = [6 x i8] c"/dev/\00"
@FIFREEZE = global i32 0
@FITHAW = global i32 0
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@LOG_ERR = global i32 0
@.str.2 = [29 x i8] c"Can't stat: %s; error:%d %s!\00"
@errno = global i32 0
@.str.3 = [21 x i8] c"/sys/dev/block/%d:%d\00"
@MNTOPT_RO = global i32 0
@.str.4 = [5 x i8] c"vfat\00"
@.str.5 = [2 x i8] c"/\00"
@.str.6 = [33 x i8] c"FREEZE of %s failed; error:%d %s\00"
@.str.7 = [32 x i8] c"FREEZE of / failed; error:%d %s\00"
define i32 @vss_operate(i32 %0) {
%2 = alloca [6 x i8]
%3 = alloca %struct.stat
%4 = alloca [1024 x i8]
%5 = alloca [23 x i8]
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = bitcast %struct.stat* %3 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [23 x i8], [23 x i8]* %5, i64 0, i64 0
switch i32 %0, label %99 [
i32 129, label %11
i32 128, label %10
]
10: ; preds = %1
br label %11
11: ; preds = %1, %10
%12 = phi i32* [ @FITHAW, %10 ], [ @FIFREEZE, %1 ]
%13 = load i32, i32* %12
%14 = tail call i32* @setmntent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %99, label %16
16: ; preds = %11
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%18 = icmp eq i32 %0, 129
br label %19
19: ; preds = %16, %68
%20 = phi i32 [ 0, %16 ], [ %72, %68 ]
%21 = phi i32 [ 0, %16 ], [ %23, %68 ]
br label %22
22: ; preds = %19, %63
%23 = phi i32 [ %21, %19 ], [ 1, %63 ]
%24 = call %struct.mntent* @getmntent(i32* %14)
%25 = icmp eq %struct.mntent* %24, null
br i1 %25, label %75, label %26
26: ; preds = %22, %33
%27 = phi %struct.mntent* [ %34, %33 ], [ %24, %22 ]
%28 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i64 0, i32 2
%29 = load i32, i32* %28
%30 = call i32 @strlen(i8* %6)
%31 = call i64 @strncmp(i32 %29, i8* %6, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %26, %46, %54, %58
%34 = call %struct.mntent* @getmntent(i32* %14)
%35 = icmp eq %struct.mntent* %34, null
br i1 %35, label %75, label %26
36: ; preds = %26
%37 = load i32, i32* %28
%38 = call i64 @stat(i32 %37, %struct.stat* %3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %36
%41 = load i32, i32* @LOG_ERR
%42 = load i32, i32* %28
%43 = load i32, i32* @errno
%44 = call i32 @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @syslog(i32 %41, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
br label %54
46: ; preds = %36
%47 = load i32, i32* %17
%48 = call i32 @major(i32 %47)
%49 = load i32, i32* %17
%50 = call i32 @minor(i32 %49)
%51 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %48, i32 %50)
%52 = call i64 @is_dev_loop(i8* %9)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %33
54: ; preds = %46, %40
%55 = load i32, i32* @MNTOPT_RO
%56 = call i32* @hasmntopt(%struct.mntent* %27, i32 %55)
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %33
58: ; preds = %54
%59 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i64 0, i32 0
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %33, label %63
63: ; preds = %58
%64 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i64 0, i32 1
%65 = load i8*, i8** %64
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %22, label %68
68: ; preds = %63
%69 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i64 0, i32 1
%70 = load i8*, i8** %69
%71 = call i32 @vss_do_freeze(i8* %70, i32 %13)
%72 = or i32 %71, %20
%73 = icmp ne i32 %72, 0
%74 = and i1 %18, %73
br i1 %74, label %83, label %19
75: ; preds = %22, %33
%76 = call i32 @endmntent(i32* %14)
%77 = icmp eq i32 %23, 0
br i1 %77, label %99, label %78
78: ; preds = %75
%79 = call i32 @vss_do_freeze(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%80 = or i32 %79, %20
%81 = icmp ne i32 %80, 0
%82 = and i1 %18, %81
br i1 %82, label %93, label %99
83: ; preds = %68
%84 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i64 0, i32 1
%85 = load i32, i32* @errno
%86 = load i8*, i8** %84
%87 = call i32 @strncpy(i8* %8, i8* %86, i32 1023)
%88 = call i32 @endmntent(i32* %14)
%89 = call i32 @vss_operate(i32 128)
%90 = load i32, i32* @LOG_ERR
%91 = call i32 @strerror(i32 %85)
%92 = call i32 (i32, i8*, ...) @syslog(i32 %90, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %8, i32 %85, i32 %91)
br label %99
93: ; preds = %78
%94 = load i32, i32* @errno
%95 = call i32 @vss_operate(i32 128)
%96 = load i32, i32* @LOG_ERR
%97 = call i32 @strerror(i32 %94)
%98 = call i32 (i32, i8*, ...) @syslog(i32 %96, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %94, i32 %97)
br label %99
99: ; preds = %78, %75, %93, %83, %11, %1
%100 = phi i32 [ -1, %1 ], [ -1, %11 ], [ %72, %83 ], [ %80, %93 ], [ %80, %78 ], [ %20, %75 ]
ret i32 %100
}