#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_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ strerror(scalar_t__);
int strlen(char const *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void verifyFile(const char *path, const char *file, const char *contents) {
  int fd;
  int file_path_length = 0;
  char *file_path = 0;
  char *buf = 0;
  int buf_length = 0;
  errno = 0;
  file_path_length = strlen(path) + strlen(file) + 1;
  file_path = (char *)malloc(sizeof(char) * file_path_length);
  snprintf(file_path, file_path_length, "%s%s", path, file);
  syslog(LOG_INFO, "File being monitored: %s", file_path);
  fd = open(file_path, O_RDONLY);
  free(file_path);
  if (fd == -1) {
    syslog(LOG_ERR, strerror(errno));
    exit(1);
  } else {
    buf_length = strlen(contents) + 1;
    buf = (char *)malloc(sizeof(char) * buf_length);
    if (read(fd, buf, buf_length - 1) == buf_length - 1) {
      buf[buf_length - 1] = '\0';
      if (strcmp(buf, contents) == 0) {
        free(buf);
        close(fd);
        exit(0);
      } else {
        printf("Content param does not match file content.");
      }
    } else {
      printf("Content read size mismatch.");
    }
  }
  if (errno != 0) {
    syslog(LOG_ERR, strerror(errno));
  }
  free(buf);
  close(fd);
  exit(1);
}


x86 assembly (clang, -O0):
<verifyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    0x2ddf(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xdb5(%rip),%rdx
call   1060 <snprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   10b0 <syslog@plt>
mov    -0x28(%rbp),%rdi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12c5 <verifyFile+0x105>
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%rdi
call   10e0 <strerror@plt>
mov    -0x3c(%rbp),%edi
movslq %eax,%rsi
mov    $0x0,%al
call   10b0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
call   1080 <read@plt>
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1358 <verifyFile+0x198>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1347 <verifyFile+0x187>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xcd0(%rip),%rdi
call   1050 <printf@plt>
jmp    1364 <verifyFile+0x1a4>
lea    0xcea(%rip),%rdi
call   1050 <printf@plt>
jmp    1369 <verifyFile+0x1a9>
mov    0x2c68(%rip),%rax
cmpq   $0x0,(%rax)
je     13a2 <verifyFile+0x1e2>
mov    0x2c3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%rdi
call   10e0 <strerror@plt>
mov    -0x40(%rbp),%edi
movslq %eax,%rsi
mov    $0x0,%al
call   10b0 <syslog@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<verifyFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2dfd(%rip),%r13
movq   $0x0,0x0(%r13)
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x1,%ebp
mov    %ebp,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
lea    0xdf7(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
mov    %r15,%r8
call   1060 <snprintf@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <syslog@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    $0xffffffff,%ebp
jne    127b <verifyFile+0xbb>
mov    0x2d66(%rip),%rax
mov    (%rax),%ebx
mov    0x0(%r13),%rdi
call   10e0 <strerror@plt>
movslq %eax,%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   10b0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %rax,%rsi
mov    %ebx,%edx
call   1080 <read@plt>
cmp    %ebx,%eax
jne    12ce <verifyFile+0x10e>
movslq %ebx,%rax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    12d7 <verifyFile+0x117>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xd74(%rip),%rdi
jmp    12de <verifyFile+0x11e>
lea    0xd40(%rip),%rdi
call   1050 <printf@plt>
mov    0x0(%r13),%rdi
test   %rdi,%rdi
je     1306 <verifyFile+0x146>
mov    0x2ccd(%rip),%rax
mov    (%rax),%ebx
call   10e0 <strerror@plt>
movslq %eax,%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   10b0 <syslog@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [5 x i8] c"%s%s\00"
@LOG_INFO = global i32 0
@.str.1 = [25 x i8] c"File being monitored: %s\00"
@O_RDONLY = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [43 x i8] c"Content param does not match file content.\00"
@.str.3 = [28 x i8] c"Content read size mismatch.\00"
define void @verifyFile(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %8
store i8* null, i8** %9
store i8* null, i8** %10
store i32 0, i32* %11
store i64 0, i64* @errno
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = mul i64 1, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = load i32, i32* %8
%26 = load i8*, i8** %4
%27 = load i8*, i8** %5
%28 = call i32 @snprintf(i8* %24, i32 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
%29 = load i32, i32* @LOG_INFO
%30 = load i8*, i8** %9
%31 = call i32 (i32, i8*, ...) @syslog(i32 %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %9
%33 = load i32, i32* @O_RDONLY
%34 = call i32 @open(i8* %32, i32 %33)
store i32 %34, i32* %7
%35 = load i8*, i8** %9
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %47
39: ; preds = %3
%40 = load i32, i32* @LOG_ERR
%41 = load i64, i64* @errno
%42 = call i32 @strerror(i64 %41)
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i8*
%45 = call i32 (i32, i8*, ...) @syslog(i32 %40, i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %3
%48 = load i8*, i8** %6
%49 = call i32 @strlen(i8* %48)
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = mul i64 1, %52
%54 = trunc i64 %53 to i32
%55 = call i64 @malloc(i32 %54)
%56 = inttoptr i64 %55 to i8*
store i8* %56, i8** %10
%57 = load i32, i32* %7
%58 = load i8*, i8** %10
%59 = load i32, i32* %11
%60 = sub nsw i32 %59, 1
%61 = call i32 @read(i32 %57, i8* %58, i32 %60)
%62 = load i32, i32* %11
%63 = sub nsw i32 %62, 1
%64 = icmp eq i32 %61, %63
br i1 %64, label %65, label %84
65: ; preds = %47
%66 = load i8*, i8** %10
%67 = load i32, i32* %11
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
store i8 0, i8* %70
%71 = load i8*, i8** %10
%72 = load i8*, i8** %6
%73 = call i64 @strcmp(i8* %71, i8* %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %65
%76 = load i8*, i8** %10
%77 = call i32 @free(i8* %76)
%78 = load i32, i32* %7
%79 = call i32 @close(i32 %78)
%80 = call i32 @exit(i32 0)
unreachable
81: ; preds = %65
%82 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %83
83: ; preds = %81
br label %86
84: ; preds = %47
%85 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %86
86: ; preds = %84, %83
br label %87
87: ; preds = %86
%88 = load i64, i64* @errno
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %97
90: ; preds = %87
%91 = load i32, i32* @LOG_ERR
%92 = load i64, i64* @errno
%93 = call i32 @strerror(i64 %92)
%94 = sext i32 %93 to i64
%95 = inttoptr i64 %94 to i8*
%96 = call i32 (i32, i8*, ...) @syslog(i32 %91, i8* %95)
br label %97
97: ; preds = %90, %87
%98 = load i8*, i8** %10
%99 = call i32 @free(i8* %98)
%100 = load i32, i32* %7
%101 = call i32 @close(i32 %100)
%102 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [5 x i8] c"%s%s\00"
@LOG_INFO = global i32 0
@.str.1 = [25 x i8] c"File being monitored: %s\00"
@O_RDONLY = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [43 x i8] c"Content param does not match file content.\00"
@.str.3 = [28 x i8] c"Content read size mismatch.\00"
define void @verifyFile(i8* %0, i8* %1, i8* %2) {
store i64 0, i64* @errno
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 1
%7 = add i32 %6, %5
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%11 = load i32, i32* @LOG_INFO
%12 = tail call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %9, i32 %13)
%15 = tail call i32 @free(i8* %9)
%16 = icmp eq i32 %14, -1
br i1 %16, label %17, label %25
17: ; preds = %3
%18 = load i32, i32* @LOG_ERR
%19 = load i64, i64* @errno
%20 = tail call i32 @strerror(i64 %19)
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = tail call i32 (i32, i8*, ...) @syslog(i32 %18, i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %3
%26 = tail call i32 @strlen(i8* %2)
%27 = add nsw i32 %26, 1
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
%30 = tail call i32 @read(i32 %14, i8* %29, i32 %26)
%31 = icmp eq i32 %30, %26
br i1 %31, label %32, label %41
32: ; preds = %25
%33 = sext i32 %26 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
store i8 0, i8* %34
%35 = tail call i64 @strcmp(i8* %29, i8* %2)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = tail call i32 @free(i8* %29)
%39 = tail call i32 @close(i32 %14)
%40 = tail call i32 @exit(i32 0)
unreachable
41: ; preds = %25, %32
%42 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), %32 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), %25 ]
%43 = tail call i32 @printf(i8* dereferenceable(1) %42)
%44 = load i64, i64* @errno
%45 = icmp eq i64 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %41
%47 = load i32, i32* @LOG_ERR
%48 = tail call i32 @strerror(i64 %44)
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i8*
%51 = tail call i32 (i32, i8*, ...) @syslog(i32 %47, i8* %50)
br label %52
52: ; preds = %46, %41
%53 = tail call i32 @free(i8* %29)
%54 = tail call i32 @close(i32 %14)
%55 = tail call i32 @exit(i32 1)
unreachable
}