#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*/ member_0;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fprintf(int /*<<< orphan*/ *, char *, char *);
char *getUserName();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ read_watcher_file(char *, int, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ *stdout;
char *str_date_log(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
char *string_date_time(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *,
                          int /*<<< orphan*/);
void write_log_file(char *log_path, char *log_message, int watch_id) {
  FILE *log_file = NULL;
  int ret = -1;
  char log_file_name[150] = "/root/logs/";
  char log_date[50];
  char *log_date_buff = str_date_log(log_date);
  strcat(log_file_name, log_path);
  struct stat st = {0};
  if (stat(log_file_name, &st) == -1) {
    mkdir(log_file_name, 0700);
  }
  strcat(log_file_name, "/");
  strcat(log_file_name, log_date_buff);
  strcat(log_file_name, ".log");
  char date[50];
  char *time_buff = string_date_time(date);
  char str_message[700];
  char directory_path[300];
  memset(directory_path, 0, 300);
  log_file = fopen(log_file_name, "a+");
  memset(str_message, 0, 700);
  strcat(str_message, time_buff);
  strcat(str_message, " ");
  strcat(str_message, getUserName());
  strcat(str_message, " ");
  if (watch_id != -1) {
    read_watcher_file(log_message, watch_id, directory_path);
    strcat(str_message, directory_path);
  }
  strcat(str_message, " ");
  strcat(str_message, log_message);
  strcat(str_message, "\n");
  ret = fprintf(log_file, "%s", str_message);
  if (ret < 0) {
    syslog(LOG_ERR, "Can not write to log stream: %s, error: %s",
           (log_file == stdout) ? "stdout" : "daemon1", strerror(errno));
  }
  ret = fflush(log_file);
  if (ret != 0) {
    syslog(LOG_ERR, "Can not fflush() log stream: %s, error: %s",
           (log_file == stdout) ? "stdout" : "daemon1", strerror(errno));
  }
  fclose(log_file);
}


x86 assembly (clang, -O0):
<write_log_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x580,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xddd(%rip),%rsi
mov    $0x96,%edx
call   1090 <memcpy@plt>
lea    -0x100(%rbp),%rdi
call   10a0 <str_date_log@plt>
mov    %rax,-0x108(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    1290 <write_log_file+0xa0>
lea    -0xc0(%rbp),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
lea    -0xc0(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1100 <strcat@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x108(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0xc0(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x150(%rbp),%rdi
call   1070 <string_date_time@plt>
mov    %rax,-0x158(%rbp)
lea    -0x550(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1050 <memset@plt>
lea    -0xc0(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x2bc,%edx
call   1050 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    -0x158(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x558(%rbp)
mov    $0x0,%al
call   10e0 <getUserName@plt>
mov    -0x558(%rbp),%rdi
mov    %rax,%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   1100 <strcat@plt>
cmpl   $0xffffffff,-0x14(%rbp)
je     13a6 <write_log_file+0x1b6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x550(%rbp),%rdx
call   10d0 <read_watcher_file@plt>
lea    -0x420(%rbp),%rdi
lea    -0x550(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xcec(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   1100 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xd18(%rip),%rsi
call   1060 <fprintf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1462 <write_log_file+0x272>
mov    0x2bc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x564(%rbp)
mov    -0x20(%rbp),%rdx
mov    0x2bbe(%rip),%rax
mov    (%rax),%rsi
lea    0xcb2(%rip),%rax
lea    0xca4(%rip),%rcx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x560(%rbp)
mov    0x2ba0(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x564(%rbp),%edi
mov    -0x560(%rbp),%rdx
mov    %eax,%ecx
lea    0xc47(%rip),%rsi
call   10c0 <syslog@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <fflush@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     14da <write_log_file+0x2ea>
mov    0x2b49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x574(%rbp)
mov    -0x20(%rbp),%rdx
mov    0x2b46(%rip),%rax
mov    (%rax),%rsi
lea    0xc3a(%rip),%rax
lea    0xc2c(%rip),%rcx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x570(%rbp)
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x574(%rbp),%edi
mov    -0x570(%rbp),%rdx
mov    %eax,%ecx
lea    0xc09(%rip),%rsi
call   10c0 <syslog@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x580,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_log_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x520,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xdf1(%rip),%rsi
lea    0x90(%rsp),%rbx
mov    $0x96,%edx
mov    %rbx,%rdi
call   1090 <memcpy@plt>
lea    0x50(%rsp),%rdi
call   10a0 <str_date_log@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1100 <strcat@plt>
movl   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    1268 <write_log_file+0x78>
lea    0x90(%rsp),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
lea    0xe27(%rip),%rsi
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
call   1100 <strcat@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1100 <strcat@plt>
lea    0xe07(%rip),%rsi
mov    %rbp,%rdi
call   1100 <strcat@plt>
lea    0x10(%rsp),%rdi
call   1070 <string_date_time@plt>
mov    %rax,%rbx
lea    0x130(%rsp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1050 <memset@plt>
lea    0xddc(%rip),%rsi
mov    %rbp,%rdi
call   10f0 <fopen@plt>
mov    %rax,%r12
lea    0x260(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x2bc,%edx
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1100 <strcat@plt>
lea    0xdab(%rip),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1100 <strcat@plt>
xor    %eax,%eax
call   10e0 <getUserName@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1100 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1100 <strcat@plt>
cmp    $0xffffffff,%r15d
je     1349 <write_log_file+0x159>
lea    0x130(%rsp),%rbx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   10d0 <read_watcher_file@plt>
lea    0x260(%rsp),%rdi
mov    %rbx,%rsi
call   1100 <strcat@plt>
lea    0xd50(%rip),%rsi
lea    0x260(%rsp),%rbx
mov    %rbx,%rdi
call   1100 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1100 <strcat@plt>
lea    0xd30(%rip),%rsi
mov    %rbx,%rdi
call   1100 <strcat@plt>
lea    0xd85(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
test   %eax,%eax
jns    13d6 <write_log_file+0x1e6>
mov    0x2c31(%rip),%rax
mov    (%rax),%ebx
mov    0x2c38(%rip),%rax
cmp    (%rax),%r12
lea    0xd25(%rip),%rax
lea    0xd25(%rip),%rbp
cmove  %rax,%rbp
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcda(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
call   10c0 <syslog@plt>
mov    %r12,%rdi
call   10b0 <fflush@plt>
test   %eax,%eax
je     1428 <write_log_file+0x238>
mov    0x2bdf(%rip),%rax
mov    (%rax),%ebx
mov    0x2be6(%rip),%rax
cmp    (%rax),%r12
lea    0xcd3(%rip),%rax
lea    0xcd3(%rip),%rbp
cmove  %rax,%rbp
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcc2(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
call   10c0 <syslog@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
add    $0x520,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@__const.write_log_file.log_file_name = [150 x i8] c"/root/logs/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [3 x i8] c"a+\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@LOG_ERR = global i32 0
@.str.6 = [43 x i8] c"Can not write to log stream: %s, error: %s\00"
@stdout = global i32* null
@.str.7 = [7 x i8] c"stdout\00"
@.str.8 = [8 x i8] c"daemon1\00"
@errno = global i32 0
@.str.9 = [43 x i8] c"Can not fflush() log stream: %s, error: %s\00"
define void @write_log_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [150 x i8]
%10 = alloca [50 x i8]
%11 = alloca i8*
%12 = alloca %struct.stat
%13 = alloca [50 x i8]
%14 = alloca i8*
%15 = alloca [700 x i8]
%16 = alloca [300 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32* null, i32** %7
store i32 -1, i32* %8
%17 = bitcast [150 x i8]* %9 to i8*
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%19 = call i8* @str_date_log(i8* %18)
store i8* %19, i8** %11
%20 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = bitcast %struct.stat* %12 to i8*
%24 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%25 = call i32 @stat(i8* %24, %struct.stat* %12)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %3
%28 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%29 = call i32 @mkdir(i8* %28, i32 448)
br label %30
30: ; preds = %27, %3
%31 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%34 = load i8*, i8** %11
%35 = call i32 @strcat(i8* %33, i8* %34)
%36 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %13, i64 0, i64 0
%39 = call i8* @string_date_time(i8* %38)
store i8* %39, i8** %14
%40 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%41 = call i32 @memset(i8* %40, i32 0, i32 300)
%42 = getelementptr inbounds [150 x i8], [150 x i8]* %9, i64 0, i64 0
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %43, i32** %7
%44 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i32 0, i32 700)
%46 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%47 = load i8*, i8** %14
%48 = call i32 @strcat(i8* %46, i8* %47)
%49 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%52 = call i8* (...) @getUserName()
%53 = call i32 @strcat(i8* %51, i8* %52)
%54 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* %6
%57 = icmp ne i32 %56, -1
br i1 %57, label %58, label %66
58: ; preds = %30
%59 = load i8*, i8** %5
%60 = load i32, i32* %6
%61 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%62 = call i32 @read_watcher_file(i8* %59, i32 %60, i8* %61)
%63 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%64 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%65 = call i32 @strcat(i8* %63, i8* %64)
br label %66
66: ; preds = %58, %30
%67 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%68 = call i32 @strcat(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%69 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%70 = load i8*, i8** %5
%71 = call i32 @strcat(i8* %69, i8* %70)
%72 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%73 = call i32 @strcat(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%74 = load i32*, i32** %7
%75 = getelementptr inbounds [700 x i8], [700 x i8]* %15, i64 0, i64 0
%76 = call i32 @fprintf(i32* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %75)
store i32 %76, i32* %8
%77 = load i32, i32* %8
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %89
79: ; preds = %66
%80 = load i32, i32* @LOG_ERR
%81 = load i32*, i32** %7
%82 = load i32*, i32** @stdout
%83 = icmp eq i32* %81, %82
%84 = zext i1 %83 to i64
%85 = select i1 %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%86 = load i32, i32* @errno
%87 = call i32 @strerror(i32 %86)
%88 = call i32 @syslog(i32 %80, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %85, i32 %87)
br label %89
89: ; preds = %79, %66
%90 = load i32*, i32** %7
%91 = call i32 @fflush(i32* %90)
store i32 %91, i32* %8
%92 = load i32, i32* %8
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %104
94: ; preds = %89
%95 = load i32, i32* @LOG_ERR
%96 = load i32*, i32** %7
%97 = load i32*, i32** @stdout
%98 = icmp eq i32* %96, %97
%99 = zext i1 %98 to i64
%100 = select i1 %98, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%101 = load i32, i32* @errno
%102 = call i32 @strerror(i32 %101)
%103 = call i32 @syslog(i32 %95, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i8* %100, i32 %102)
br label %104
104: ; preds = %94, %89
%105 = load i32*, i32** %7
%106 = call i32 @fclose(i32* %105)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@__const.write_log_file.log_file_name = [150 x i8] c"/root/logs/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [3 x i8] c"a+\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@LOG_ERR = global i32 0
@.str.6 = [43 x i8] c"Can not write to log stream: %s, error: %s\00"
@stdout = global i32* null
@.str.7 = [7 x i8] c"stdout\00"
@.str.8 = [8 x i8] c"daemon1\00"
@errno = global i32 0
@.str.9 = [43 x i8] c"Can not fflush() log stream: %s, error: %s\00"
define void @write_log_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca [150 x i8]
%5 = alloca [50 x i8]
%6 = alloca %struct.stat
%7 = alloca [50 x i8]
%8 = alloca [700 x i8]
%9 = alloca [300 x i8]
%10 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%12 = call i8* @str_date_log(i8* %11)
%13 = call i32 @strcat(i8* %10, i8* %0)
%14 = bitcast %struct.stat* %6 to i8*
%15 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
store i32 0, i32* %15
%16 = call i32 @stat(i8* %10, %struct.stat* %6)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = call i32 @mkdir(i8* %10, i32 448)
br label %20
20: ; preds = %18, %3
%21 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @strcat(i8* %10, i8* %12)
%23 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%25 = call i8* @string_date_time(i8* %24)
%26 = getelementptr inbounds [700 x i8], [700 x i8]* %8, i64 0, i64 0
%27 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%28 = call i32 @memset(i8* %27, i32 0, i32 300)
%29 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @memset(i8* %26, i32 0, i32 700)
%31 = call i32 @strcat(i8* %26, i8* %25)
%32 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = call i8* (...) @getUserName()
%34 = call i32 @strcat(i8* %26, i8* %33)
%35 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i32 %2, -1
br i1 %36, label %40, label %37
37: ; preds = %20
%38 = call i32 @read_watcher_file(i8* %1, i32 %2, i8* %27)
%39 = call i32 @strcat(i8* %26, i8* %27)
br label %40
40: ; preds = %37, %20
%41 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @strcat(i8* %26, i8* %1)
%43 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %40
%47 = load i32, i32* @LOG_ERR
%48 = load i32*, i32** @stdout
%49 = icmp eq i32* %29, %48
%50 = select i1 %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%51 = load i32, i32* @errno
%52 = call i32 @strerror(i32 %51)
%53 = call i32 @syslog(i32 %47, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %50, i32 %52)
br label %54
54: ; preds = %46, %40
%55 = call i32 @fflush(i32* %29)
%56 = icmp eq i32 %55, 0
br i1 %56, label %65, label %57
57: ; preds = %54
%58 = load i32, i32* @LOG_ERR
%59 = load i32*, i32** @stdout
%60 = icmp eq i32* %29, %59
%61 = select i1 %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 @syslog(i32 %58, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i8* %61, i32 %63)
br label %65
65: ; preds = %57, %54
%66 = call i32 @fclose(i32* %29)
ret void
}