#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 st_uid;
  int st_gid;
  int /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ REG_EXTENDED;
int REG_NOMATCH;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int atoi(char *);
int /*<<< orphan*/ b64_decode(char *, char *);
int /*<<< orphan*/ chmod(char *, scalar_t__);
int chown(char *, long, long);
int /*<<< orphan*/ dirname(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
char *realpath(char *, int /*<<< orphan*/ *);
int regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  if (strlen(argv[4]) > 1024) {
    fprintf(stderr, "Path length is more than 1024\n");
  }
  char destination_path[1024], parent_path[1024] = "";
  b64_decode(argv[4], destination_path);
  b64_decode(argv[4], parent_path);
  dirname(parent_path);
  regex_t umaskRegex;
  regex_t pathRegex;
  regex_t uidRegex;
  regex_t gidRegex;
  int reti;
  reti = regcomp(&pathRegex, "^/itu/users/", REG_EXTENDED);
  if (reti) {
    perror("Could not compile regex rule for path");
    exit(1);
  }
  reti = regexec(&pathRegex, destination_path, 0, NULL, 0);
  if (reti == REG_NOMATCH) {
    fprintf(stderr, "Path is not matched with regex\n");
    exit(EXIT_FAILURE);
  }
  regfree(&pathRegex);
  char *actualpath = realpath(destination_path, NULL);
  if (actualpath != NULL) {
    reti = regcomp(&pathRegex, "^/itu/s0[1-8]d0[1-9]|1[0-1]/", REG_EXTENDED);
    if (reti) {
      perror("Could not compile regex rule for  real path");
      exit(1);
    }
    reti = regexec(&pathRegex, actualpath, 0, NULL, 0);
    if (reti == REG_NOMATCH) {
      fprintf(stderr, "Real path is not matched with regex\n");
      exit(EXIT_FAILURE);
    }
    regfree(&pathRegex);
  }
  reti = regcomp(&gidRegex, "^300$", REG_EXTENDED);
  if (reti) {
    perror("Could not compile regex rule for gid");
    exit(1);
  }
  reti = regexec(&gidRegex, argv[2], 0, NULL, 0);
  if (reti == REG_NOMATCH) {
    fprintf(stderr, "GID is not matched with regex\n");
    exit(EXIT_FAILURE);
  }
  regfree(&gidRegex);
  reti = regcomp(&uidRegex, "^[1-9][0-9]{3,5}$", REG_EXTENDED);
  if (reti) {
    perror("Could not compile regex rule for uid");
    exit(1);
  }
  reti = regexec(&uidRegex, argv[1], 0, NULL, 0);
  if (reti == REG_NOMATCH) {
    fprintf(stderr, "UID is not matched with regex\n");
    exit(EXIT_FAILURE);
  }
  reti = regcomp(&umaskRegex, "^007$", REG_EXTENDED);
  if (reti) {
    perror("Could not compile regex rule for umask");
    exit(1);
  }
  reti = regexec(&umaskRegex, argv[3], 0, NULL, 0);
  if (reti == REG_NOMATCH) {
    fprintf(stderr, "Umask is not matched with regex\n");
    exit(EXIT_FAILURE);
  }
  regfree(&umaskRegex);
  int ownerUid = atoi(argv[1]);
  int ownerGid = atoi(argv[2]);
  struct stat info;
  stat(parent_path, &info);
  if (info.st_uid != ownerUid) {
    fprintf(stderr,
            "UID not matched with parent directory's UID. Parent:%d - UID:%d\n",
            info.st_uid, ownerUid);
    exit(EXIT_FAILURE);
  }
  if (info.st_gid != ownerGid) {
    fprintf(stderr,
            "GID not matched with parent directory's GID. Parent:%d - GID:%d\n",
            info.st_gid, ownerGid);
    exit(EXIT_FAILURE);
  }
  struct stat cur_file;
  if (stat(destination_path, &cur_file) == -1) {
    perror("stat");
    exit(EXIT_FAILURE);
  }
  int res = chown(destination_path, (long)ownerUid, (long)ownerGid);
  if (res == -1) {
    perror("chown");
    exit(EXIT_FAILURE);
  } else {
    if (S_ISDIR(cur_file.st_mode)) {
      chmod(destination_path, (511 - strtol(argv[3], 0, 8)));
    } else {
      chmod(destination_path, (439 - strtol(argv[3], 0, 8)));
    }
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <strlen@plt>
cmp    $0x400,%eax
jle    1258 <main+0x48>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <b64_decode@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x810(%rbp),%rsi
call   1030 <b64_decode@plt>
lea    -0x810(%rbp),%rdi
call   1070 <dirname@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
lea    -0x818(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   1090 <regcomp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     12e4 <main+0xd4>
lea    0xd57(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    -0x410(%rbp),%rsi
lea    -0x818(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   10e0 <regexec@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
mov    0x2cd4(%rip),%rcx
cmp    (%rcx),%eax
jne    1341 <main+0x131>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
lea    0xd26(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x818(%rbp),%rdi
call   1040 <regfree@plt>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <realpath@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x830(%rbp)
je     1420 <main+0x210>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edx
lea    -0x818(%rbp),%rdi
lea    0xce9(%rip),%rsi
call   1090 <regcomp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     13b7 <main+0x1a7>
lea    0xce7(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x830(%rbp),%rsi
lea    -0x818(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   10e0 <regexec@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
mov    0x2c01(%rip),%rcx
cmp    (%rcx),%eax
jne    1414 <main+0x204>
mov    0x2be2(%rip),%rax
mov    (%rax),%edi
lea    0xcbc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x818(%rbp),%rdi
call   1040 <regfree@plt>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edx
lea    -0x820(%rbp),%rdi
lea    0xca9(%rip),%rsi
call   1090 <regcomp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     1465 <main+0x255>
lea    0xc90(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x820(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   10e0 <regexec@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
mov    0x2b52(%rip),%rcx
cmp    (%rcx),%eax
jne    14c3 <main+0x2b3>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
lea    0xc5d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x820(%rbp),%rdi
call   1040 <regfree@plt>
mov    0x2af2(%rip),%rax
mov    (%rax),%edx
lea    -0x81c(%rbp),%rdi
lea    0xc44(%rip),%rsi
call   1090 <regcomp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     1514 <main+0x304>
lea    0xc37(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x81c(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   10e0 <regexec@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
mov    0x2aa3(%rip),%rcx
cmp    (%rcx),%eax
jne    1572 <main+0x362>
mov    0x2a84(%rip),%rax
mov    (%rax),%edi
lea    0xc04(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2a65(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    0x2a4f(%rip),%rax
mov    (%rax),%edx
lea    -0x814(%rbp),%rdi
lea    0xbf7(%rip),%rsi
call   1090 <regcomp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     15b7 <main+0x3a7>
lea    0xbde(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    -0x814(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   10e0 <regexec@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
mov    0x2a00(%rip),%rcx
cmp    (%rcx),%eax
jne    1615 <main+0x405>
mov    0x29e1(%rip),%rax
mov    (%rax),%edi
lea    0xbad(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x29c2(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x814(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x834(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x838(%rbp)
lea    -0x810(%rbp),%rdi
lea    -0x848(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x848(%rbp),%eax
cmp    -0x834(%rbp),%eax
je     169d <main+0x48d>
mov    0x2965(%rip),%rax
mov    (%rax),%edi
mov    -0x848(%rbp),%edx
mov    -0x834(%rbp),%ecx
lea    0xb46(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x293a(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x844(%rbp),%eax
cmp    -0x838(%rbp),%eax
je     16e0 <main+0x4d0>
mov    0x2922(%rip),%rax
mov    (%rax),%edi
mov    -0x844(%rbp),%edx
mov    -0x838(%rbp),%ecx
lea    0xb44(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x28f7(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x410(%rbp),%rdi
lea    -0x858(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1716 <main+0x506>
lea    0xb4d(%rip),%rdi
call   1110 <perror@plt>
mov    0x28c1(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x410(%rbp),%rdi
movslq -0x834(%rbp),%rsi
movslq -0x838(%rbp),%rdx
call   10f0 <chown@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0xffffffff,-0x85c(%rbp)
jne    175d <main+0x54d>
lea    0xb0b(%rip),%rdi
call   1110 <perror@plt>
mov    0x287a(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x850(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     17ad <main+0x59d>
lea    -0x410(%rbp),%rax
mov    %rax,-0x868(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <strtol@plt>
mov    -0x868(%rbp),%rdi
mov    $0x1ff,%esi
sub    %rax,%rsi
call   1100 <chmod@plt>
jmp    17e3 <main+0x5d3>
lea    -0x410(%rbp),%rax
mov    %rax,-0x870(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <strtol@plt>
mov    -0x870(%rbp),%rdi
mov    $0x1b7,%esi
sub    %rax,%rsi
call   1100 <chmod@plt>
jmp    17e8 <main+0x5d8>
mov    0x27d1(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x838,%rsp
mov    %rsi,%rbx
mov    0x20(%rsi),%rdi
call   1050 <strlen@plt>
cmp    $0x401,%eax
jl     1247 <main+0x37>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x430(%rsp),%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    0x20(%rbx),%rdi
lea    0x30(%rsp),%rsi
call   1030 <b64_decode@plt>
mov    0x20(%rbx),%rdi
mov    %rbp,%rsi
call   1030 <b64_decode@plt>
mov    %rbp,%rdi
call   1070 <dirname@plt>
mov    0x2d41(%rip),%r14
mov    (%r14),%edx
lea    0xd8e(%rip),%rsi
mov    %rsp,%rdi
call   1090 <regcomp@plt>
test   %eax,%eax
jne    12e2 <main+0xd2>
mov    %rsp,%rdi
lea    0x30(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
mov    0x2d30(%rip),%r15
cmp    (%r15),%eax
jne    12f8 <main+0xe8>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xd43(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %rsp,%rdi
call   1040 <regfree@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   10d0 <realpath@plt>
test   %rax,%rax
je     1367 <main+0x157>
mov    %rax,%rbp
mov    (%r14),%edx
lea    0xd54(%rip),%rsi
mov    %rsp,%rdi
call   1090 <regcomp@plt>
test   %eax,%eax
jne    1356 <main+0x146>
mov    %rsp,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
cmp    (%r15),%eax
jne    135f <main+0x14f>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
jmp    12cd <main+0xbd>
lea    0xd32(%rip),%rdi
jmp    12e9 <main+0xd9>
mov    %rsp,%rdi
call   1040 <regfree@plt>
mov    (%r14),%edx
lea    0xd6f(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1090 <regcomp@plt>
test   %eax,%eax
jne    13ae <main+0x19e>
mov    0x10(%rbx),%rsi
lea    0x4(%rsp),%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
cmp    (%r15),%eax
jne    13ba <main+0x1aa>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
jmp    12cd <main+0xbd>
lea    0xd31(%rip),%rdi
jmp    12e9 <main+0xd9>
lea    0x4(%rsp),%rdi
call   1040 <regfree@plt>
mov    (%r14),%edx
lea    0xd5c(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1090 <regcomp@plt>
test   %eax,%eax
jne    140b <main+0x1fb>
mov    0x8(%rbx),%rsi
lea    0xc(%rsp),%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
cmp    (%r15),%eax
jne    1417 <main+0x207>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
jmp    12cd <main+0xbd>
lea    0xd2a(%rip),%rdi
jmp    12e9 <main+0xd9>
mov    (%r14),%edx
lea    0xd5f(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1090 <regcomp@plt>
test   %eax,%eax
jne    145e <main+0x24e>
mov    0x18(%rbx),%rsi
lea    0x8(%rsp),%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
cmp    (%r15),%eax
jne    146a <main+0x25a>
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
jmp    12cd <main+0xbd>
lea    0xd21(%rip),%rdi
jmp    12e9 <main+0xd9>
lea    0x8(%rsp),%rdi
call   1040 <regfree@plt>
mov    0x8(%rbx),%rdi
call   1120 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1120 <atoi@plt>
mov    %eax,%r14d
lea    0x430(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   10b0 <stat@plt>
mov    0x10(%rsp),%edx
cmp    %ebp,%edx
jne    14cb <main+0x2bb>
mov    0x14(%rsp),%edx
cmp    %r14d,%edx
jne    14df <main+0x2cf>
lea    0x30(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    14fe <main+0x2ee>
lea    0xd87(%rip),%rdi
jmp    151a <main+0x30a>
mov    0x2b06(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
mov    %ebp,%ecx
jmp    14f2 <main+0x2e2>
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
mov    %r14d,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    12d4 <main+0xc4>
movslq %ebp,%rsi
movslq %r14d,%rdx
lea    0x30(%rsp),%rdi
call   10f0 <chown@plt>
cmp    $0xffffffff,%eax
jne    1524 <main+0x314>
lea    0xd3b(%rip),%rdi
call   1110 <perror@plt>
jmp    12d4 <main+0xc4>
mov    0x28(%rsp),%edi
call   1060 <S_ISDIR@plt>
mov    %rax,%rbp
mov    0x18(%rbx),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <strtol@plt>
test   %rbp,%rbp
mov    $0x1b7,%ecx
mov    $0x1ff,%esi
cmove  %rcx,%rsi
sub    %rax,%rsi
lea    0x30(%rsp),%rdi
call   1100 <chmod@plt>
mov    0x2a5b(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Path length is more than 1024\0A\00"
@.str.1 = [13 x i8] c"^/itu/users/\00"
@REG_EXTENDED = global i32 0
@.str.2 = [38 x i8] c"Could not compile regex rule for path\00"
@REG_NOMATCH = global i32 0
@.str.3 = [32 x i8] c"Path is not matched with regex\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [29 x i8] c"^/itu/s0[1-8]d0[1-9]|1[0-1]/\00"
@.str.5 = [44 x i8] c"Could not compile regex rule for real path\00"
@.str.6 = [37 x i8] c"Real path is not matched with regex\0A\00"
@.str.7 = [6 x i8] c"^300$\00"
@.str.8 = [37 x i8] c"Could not compile regex rule for gid\00"
@.str.9 = [31 x i8] c"GID is not matched with regex\0A\00"
@.str.10 = [18 x i8] c"^[1-9][0-9]{3,5}$\00"
@.str.11 = [37 x i8] c"Could not compile regex rule for uid\00"
@.str.12 = [31 x i8] c"UID is not matched with regex\0A\00"
@.str.13 = [6 x i8] c"^007$\00"
@.str.14 = [39 x i8] c"Could not compile regex rule for umask\00"
@.str.15 = [33 x i8] c"Umask is not matched with regex\0A\00"
@.str.16 = [65 x i8] c"UID not matched with parent directory's UID. Parent:%d - UID:%d\0A\00"
@.str.17 = [65 x i8] c"GID not matched with parent directory's GID. Parent:%d - GID:%d\0A\00"
@.str.18 = [5 x i8] c"stat\00"
@.str.19 = [6 x i8] c"chown\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.stat
%17 = alloca %struct.stat
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 4
%21 = load i8*, i8** %20
%22 = call i32 @strlen(i8* %21)
%23 = icmp sgt i32 %22, 1024
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %24, %2
%28 = bitcast [1024 x i8]* %7 to i8*
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 4
%31 = load i8*, i8** %30
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%33 = call i32 @b64_decode(i8* %31, i8* %32)
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%38 = call i32 @b64_decode(i8* %36, i8* %37)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%40 = call i32 @dirname(i8* %39)
%41 = load i32, i32* @REG_EXTENDED
%42 = call i32 @regcomp(i32* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %41)
store i32 %42, i32* %12
%43 = load i32, i32* %12
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %27
%46 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %27
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%50 = call i32 @regexec(i32* %9, i8* %49, i32 0, i32* null, i32 0)
store i32 %50, i32* %12
%51 = load i32, i32* %12
%52 = load i32, i32* @REG_NOMATCH
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %59
54: ; preds = %48
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %48
%60 = call i32 @regfree(i32* %9)
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%62 = call i8* @realpath(i8* %61, i32* null)
store i8* %62, i8** %13
%63 = load i8*, i8** %13
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %86
65: ; preds = %59
%66 = load i32, i32* @REG_EXTENDED
%67 = call i32 @regcomp(i32* %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %66)
store i32 %67, i32* %12
%68 = load i32, i32* %12
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %65
%74 = load i8*, i8** %13
%75 = call i32 @regexec(i32* %9, i8* %74, i32 0, i32* null, i32 0)
store i32 %75, i32* %12
%76 = load i32, i32* %12
%77 = load i32, i32* @REG_NOMATCH
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %84
79: ; preds = %73
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %73
%85 = call i32 @regfree(i32* %9)
br label %86
86: ; preds = %84, %59
%87 = load i32, i32* @REG_EXTENDED
%88 = call i32 @regcomp(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %87)
store i32 %88, i32* %12
%89 = load i32, i32* %12
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %86
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 2
%97 = load i8*, i8** %96
%98 = call i32 @regexec(i32* %11, i8* %97, i32 0, i32* null, i32 0)
store i32 %98, i32* %12
%99 = load i32, i32* %12
%100 = load i32, i32* @REG_NOMATCH
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %107
102: ; preds = %94
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %94
%108 = call i32 @regfree(i32* %11)
%109 = load i32, i32* @REG_EXTENDED
%110 = call i32 @regcomp(i32* %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %109)
store i32 %110, i32* %12
%111 = load i32, i32* %12
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %107
%114 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%115 = call i32 @exit(i32 1)
unreachable
116: ; preds = %107
%117 = load i8**, i8*** %5
%118 = getelementptr inbounds i8*, i8** %117, i64 1
%119 = load i8*, i8** %118
%120 = call i32 @regexec(i32* %10, i8* %119, i32 0, i32* null, i32 0)
store i32 %120, i32* %12
%121 = load i32, i32* %12
%122 = load i32, i32* @REG_NOMATCH
%123 = icmp eq i32 %121, %122
br i1 %123, label %124, label %129
124: ; preds = %116
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
%127 = load i32, i32* @EXIT_FAILURE
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %116
%130 = load i32, i32* @REG_EXTENDED
%131 = call i32 @regcomp(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %130)
store i32 %131, i32* %12
%132 = load i32, i32* %12
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %137
134: ; preds = %129
%135 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0))
%136 = call i32 @exit(i32 1)
unreachable
137: ; preds = %129
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 3
%140 = load i8*, i8** %139
%141 = call i32 @regexec(i32* %8, i8* %140, i32 0, i32* null, i32 0)
store i32 %141, i32* %12
%142 = load i32, i32* %12
%143 = load i32, i32* @REG_NOMATCH
%144 = icmp eq i32 %142, %143
br i1 %144, label %145, label %150
145: ; preds = %137
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.15, i64 0, i64 0))
%148 = load i32, i32* @EXIT_FAILURE
%149 = call i32 @exit(i32 %148)
unreachable
150: ; preds = %137
%151 = call i32 @regfree(i32* %8)
%152 = load i8**, i8*** %5
%153 = getelementptr inbounds i8*, i8** %152, i64 1
%154 = load i8*, i8** %153
%155 = call i32 @atoi(i8* %154)
store i32 %155, i32* %14
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 2
%158 = load i8*, i8** %157
%159 = call i32 @atoi(i8* %158)
store i32 %159, i32* %15
%160 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%161 = call i32 @stat(i8* %160, %struct.stat* %16)
%162 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%163 = load i32, i32* %162
%164 = load i32, i32* %14
%165 = icmp ne i32 %163, %164
br i1 %165, label %166, label %174
166: ; preds = %150
%167 = load i32, i32* @stderr
%168 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%169 = load i32, i32* %168
%170 = load i32, i32* %14
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %167, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.16, i64 0, i64 0), i32 %169, i32 %170)
%172 = load i32, i32* @EXIT_FAILURE
%173 = call i32 @exit(i32 %172)
unreachable
174: ; preds = %150
%175 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 1
%176 = load i32, i32* %175
%177 = load i32, i32* %15
%178 = icmp ne i32 %176, %177
br i1 %178, label %179, label %187
179: ; preds = %174
%180 = load i32, i32* @stderr
%181 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 1
%182 = load i32, i32* %181
%183 = load i32, i32* %15
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i64 0, i64 0), i32 %182, i32 %183)
%185 = load i32, i32* @EXIT_FAILURE
%186 = call i32 @exit(i32 %185)
unreachable
187: ; preds = %174
%188 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%189 = call i32 @stat(i8* %188, %struct.stat* %17)
%190 = icmp eq i32 %189, -1
br i1 %190, label %191, label %195
191: ; preds = %187
%192 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%193 = load i32, i32* @EXIT_FAILURE
%194 = call i32 @exit(i32 %193)
unreachable
195: ; preds = %187
%196 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%197 = load i32, i32* %14
%198 = sext i32 %197 to i64
%199 = load i32, i32* %15
%200 = sext i32 %199 to i64
%201 = call i32 @chown(i8* %196, i64 %198, i64 %200)
store i32 %201, i32* %18
%202 = load i32, i32* %18
%203 = icmp eq i32 %202, -1
br i1 %203, label %204, label %208
204: ; preds = %195
%205 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%206 = load i32, i32* @EXIT_FAILURE
%207 = call i32 @exit(i32 %206)
unreachable
208: ; preds = %195
%209 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 2
%210 = load i32, i32* %209
%211 = call i64 @S_ISDIR(i32 %210)
%212 = icmp ne i64 %211, 0
br i1 %212, label %213, label %221
213: ; preds = %208
%214 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%215 = load i8**, i8*** %5
%216 = getelementptr inbounds i8*, i8** %215, i64 3
%217 = load i8*, i8** %216
%218 = call i64 @strtol(i8* %217, i32 0, i32 8)
%219 = sub nsw i64 511, %218
%220 = call i32 @chmod(i8* %214, i64 %219)
br label %229
221: ; preds = %208
%222 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%223 = load i8**, i8*** %5
%224 = getelementptr inbounds i8*, i8** %223, i64 3
%225 = load i8*, i8** %224
%226 = call i64 @strtol(i8* %225, i32 0, i32 8)
%227 = sub nsw i64 439, %226
%228 = call i32 @chmod(i8* %222, i64 %227)
br label %229
229: ; preds = %221, %213
br label %230
230: ; preds = %229
%231 = load i32, i32* @EXIT_SUCCESS
%232 = call i32 @exit(i32 %231)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Path length is more than 1024\0A\00"
@.str.1 = [13 x i8] c"^/itu/users/\00"
@REG_EXTENDED = global i32 0
@.str.2 = [38 x i8] c"Could not compile regex rule for path\00"
@REG_NOMATCH = global i32 0
@.str.3 = [32 x i8] c"Path is not matched with regex\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [29 x i8] c"^/itu/s0[1-8]d0[1-9]|1[0-1]/\00"
@.str.5 = [44 x i8] c"Could not compile regex rule for real path\00"
@.str.6 = [37 x i8] c"Real path is not matched with regex\0A\00"
@.str.7 = [6 x i8] c"^300$\00"
@.str.8 = [37 x i8] c"Could not compile regex rule for gid\00"
@.str.9 = [31 x i8] c"GID is not matched with regex\0A\00"
@.str.10 = [18 x i8] c"^[1-9][0-9]{3,5}$\00"
@.str.11 = [37 x i8] c"Could not compile regex rule for uid\00"
@.str.12 = [31 x i8] c"UID is not matched with regex\0A\00"
@.str.13 = [6 x i8] c"^007$\00"
@.str.14 = [39 x i8] c"Could not compile regex rule for umask\00"
@.str.15 = [33 x i8] c"Umask is not matched with regex\0A\00"
@.str.16 = [65 x i8] c"UID not matched with parent directory's UID. Parent:%d - UID:%d\0A\00"
@.str.17 = [65 x i8] c"GID not matched with parent directory's GID. Parent:%d - GID:%d\0A\00"
@.str.18 = [5 x i8] c"stat\00"
@.str.19 = [6 x i8] c"chown\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca %struct.stat
%11 = getelementptr inbounds i8*, i8** %1, i64 4
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
%14 = icmp sgt i32 %13, 1024
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %2
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = load i8*, i8** %11
%22 = call i32 @b64_decode(i8* %21, i8* %19)
%23 = load i8*, i8** %11
%24 = call i32 @b64_decode(i8* %23, i8* %20)
%25 = call i32 @dirname(i8* %20)
%26 = bitcast i32* %5 to i8*
%27 = bitcast i32* %6 to i8*
%28 = bitcast i32* %7 to i8*
%29 = bitcast i32* %8 to i8*
%30 = load i32, i32* @REG_EXTENDED
%31 = call i32 @regcomp(i32* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %18
%34 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %18
%37 = call i32 @regexec(i32* %6, i8* %19, i32 0, i32* null, i32 0)
%38 = load i32, i32* @REG_NOMATCH
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %36
%46 = call i32 @regfree(i32* %6)
%47 = call i8* @realpath(i8* %19, i32* null)
%48 = icmp eq i8* %47, null
br i1 %48, label %67, label %49
49: ; preds = %45
%50 = load i32, i32* @REG_EXTENDED
%51 = call i32 @regcomp(i32* %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %49
%54 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %49
%57 = call i32 @regexec(i32* %6, i8* %47, i32 0, i32* null, i32 0)
%58 = load i32, i32* @REG_NOMATCH
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %56
%66 = call i32 @regfree(i32* %6)
br label %67
67: ; preds = %65, %45
%68 = load i32, i32* @REG_EXTENDED
%69 = call i32 @regcomp(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %68)
%70 = icmp eq i32 %69, 0
br i1 %70, label %74, label %71
71: ; preds = %67
%72 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %67
%75 = getelementptr inbounds i8*, i8** %1, i64 2
%76 = load i8*, i8** %75
%77 = call i32 @regexec(i32* %8, i8* %76, i32 0, i32* null, i32 0)
%78 = load i32, i32* @REG_NOMATCH
%79 = icmp eq i32 %77, %78
br i1 %79, label %80, label %85
80: ; preds = %74
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %74
%86 = call i32 @regfree(i32* %8)
%87 = load i32, i32* @REG_EXTENDED
%88 = call i32 @regcomp(i32* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %87)
%89 = icmp eq i32 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %85
%91 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %85
%94 = getelementptr inbounds i8*, i8** %1, i64 1
%95 = load i8*, i8** %94
%96 = call i32 @regexec(i32* %7, i8* %95, i32 0, i32* null, i32 0)
%97 = load i32, i32* @REG_NOMATCH
%98 = icmp eq i32 %96, %97
br i1 %98, label %99, label %104
99: ; preds = %93
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %93
%105 = load i32, i32* @REG_EXTENDED
%106 = call i32 @regcomp(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %105)
%107 = icmp eq i32 %106, 0
br i1 %107, label %111, label %108
108: ; preds = %104
%109 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0))
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %104
%112 = getelementptr inbounds i8*, i8** %1, i64 3
%113 = load i8*, i8** %112
%114 = call i32 @regexec(i32* %5, i8* %113, i32 0, i32* null, i32 0)
%115 = load i32, i32* @REG_NOMATCH
%116 = icmp eq i32 %114, %115
br i1 %116, label %117, label %122
117: ; preds = %111
%118 = load i32, i32* @stderr
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.15, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %111
%123 = call i32 @regfree(i32* %5)
%124 = load i8*, i8** %94
%125 = call i32 @atoi(i8* %124)
%126 = load i8*, i8** %75
%127 = call i32 @atoi(i8* %126)
%128 = bitcast %struct.stat* %9 to i8*
%129 = call i32 @stat(i8* %20, %struct.stat* %9)
%130 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 0
%131 = load i32, i32* %130
%132 = icmp eq i32 %131, %125
br i1 %132, label %138, label %133
133: ; preds = %122
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.16, i64 0, i64 0), i32 %131, i32 %125)
%136 = load i32, i32* @EXIT_FAILURE
%137 = call i32 @exit(i32 %136)
unreachable
138: ; preds = %122
%139 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 1
%140 = load i32, i32* %139
%141 = icmp eq i32 %140, %127
br i1 %141, label %147, label %142
142: ; preds = %138
%143 = load i32, i32* @stderr
%144 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i64 0, i64 0), i32 %140, i32 %127)
%145 = load i32, i32* @EXIT_FAILURE
%146 = call i32 @exit(i32 %145)
unreachable
147: ; preds = %138
%148 = bitcast %struct.stat* %10 to i8*
%149 = call i32 @stat(i8* %19, %struct.stat* %10)
%150 = icmp eq i32 %149, -1
br i1 %150, label %151, label %155
151: ; preds = %147
%152 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%153 = load i32, i32* @EXIT_FAILURE
%154 = call i32 @exit(i32 %153)
unreachable
155: ; preds = %147
%156 = sext i32 %125 to i64
%157 = sext i32 %127 to i64
%158 = call i32 @chown(i8* %19, i64 %156, i64 %157)
%159 = icmp eq i32 %158, -1
br i1 %159, label %160, label %164
160: ; preds = %155
%161 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%162 = load i32, i32* @EXIT_FAILURE
%163 = call i32 @exit(i32 %162)
unreachable
164: ; preds = %155
%165 = getelementptr inbounds %struct.stat, %struct.stat* %10, i64 0, i32 2
%166 = load i32, i32* %165
%167 = call i64 @S_ISDIR(i32 %166)
%168 = icmp eq i64 %167, 0
%169 = load i8*, i8** %112
%170 = call i64 @strtol(i8* %169, i32 0, i32 8)
%171 = select i1 %168, i64 439, i64 511
%172 = sub nsw i64 %171, %170
%173 = call i32 @chmod(i8* %19, i64 %172)
%174 = load i32, i32* @EXIT_SUCCESS
%175 = call i32 @exit(i32 %174)
unreachable
}