#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 inotify_event {
  char *name;
  scalar_t__ len;
};
typedef int pid_t;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ ENOENT;
int EXIT_SUCCESS;
int /*<<< orphan*/ IN_CREATE;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int fork();
int inotify_add_watch(int, char *, int /*<<< orphan*/);
int inotify_init();
int /*<<< orphan*/ inotify_rm_watch(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ skeleton_daemon();
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strndup(char *, int);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(void) {
  char *fujiPath = "/mnt/sd/DCIM/100_FUJI/";
  int fd, wd, i, length;
  char buffer[(1024 * ((sizeof(struct inotify_event)) + 16))];
  skeleton_daemon();
  syslog(LOG_NOTICE, "Check if DCIM/100_FUJI exists.");
  DIR *fuji = opendir(fujiPath);
  if (fuji) {
    syslog(LOG_NOTICE, "DCIM/100_FUJI found. Continue execting.");
    closedir(fuji);
  } else if (ENOENT == errno) {
    syslog(LOG_NOTICE,
           "DCIM/100_FUJI not found. Create it and continue execting.");
    mkdir(fujiPath, 0777);
  } else {
    syslog(LOG_ERR, "Error (%d) occured during checking DCIM/100_FUJI. Exiting",
           errno);
    exit(1);
  }
  fd = inotify_init();
  if (fd < 0) {
    syslog(LOG_ERR, "Error (%d) occured setting up inotify. Exiting", errno);
    exit(1);
  }
  wd = inotify_add_watch(fd, fujiPath, IN_CREATE);
  while (1) {
    i = 0;
    length = read(fd, buffer, (1024 * ((sizeof(struct inotify_event)) + 16)));
    if (length < 0) {
      perror("read");
    }
    while (i < length) {
      struct inotify_event *event = (struct inotify_event *)&buffer[i];
      if (event->len) {
        syslog(LOG_NOTICE, "New file %s created.", event->name);
        int pathLength = strlen(event->name) + strlen(fujiPath) + 1;
        char *newFilePath = (char *)malloc(pathLength);
        if (newFilePath == NULL) {
          syslog(LOG_ERR, "Error during initializing newFilePath buffer. "
                          "Continue without encrypting");
        } else {
          memset(newFilePath, '\0', pathLength);
          strncpy(newFilePath, fujiPath, strlen(fujiPath));
          strncat(newFilePath, event->name, strlen(event->name));
          if (strstr(event->name, ".out") == NULL) {
            pid_t childPid = fork();
            if (childPid == -1) {
              syslog(LOG_ERR,
                     "Error %d occured during start of cryptosd. Continuing "
                     "without encrypting %s",
                     errno, event->name);
            } else if (childPid == 0) {
              syslog(LOG_NOTICE, "Starting cryptosd for %s.", event->name);
              char *argList[] = {"cryptosd", "-e",
                                 "-s",       "/tmp/cam_seckey",
                                 "-p",       "/tmp/user_pubkey",
                                 "-i",       newFilePath,
                                 NULL};
              execvp("/tmp/cryptosd", argList);
              syslog(LOG_ERR, "Error (%d) during execvp of cryptosd for %s.",
                     newFilePath, errno);
              abort();
            } else {
              syslog(LOG_NOTICE, "Child pid: %d", childPid);
              int returnStatus;
              waitpid(childPid, &returnStatus, 0);
              if (returnStatus != 0) {
                syslog(LOG_ERR, "Child returned with errorcode %d",
                       returnStatus);
              } else {
                syslog(LOG_NOTICE, "Encryption done for %s", newFilePath);
              }
            }
          } else {
            char *origiPath = strndup(newFilePath, strlen(newFilePath) - 4);
            if (origiPath == NULL) {
              syslog(LOG_ERR,
                     "Error during initializing origiPath buffer. Continue "
                     "without deleting %s (without .out)",
                     event->name);
            } else {
              pid_t childPid = fork();
              if (childPid == -1) {
                syslog(LOG_ERR,
                       "Error (%d) during start of shred. Continue without "
                       "deleting %s",
                       errno, origiPath);
              } else if (childPid == 0) {
                syslog(LOG_NOTICE, "Starting deletion of %s", origiPath);
                char *argList[] = {"rm", origiPath, NULL};
                execvp("rm", argList);
                syslog(LOG_ERR, "Error during execvp of rm for %s", origiPath);
                abort();
              } else {
                syslog(LOG_NOTICE, "Child pid: %d", childPid);
                int returnStatus;
                waitpid(childPid, &returnStatus, 0);
                if (returnStatus != 0) {
                  syslog(LOG_ERR, "Child returned with errorcode %d",
                         returnStatus);
                } else {
                  syslog(LOG_NOTICE, "Deletion done for %s", origiPath);
                }
              }
            }
          }
        }
        i += (sizeof(struct inotify_event)) + event->len;
      }
    }
  }
  inotify_rm_watch(fd, wd);
  close(fd);
  syslog(LOG_NOTICE, "Cryptodaemon terminated.");
  closelog();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xd97(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <skeleton_daemon@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x10(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x8028(%rbp)
cmpq   $0x0,-0x8028(%rbp)
je     12d1 <main+0x81>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x8028(%rbp),%rdi
call   10b0 <closedir@plt>
jmp    1342 <main+0xf2>
mov    0x2ce8(%rip),%rax
mov    (%rax),%eax
mov    0x2cff(%rip),%rcx
cmp    (%rcx),%eax
jne    1313 <main+0xc3>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1ff,%esi
call   1050 <mkdir@plt>
jmp    133d <main+0xed>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
mov    0x2cbd(%rip),%rax
mov    (%rax),%edx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
jmp    1342 <main+0xf2>
mov    $0x0,%al
call   10e0 <inotify_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1380 <main+0x130>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
mov    0x2c7a(%rip),%rax
mov    (%rax),%edx
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2c4a(%rip),%rax
mov    (%rax),%edx
call   1100 <inotify_add_watch@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x8020(%rbp),%rsi
mov    $0x8000,%edx
call   10c0 <read@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    13cc <main+0x17c>
lea    0xd3a(%rip),%rdi
call   1130 <perror@plt>
jmp    13d1 <main+0x181>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    18eb <main+0x69b>
movslq -0x1c(%rbp),%rcx
lea    -0x8020(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x8030(%rbp)
mov    -0x8030(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     18e6 <main+0x696>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdx
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x80c8(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x80c8(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x8034(%rbp)
mov    -0x8034(%rbp),%edi
call   10f0 <malloc@plt>
mov    %rax,-0x8040(%rbp)
cmpq   $0x0,-0x8040(%rbp)
jne    1492 <main+0x242>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    18cd <main+0x67d>
mov    -0x8040(%rbp),%rdi
mov    -0x8034(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x8040(%rbp),%rax
mov    %rax,-0x80e8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80e0(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x80e8(%rbp),%rdi
mov    -0x80e0(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x8040(%rbp),%rax
mov    %rax,-0x80d8(%rbp)
mov    -0x8030(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80d0(%rbp)
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    -0x80d8(%rbp),%rdi
mov    -0x80d0(%rbp),%rsi
mov    %eax,%edx
call   10a0 <strncat@plt>
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdi
lea    0xc34(%rip),%rsi
call   1170 <strstr@plt>
cmp    $0x0,%rax
jne    1700 <main+0x4b0>
mov    $0x0,%al
call   1160 <fork@plt>
mov    %eax,-0x8044(%rbp)
cmpl   $0xffffffff,-0x8044(%rbp)
jne    1589 <main+0x339>
mov    0x2a57(%rip),%rax
mov    (%rax),%edi
mov    0x2a76(%rip),%rax
mov    (%rax),%edx
mov    -0x8030(%rbp),%rax
mov    (%rax),%rcx
lea    0xbed(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    16fb <main+0x4ab>
cmpl   $0x0,-0x8044(%rbp)
jne    1673 <main+0x423>
mov    0x2a33(%rip),%rax
mov    (%rax),%edi
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdx
lea    0xc06(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
lea    0xc44(%rip),%rax
mov    %rax,-0x8090(%rbp)
lea    0xc04(%rip),%rax
mov    %rax,-0x8088(%rbp)
lea    0xbf9(%rip),%rax
mov    %rax,-0x8080(%rbp)
lea    0xbee(%rip),%rax
mov    %rax,-0x8078(%rbp)
lea    0xbf0(%rip),%rax
mov    %rax,-0x8070(%rbp)
lea    0xbe5(%rip),%rax
mov    %rax,-0x8068(%rbp)
lea    0xbe8(%rip),%rax
mov    %rax,-0x8060(%rbp)
mov    -0x8040(%rbp),%rax
mov    %rax,-0x8058(%rbp)
movq   $0x0,-0x8050(%rbp)
lea    -0x8090(%rbp),%rsi
lea    0xbbd(%rip),%rdi
call   1140 <execvp@plt>
mov    0x296c(%rip),%rax
mov    (%rax),%edi
mov    -0x8040(%rbp),%rdx
mov    0x2984(%rip),%rax
mov    (%rax),%ecx
lea    0xba6(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2956(%rip),%rax
mov    (%rax),%edi
mov    -0x8044(%rbp),%edx
lea    0xbaf(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x8044(%rbp),%edi
lea    -0x8094(%rbp),%rsi
xor    %edx,%edx
call   1120 <waitpid@plt>
cmpl   $0x0,-0x8094(%rbp)
je     16d3 <main+0x483>
mov    0x2900(%rip),%rax
mov    (%rax),%edi
mov    -0x8094(%rbp),%edx
lea    0xb7f(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    16f1 <main+0x4a1>
mov    0x28f6(%rip),%rax
mov    (%rax),%edi
mov    -0x8040(%rbp),%rdx
lea    0xb7d(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    16f6 <main+0x4a6>
jmp    16fb <main+0x4ab>
jmp    18c8 <main+0x678>
mov    -0x8040(%rbp),%rax
mov    %rax,-0x80f0(%rbp)
mov    -0x8040(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x80f0(%rbp),%rdi
mov    %eax,%esi
sub    $0x4,%esi
call   10d0 <strndup@plt>
mov    %rax,-0x80a0(%rbp)
cmpq   $0x0,-0x80a0(%rbp)
jne    1766 <main+0x516>
mov    0x2871(%rip),%rax
mov    (%rax),%edi
mov    -0x8030(%rbp),%rax
mov    (%rax),%rdx
lea    0xb24(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    18c3 <main+0x673>
mov    $0x0,%al
call   1160 <fork@plt>
mov    %eax,-0x80a4(%rbp)
cmpl   $0xffffffff,-0x80a4(%rbp)
jne    17ac <main+0x55c>
mov    0x2831(%rip),%rax
mov    (%rax),%edi
mov    0x2850(%rip),%rax
mov    (%rax),%edx
mov    -0x80a0(%rbp),%rcx
lea    0xb36(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    18be <main+0x66e>
cmpl   $0x0,-0x80a4(%rbp)
jne    1836 <main+0x5e6>
mov    0x2810(%rip),%rax
mov    (%rax),%edi
mov    -0x80a0(%rbp),%rdx
lea    0xb45(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
lea    0xb4f(%rip),%rax
mov    %rax,-0x80c0(%rbp)
mov    -0x80a0(%rbp),%rax
mov    %rax,-0x80b8(%rbp)
movq   $0x0,-0x80b0(%rbp)
lea    -0x80c0(%rbp),%rsi
lea    0xb21(%rip),%rdi
call   1140 <execvp@plt>
mov    0x27a0(%rip),%rax
mov    (%rax),%edi
mov    -0x80a0(%rbp),%rdx
lea    0xb08(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2793(%rip),%rax
mov    (%rax),%edi
mov    -0x80a4(%rbp),%edx
lea    0x9ec(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x80a4(%rbp),%edi
lea    -0x80c4(%rbp),%rsi
xor    %edx,%edx
call   1120 <waitpid@plt>
cmpl   $0x0,-0x80c4(%rbp)
je     1896 <main+0x646>
mov    0x273d(%rip),%rax
mov    (%rax),%edi
mov    -0x80c4(%rbp),%edx
lea    0x9bc(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    18b4 <main+0x664>
mov    0x2733(%rip),%rax
mov    (%rax),%edi
mov    -0x80a0(%rbp),%rdx
lea    0xaa4(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
jmp    18b9 <main+0x669>
jmp    18be <main+0x66e>
jmp    18c3 <main+0x673>
jmp    18c8 <main+0x678>
jmp    18cd <main+0x67d>
mov    -0x8030(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0x10,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    13d1 <main+0x181>
jmp    1398 <main+0x148>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8068,%rsp
xor    %eax,%eax
call   1080 <skeleton_daemon@plt>
mov    0x2d61(%rip),%r13
mov    0x0(%r13),%edi
lea    0xd9d(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xd78(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     12b1 <main+0x61>
mov    %rax,%rbx
mov    0x0(%r13),%edi
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
mov    %rbx,%rdi
call   10b0 <closedir@plt>
jmp    12ec <main+0x9c>
mov    0x2d08(%rip),%rax
mov    0x2d21(%rip),%rcx
mov    (%rcx),%edx
cmp    %edx,(%rax)
jne    1717 <main+0x4c7>
mov    0x0(%r13),%edi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xd1e(%rip),%rdi
mov    $0x1ff,%esi
call   1050 <mkdir@plt>
xor    %eax,%eax
call   10e0 <inotify_init@plt>
test   %eax,%eax
js     16fc <main+0x4ac>
mov    %eax,%edi
mov    0x2cd4(%rip),%rax
mov    (%rax),%edx
lea    0xcf3(%rip),%r12
mov    %edi,0x8(%rsp)
mov    %r12,%rsi
call   1100 <inotify_add_watch@plt>
jmp    1330 <main+0xe0>
lea    0xddf(%rip),%rdi
call   1130 <perror@plt>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edi
lea    0x60(%rsp),%rsi
mov    $0x8000,%edx
call   10c0 <read@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     131b <main+0xcb>
je     1330 <main+0xe0>
xor    %r15d,%r15d
jmp    138c <main+0x13c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2c51(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
mov    0x2c52(%rip),%r13
add    %r14d,%r15d
add    $0x10,%r15d
cmp    0xc(%rsp),%r15d
jge    1330 <main+0xe0>
movslq %r15d,%rax
mov    0x68(%rsp,%rax,1),%r14
test   %r14,%r14
je     1385 <main+0x135>
mov    0x0(%r13),%edi
mov    0x60(%rsp,%rax,1),%r13
lea    0xd5d(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %eax,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     1360 <main+0x110>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1090 <memset@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   10a0 <strncat@plt>
mov    %r13,%rdi
lea    0xd4c(%rip),%rsi
call   1170 <strstr@plt>
test   %rax,%rax
je     14b8 <main+0x268>
mov    %rbp,%rdi
call   1070 <strlen@plt>
lea    -0x4(%rax),%esi
mov    %rbp,%rdi
call   10d0 <strndup@plt>
test   %rax,%rax
je     152a <main+0x2da>
mov    %rax,%rbp
xor    %eax,%eax
call   1160 <fork@plt>
cmp    $0xffffffff,%eax
lea    0xba9(%rip),%r12
je     1557 <main+0x307>
mov    %eax,%ebx
test   %eax,%eax
je     15e6 <main+0x396>
mov    0x2b62(%rip),%r12
mov    (%r12),%edi
lea    0xdbf(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    %ebx,%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1120 <waitpid@plt>
mov    0x10(%rsp),%edx
test   %edx,%edx
je     15a4 <main+0x354>
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
jmp    15b9 <main+0x369>
xor    %eax,%eax
call   1160 <fork@plt>
cmp    $0xffffffff,%eax
je     157f <main+0x32f>
mov    %eax,%ebx
test   %eax,%eax
je     1645 <main+0x3f5>
mov    0x2af7(%rip),%r13
mov    0x0(%r13),%edi
lea    0xd54(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    %ebx,%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1120 <waitpid@plt>
mov    0x10(%rsp),%edx
test   %edx,%edx
je     15c5 <main+0x375>
mov    0x2aaa(%rip),%rax
mov    (%rax),%edi
lea    0xd2f(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xadb(%rip),%r12
jmp    137e <main+0x12e>
mov    0x2a87(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    0x2a85(%rip),%r13
lea    0xaae(%rip),%r12
jmp    137e <main+0x12e>
mov    0x2a5a(%rip),%rax
mov    (%rax),%edi
mov    0x2a79(%rip),%rax
mov    (%rax),%edx
lea    0xd66(%rip),%rsi
mov    %rbp,%rcx
xor    %eax,%eax
call   1110 <syslog@plt>
jmp    1377 <main+0x127>
mov    0x2a32(%rip),%rax
mov    (%rax),%edi
mov    0x2a51(%rip),%rax
mov    (%rax),%edx
lea    0xbd2(%rip),%rsi
mov    %r13,%rcx
xor    %eax,%eax
call   1110 <syslog@plt>
jmp    15b9 <main+0x369>
mov    (%r12),%edi
lea    0xda2(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xa40(%rip),%r12
jmp    1377 <main+0x127>
mov    0x0(%r13),%edi
lea    0xc97(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xa1f(%rip),%r12
jmp    137e <main+0x12e>
mov    0x29e3(%rip),%rax
mov    (%rax),%edi
lea    0xd1f(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xd26(%rip),%rdi
mov    %rdi,0x10(%rsp)
mov    %rbp,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x10(%rsp),%rsi
call   1140 <execvp@plt>
mov    0x298d(%rip),%rax
mov    (%rax),%edi
lea    0xcfc(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x2984(%rip),%rax
mov    (%rax),%edi
lea    0xb61(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xb9c(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xb5e(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xb55(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xb4c(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xb50(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xb47(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xb4c(%rip),%rax
mov    %rax,0x40(%rsp)
mov    %rbp,0x48(%rsp)
movq   $0x0,0x50(%rsp)
lea    0xb35(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1140 <execvp@plt>
mov    0x28df(%rip),%rax
mov    (%rax),%edi
mov    0x28fe(%rip),%rax
mov    (%rax),%ecx
lea    0xb20(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x28b5(%rip),%rax
mov    (%rax),%edi
mov    0x28d4(%rip),%rax
mov    (%rax),%edx
lea    0x9bd(%rip),%rsi
jmp    1727 <main+0x4d7>
mov    0x289a(%rip),%rax
mov    (%rax),%edi
lea    0x971(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.inotify_event = type { i8*, i64 }
@.str = [23 x i8] c"/mnt/sd/DCIM/100_FUJI/\00"
@LOG_NOTICE = global i32 0
@.str.1 = [31 x i8] c"Check if DCIM/100_FUJI exists.\00"
@.str.2 = [40 x i8] c"DCIM/100_FUJI found. Continue execting.\00"
@ENOENT = global i32 0
@errno = global i32 0
@.str.3 = [58 x i8] c"DCIM/100_FUJI not found. Create it and continue execting.\00"
@LOG_ERR = global i32 0
@.str.4 = [58 x i8] c"Error (%d) occured during checking DCIM/100_FUJI. Exiting\00"
@.str.5 = [47 x i8] c"Error (%d) occured setting up inotify. Exiting\00"
@IN_CREATE = global i32 0
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [21 x i8] c"New file %s created.\00"
@.str.8 = [74 x i8] c"Error during initializing newFilePath buffer. Continue without encrypting\00"
@.str.9 = [5 x i8] c".out\00"
@.str.10 = [76 x i8] c"Error %d occured during start of cryptosd. Continuing without encrypting %s\00"
@.str.11 = [26 x i8] c"Starting cryptosd for %s.\00"
@.str.12 = [9 x i8] c"cryptosd\00"
@.str.13 = [3 x i8] c"-e\00"
@.str.14 = [3 x i8] c"-s\00"
@.str.15 = [16 x i8] c"/tmp/cam_seckey\00"
@.str.16 = [3 x i8] c"-p\00"
@.str.17 = [17 x i8] c"/tmp/user_pubkey\00"
@.str.18 = [3 x i8] c"-i\00"
@.str.19 = [14 x i8] c"/tmp/cryptosd\00"
@.str.20 = [45 x i8] c"Error (%d) during execvp of cryptosd for %s.\00"
@.str.21 = [14 x i8] c"Child pid: %d\00"
@.str.22 = [33 x i8] c"Child returned with errorcode %d\00"
@.str.23 = [23 x i8] c"Encryption done for %s\00"
@.str.24 = [88 x i8] c"Error during initializing origiPath buffer. Continue without deleting %s (without .out)\00"
@.str.25 = [63 x i8] c"Error (%d) during start of shred. Continue without deleting %s\00"
@.str.26 = [24 x i8] c"Starting deletion of %s\00"
@.str.27 = [3 x i8] c"rm\00"
@.str.28 = [33 x i8] c"Error during execvp of rm for %s\00"
@.str.29 = [21 x i8] c"Deletion done for %s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32768 x i8]
%8 = alloca i32*
%9 = alloca %struct.inotify_event*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [9 x i8*]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca [3 x i8*]
%18 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %2
%19 = call i32 (...) @skeleton_daemon()
%20 = load i32, i32* @LOG_NOTICE
%21 = call i32 (i32, i8*, ...) @syslog(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %2
%23 = call i32* @opendir(i8* %22)
store i32* %23, i32** %8
%24 = load i32*, i32** %8
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %31
26: ; preds = %0
%27 = load i32, i32* @LOG_NOTICE
%28 = call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32*, i32** %8
%30 = call i32 @closedir(i32* %29)
br label %46
31: ; preds = %0
%32 = load i32, i32* @ENOENT
%33 = load i32, i32* @errno
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* @LOG_NOTICE
%37 = call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%38 = load i8*, i8** %2
%39 = call i32 @mkdir(i8* %38, i32 511)
br label %45
40: ; preds = %31
%41 = load i32, i32* @LOG_ERR
%42 = load i32, i32* @errno
%43 = call i32 (i32, i8*, ...) @syslog(i32 %41, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %35
br label %46
46: ; preds = %45, %26
%47 = call i32 (...) @inotify_init()
store i32 %47, i32* %3
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i32, i32* @LOG_ERR
%52 = load i32, i32* @errno
%53 = call i32 (i32, i8*, ...) @syslog(i32 %51, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %46
%56 = load i32, i32* %3
%57 = load i8*, i8** %2
%58 = load i32, i32* @IN_CREATE
%59 = call i32 @inotify_add_watch(i32 %56, i8* %57, i32 %58)
store i32 %59, i32* %4
br label %60
60: ; preds = %55, %254
store i32 0, i32* %5
%61 = load i32, i32* %3
%62 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%63 = call i32 @read(i32 %61, i8* %62, i32 32768)
store i32 %63, i32* %6
%64 = load i32, i32* %6
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %68
68: ; preds = %66, %60
br label %69
69: ; preds = %253, %68
%70 = load i32, i32* %5
%71 = load i32, i32* %6
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %254
73: ; preds = %69
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 %75
%77 = bitcast i8* %76 to %struct.inotify_event*
store %struct.inotify_event* %77, %struct.inotify_event** %9
%78 = load %struct.inotify_event*, %struct.inotify_event** %9
%79 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %78, i32 0, i32 1
%80 = load i64, i64* %79
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %253
82: ; preds = %73
%83 = load i32, i32* @LOG_NOTICE
%84 = load %struct.inotify_event*, %struct.inotify_event** %9
%85 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = call i32 (i32, i8*, ...) @syslog(i32 %83, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %86)
%88 = load %struct.inotify_event*, %struct.inotify_event** %9
%89 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %88, i32 0, i32 0
%90 = load i8*, i8** %89
%91 = call i32 @strlen(i8* %90)
%92 = load i8*, i8** %2
%93 = call i32 @strlen(i8* %92)
%94 = add nsw i32 %91, %93
%95 = add nsw i32 %94, 1
store i32 %95, i32* %10
%96 = load i32, i32* %10
%97 = call i64 @malloc(i32 %96)
%98 = inttoptr i64 %97 to i8*
store i8* %98, i8** %11
%99 = load i8*, i8** %11
%100 = icmp eq i8* %99, null
br i1 %100, label %101, label %104
101: ; preds = %82
%102 = load i32, i32* @LOG_ERR
%103 = call i32 (i32, i8*, ...) @syslog(i32 %102, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.8, i64 0, i64 0))
br label %244
104: ; preds = %82
%105 = load i8*, i8** %11
%106 = load i32, i32* %10
%107 = call i32 @memset(i8* %105, i8 signext 0, i32 %106)
%108 = load i8*, i8** %11
%109 = load i8*, i8** %2
%110 = load i8*, i8** %2
%111 = call i32 @strlen(i8* %110)
%112 = call i32 @strncpy(i8* %108, i8* %109, i32 %111)
%113 = load i8*, i8** %11
%114 = load %struct.inotify_event*, %struct.inotify_event** %9
%115 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %114, i32 0, i32 0
%116 = load i8*, i8** %115
%117 = load %struct.inotify_event*, %struct.inotify_event** %9
%118 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %117, i32 0, i32 0
%119 = load i8*, i8** %118
%120 = call i32 @strlen(i8* %119)
%121 = call i32 @strncat(i8* %113, i8* %116, i32 %120)
%122 = load %struct.inotify_event*, %struct.inotify_event** %9
%123 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %122, i32 0, i32 0
%124 = load i8*, i8** %123
%125 = call i32* @strstr(i8* %124, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%126 = icmp eq i32* %125, null
br i1 %126, label %127, label %183
127: ; preds = %104
%128 = call i32 (...) @fork()
store i32 %128, i32* %12
%129 = load i32, i32* %12
%130 = icmp eq i32 %129, -1
br i1 %130, label %131, label %138
131: ; preds = %127
%132 = load i32, i32* @LOG_ERR
%133 = load i32, i32* @errno
%134 = load %struct.inotify_event*, %struct.inotify_event** %9
%135 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %134, i32 0, i32 0
%136 = load i8*, i8** %135
%137 = call i32 (i32, i8*, ...) @syslog(i32 %132, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.10, i64 0, i64 0), i32 %133, i8* %136)
br label %182
138: ; preds = %127
%139 = load i32, i32* %12
%140 = icmp eq i32 %139, 0
br i1 %140, label %141, label %164
141: ; preds = %138
%142 = load i32, i32* @LOG_NOTICE
%143 = load %struct.inotify_event*, %struct.inotify_event** %9
%144 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %143, i32 0, i32 0
%145 = load i8*, i8** %144
%146 = call i32 (i32, i8*, ...) @syslog(i32 %142, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %145)
%147 = getelementptr inbounds [9 x i8*], [9 x i8*]* %13, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %147
%148 = getelementptr inbounds i8*, i8** %147, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8** %148
%149 = getelementptr inbounds i8*, i8** %148, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8** %149
%150 = getelementptr inbounds i8*, i8** %149, i64 1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0), i8** %150
%151 = getelementptr inbounds i8*, i8** %150, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8** %151
%152 = getelementptr inbounds i8*, i8** %151, i64 1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8** %152
%153 = getelementptr inbounds i8*, i8** %152, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i8** %153
%154 = getelementptr inbounds i8*, i8** %153, i64 1
%155 = load i8*, i8** %11
store i8* %155, i8** %154
%156 = getelementptr inbounds i8*, i8** %154, i64 1
store i8* null, i8** %156
%157 = getelementptr inbounds [9 x i8*], [9 x i8*]* %13, i64 0, i64 0
%158 = call i32 @execvp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8** %157)
%159 = load i32, i32* @LOG_ERR
%160 = load i8*, i8** %11
%161 = load i32, i32* @errno
%162 = call i32 (i32, i8*, ...) @syslog(i32 %159, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.20, i64 0, i64 0), i8* %160, i32 %161)
%163 = call i32 (...) @abort()
unreachable
164: ; preds = %138
%165 = load i32, i32* @LOG_NOTICE
%166 = load i32, i32* %12
%167 = call i32 (i32, i8*, ...) @syslog(i32 %165, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %166)
%168 = load i32, i32* %12
%169 = call i32 @waitpid(i32 %168, i32* %14, i32 0)
%170 = load i32, i32* %14
%171 = icmp ne i32 %170, 0
br i1 %171, label %172, label %176
172: ; preds = %164
%173 = load i32, i32* @LOG_ERR
%174 = load i32, i32* %14
%175 = call i32 (i32, i8*, ...) @syslog(i32 %173, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %174)
br label %180
176: ; preds = %164
%177 = load i32, i32* @LOG_NOTICE
%178 = load i8*, i8** %11
%179 = call i32 (i32, i8*, ...) @syslog(i32 %177, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.23, i64 0, i64 0), i8* %178)
br label %180
180: ; preds = %176, %172
br label %181
181: ; preds = %180
br label %182
182: ; preds = %181, %131
br label %243
183: ; preds = %104
%184 = load i8*, i8** %11
%185 = load i8*, i8** %11
%186 = call i32 @strlen(i8* %185)
%187 = sub nsw i32 %186, 4
%188 = call i8* @strndup(i8* %184, i32 %187)
store i8* %188, i8** %15
%189 = load i8*, i8** %15
%190 = icmp eq i8* %189, null
br i1 %190, label %191, label %197
191: ; preds = %183
%192 = load i32, i32* @LOG_ERR
%193 = load %struct.inotify_event*, %struct.inotify_event** %9
%194 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %193, i32 0, i32 0
%195 = load i8*, i8** %194
%196 = call i32 (i32, i8*, ...) @syslog(i32 %192, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.24, i64 0, i64 0), i8* %195)
br label %242
197: ; preds = %183
%198 = call i32 (...) @fork()
store i32 %198, i32* %16
%199 = load i32, i32* %16
%200 = icmp eq i32 %199, -1
br i1 %200, label %201, label %206
201: ; preds = %197
%202 = load i32, i32* @LOG_ERR
%203 = load i32, i32* @errno
%204 = load i8*, i8** %15
%205 = call i32 (i32, i8*, ...) @syslog(i32 %202, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.25, i64 0, i64 0), i32 %203, i8* %204)
br label %241
206: ; preds = %197
%207 = load i32, i32* %16
%208 = icmp eq i32 %207, 0
br i1 %208, label %209, label %223
209: ; preds = %206
%210 = load i32, i32* @LOG_NOTICE
%211 = load i8*, i8** %15
%212 = call i32 (i32, i8*, ...) @syslog(i32 %210, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0), i8* %211)
%213 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i8** %213
%214 = getelementptr inbounds i8*, i8** %213, i64 1
%215 = load i8*, i8** %15
store i8* %215, i8** %214
%216 = getelementptr inbounds i8*, i8** %214, i64 1
store i8* null, i8** %216
%217 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
%218 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i8** %217)
%219 = load i32, i32* @LOG_ERR
%220 = load i8*, i8** %15
%221 = call i32 (i32, i8*, ...) @syslog(i32 %219, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.28, i64 0, i64 0), i8* %220)
%222 = call i32 (...) @abort()
unreachable
223: ; preds = %206
%224 = load i32, i32* @LOG_NOTICE
%225 = load i32, i32* %16
%226 = call i32 (i32, i8*, ...) @syslog(i32 %224, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %225)
%227 = load i32, i32* %16
%228 = call i32 @waitpid(i32 %227, i32* %18, i32 0)
%229 = load i32, i32* %18
%230 = icmp ne i32 %229, 0
br i1 %230, label %231, label %235
231: ; preds = %223
%232 = load i32, i32* @LOG_ERR
%233 = load i32, i32* %18
%234 = call i32 (i32, i8*, ...) @syslog(i32 %232, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %233)
br label %239
235: ; preds = %223
%236 = load i32, i32* @LOG_NOTICE
%237 = load i8*, i8** %15
%238 = call i32 (i32, i8*, ...) @syslog(i32 %236, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %237)
br label %239
239: ; preds = %235, %231
br label %240
240: ; preds = %239
br label %241
241: ; preds = %240, %201
br label %242
242: ; preds = %241, %191
br label %243
243: ; preds = %242, %182
br label %244
244: ; preds = %243, %101
%245 = load %struct.inotify_event*, %struct.inotify_event** %9
%246 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %245, i32 0, i32 1
%247 = load i64, i64* %246
%248 = add i64 16, %247
%249 = load i32, i32* %5
%250 = sext i32 %249 to i64
%251 = add i64 %250, %248
%252 = trunc i64 %251 to i32
store i32 %252, i32* %5
br label %253
253: ; preds = %244, %73
br label %69
254: ; preds = %69
br label %60
}

LLVM IR (-O2):
@.str = [23 x i8] c"/mnt/sd/DCIM/100_FUJI/\00"
@LOG_NOTICE = global i32 0
@.str.1 = [31 x i8] c"Check if DCIM/100_FUJI exists.\00"
@.str.2 = [40 x i8] c"DCIM/100_FUJI found. Continue execting.\00"
@ENOENT = global i32 0
@errno = global i32 0
@.str.3 = [58 x i8] c"DCIM/100_FUJI not found. Create it and continue execting.\00"
@LOG_ERR = global i32 0
@.str.4 = [58 x i8] c"Error (%d) occured during checking DCIM/100_FUJI. Exiting\00"
@.str.5 = [47 x i8] c"Error (%d) occured setting up inotify. Exiting\00"
@IN_CREATE = global i32 0
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [21 x i8] c"New file %s created.\00"
@.str.8 = [74 x i8] c"Error during initializing newFilePath buffer. Continue without encrypting\00"
@.str.9 = [5 x i8] c".out\00"
@.str.10 = [76 x i8] c"Error %d occured during start of cryptosd. Continuing without encrypting %s\00"
@.str.11 = [26 x i8] c"Starting cryptosd for %s.\00"
@.str.12 = [9 x i8] c"cryptosd\00"
@.str.13 = [3 x i8] c"-e\00"
@.str.14 = [3 x i8] c"-s\00"
@.str.15 = [16 x i8] c"/tmp/cam_seckey\00"
@.str.16 = [3 x i8] c"-p\00"
@.str.17 = [17 x i8] c"/tmp/user_pubkey\00"
@.str.18 = [3 x i8] c"-i\00"
@.str.19 = [14 x i8] c"/tmp/cryptosd\00"
@.str.20 = [45 x i8] c"Error (%d) during execvp of cryptosd for %s.\00"
@.str.21 = [14 x i8] c"Child pid: %d\00"
@.str.22 = [33 x i8] c"Child returned with errorcode %d\00"
@.str.23 = [23 x i8] c"Encryption done for %s\00"
@.str.24 = [88 x i8] c"Error during initializing origiPath buffer. Continue without deleting %s (without .out)\00"
@.str.25 = [63 x i8] c"Error (%d) during start of shred. Continue without deleting %s\00"
@.str.26 = [24 x i8] c"Starting deletion of %s\00"
@.str.27 = [3 x i8] c"rm\00"
@.str.28 = [33 x i8] c"Error during execvp of rm for %s\00"
@.str.29 = [21 x i8] c"Deletion done for %s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [32768 x i8]
%2 = alloca [9 x i8*]
%3 = alloca i32
%4 = alloca [3 x i8*]
%5 = alloca i32
%6 = getelementptr inbounds [32768 x i8], [32768 x i8]* %1, i64 0, i64 0
%7 = tail call i32 (...) @skeleton_daemon()
%8 = load i32, i32* @LOG_NOTICE
%9 = tail call i32 (i32, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32* @opendir(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = load i32, i32* @LOG_NOTICE
%14 = tail call i32 (i32, i8*, ...) @syslog(i32 %13, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @closedir(i32* %10)
br label %28
16: ; preds = %0
%17 = load i32, i32* @ENOENT
%18 = load i32, i32* @errno
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @LOG_NOTICE
%22 = tail call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @mkdir(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 511)
br label %28
24: ; preds = %16
%25 = load i32, i32* @LOG_ERR
%26 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %20, %12
%29 = tail call i32 (...) @inotify_init()
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* @LOG_ERR
%33 = load i32, i32* @errno
%34 = tail call i32 (i32, i8*, ...) @syslog(i32 %32, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = load i32, i32* @IN_CREATE
%38 = tail call i32 @inotify_add_watch(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = bitcast i32* %5 to i8*
%40 = bitcast i32* %3 to i8*
br label %41
41: ; preds = %46, %36
%42 = call i32 @read(i32 %29, i8* %6, i32 32768)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %160, %44, %47
br label %41
47: ; preds = %41
%48 = icmp eq i32 %42, 0
br i1 %48, label %46, label %49
49: ; preds = %47, %160
%50 = phi i32 [ %161, %160 ], [ 0, %47 ]
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [32768 x i8], [32768 x i8]* %1, i64 0, i64 %51
%53 = getelementptr inbounds i8, i8* %52, i64 8
%54 = bitcast i8* %53 to i64*
%55 = load i64, i64* %54
%56 = icmp eq i64 %55, 0
br i1 %56, label %160, label %57
57: ; preds = %49
%58 = load i32, i32* @LOG_NOTICE
%59 = bitcast i8* %52 to i8**
%60 = load i8*, i8** %59
%61 = call i32 (i32, i8*, ...) @syslog(i32 %58, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %60)
%62 = call i32 @strlen(i8* %60)
%63 = call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%64 = add i32 %62, 1
%65 = add i32 %64, %63
%66 = call i64 @malloc(i32 %65)
%67 = inttoptr i64 %66 to i8*
%68 = icmp eq i64 %66, 0
br i1 %68, label %69, label %72
69: ; preds = %57
%70 = load i32, i32* @LOG_ERR
%71 = call i32 (i32, i8*, ...) @syslog(i32 %70, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.8, i64 0, i64 0))
br label %156
72: ; preds = %57
%73 = call i32 @memset(i8* %67, i8 signext 0, i32 %65)
%74 = call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%75 = call i32 @strncpy(i8* %67, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %74)
%76 = call i32 @strlen(i8* %60)
%77 = call i32 @strncat(i8* %67, i8* %60, i32 %76)
%78 = call i32* @strstr(i8* dereferenceable(1) %60, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %118
80: ; preds = %72
%81 = call i32 (...) @fork()
switch i32 %81, label %105 [
i32 -1, label %82
i32 0, label %86
]
82: ; preds = %80
%83 = load i32, i32* @LOG_ERR
%84 = load i32, i32* @errno
%85 = call i32 (i32, i8*, ...) @syslog(i32 %83, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.10, i64 0, i64 0), i32 %84, i8* %60)
br label %156
86: ; preds = %80
%87 = inttoptr i64 %66 to i8*
%88 = load i32, i32* @LOG_NOTICE
%89 = call i32 (i32, i8*, ...) @syslog(i32 %88, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %60)
%90 = bitcast [9 x i8*]* %2 to i8*
%91 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %91
%92 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8** %92
%93 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8** %93
%94 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0), i8** %94
%95 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8** %95
%96 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 5
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8** %96
%97 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 6
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i8** %97
%98 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 7
store i8* %87, i8** %98
%99 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 8
store i8* null, i8** %99
%100 = call i32 @execvp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8** %91)
%101 = load i32, i32* @LOG_ERR
%102 = load i32, i32* @errno
%103 = call i32 (i32, i8*, ...) @syslog(i32 %101, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.20, i64 0, i64 0), i8* %87, i32 %102)
%104 = call i32 (...) @abort()
unreachable
105: ; preds = %80
%106 = load i32, i32* @LOG_NOTICE
%107 = call i32 (i32, i8*, ...) @syslog(i32 %106, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %81)
%108 = call i32 @waitpid(i32 %81, i32* %3, i32 0)
%109 = load i32, i32* %3
%110 = icmp eq i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %105
%112 = load i32, i32* @LOG_ERR
%113 = call i32 (i32, i8*, ...) @syslog(i32 %112, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %109)
br label %117
114: ; preds = %105
%115 = load i32, i32* @LOG_NOTICE
%116 = call i32 (i32, i8*, ...) @syslog(i32 %115, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.23, i64 0, i64 0), i8* %67)
br label %117
117: ; preds = %114, %111
br label %156
118: ; preds = %72
%119 = call i32 @strlen(i8* %67)
%120 = add nsw i32 %119, -4
%121 = call i8* @strndup(i8* %67, i32 %120)
%122 = icmp eq i8* %121, null
br i1 %122, label %123, label %126
123: ; preds = %118
%124 = load i32, i32* @LOG_ERR
%125 = call i32 (i32, i8*, ...) @syslog(i32 %124, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.24, i64 0, i64 0), i8* %60)
br label %156
126: ; preds = %118
%127 = call i32 (...) @fork()
switch i32 %127, label %143 [
i32 -1, label %128
i32 0, label %132
]
128: ; preds = %126
%129 = load i32, i32* @LOG_ERR
%130 = load i32, i32* @errno
%131 = call i32 (i32, i8*, ...) @syslog(i32 %129, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.25, i64 0, i64 0), i32 %130, i8* %121)
br label %156
132: ; preds = %126
%133 = load i32, i32* @LOG_NOTICE
%134 = call i32 (i32, i8*, ...) @syslog(i32 %133, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0), i8* %121)
%135 = bitcast [3 x i8*]* %4 to i8*
%136 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i8** %136
%137 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
store i8* %121, i8** %137
%138 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 2
store i8* null, i8** %138
%139 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i8** %136)
%140 = load i32, i32* @LOG_ERR
%141 = call i32 (i32, i8*, ...) @syslog(i32 %140, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.28, i64 0, i64 0), i8* %121)
%142 = call i32 (...) @abort()
unreachable
143: ; preds = %126
%144 = load i32, i32* @LOG_NOTICE
%145 = call i32 (i32, i8*, ...) @syslog(i32 %144, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %127)
%146 = call i32 @waitpid(i32 %127, i32* %5, i32 0)
%147 = load i32, i32* %5
%148 = icmp eq i32 %147, 0
br i1 %148, label %152, label %149
149: ; preds = %143
%150 = load i32, i32* @LOG_ERR
%151 = call i32 (i32, i8*, ...) @syslog(i32 %150, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %147)
br label %155
152: ; preds = %143
%153 = load i32, i32* @LOG_NOTICE
%154 = call i32 (i32, i8*, ...) @syslog(i32 %153, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %121)
br label %155
155: ; preds = %152, %149
br label %156
156: ; preds = %123, %155, %128, %82, %117, %69
%157 = trunc i64 %55 to i32
%158 = add i32 %50, 16
%159 = add i32 %158, %157
br label %160
160: ; preds = %156, %49
%161 = phi i32 [ %159, %156 ], [ %50, %49 ]
%162 = icmp slt i32 %161, %42
br i1 %162, label %49, label %46
}