#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  int /*<<< orphan*/ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ PROT_READ;
int S_IRGRP;
int S_IRUSR;
int /*<<< orphan*/ S_IRWXU;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ generate_dir(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ mkdir(char *, int /*<<< orphan*/);
void *mmap(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, int /*<<< orphan*/);
int open(char *, int, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int, void *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct stat s;
  char buf[500];
  char sciezka[500];
  char *a, *b;
  char *f;
  char *t[10];
  int index = 0;
  void *start;
  int fd, fd2;
  if (argc != 2) {
    fprintf(stderr, "xdb_copy needs parameter.\r\n");
    return 0;
  }
  a = argv[1];
  b = sciezka;
  a += 6;
  memcpy(b, "./spool1/", 9);
  b += 9;
  *b = 0;
  while (1) {
    if (*a == 0) {
      break;
    }
    if (*a == '/') {
      f = a;
      if (index < 2) {
        *b = 0;
        if (stat(sciezka, &s) < 0)
          mkdir(sciezka, S_IRWXU);
        t[index] = b;
        index++;
        *b = *a;
        b++;
      }
      a++;
      continue;
    }
    if (index < 2) {
      *b = *a;
      b++;
    }
    a++;
  }
  f++;
  generate_dir(f, buf, 200);
  memcpy(b, buf + 1, 2);
  b += 2;
  *b = 0;
  if (stat(sciezka, &s) < 0)
    mkdir(sciezka, S_IRWXU);
  *b = '/';
  memcpy(b + 1, buf + 4, 2);
  b += 3;
  *b = 0;
  if (stat(sciezka, &s) < 0)
    mkdir(sciezka, S_IRWXU);
  *b = '/';
  memcpy(b + 1, f, a - f);
  b += a - f + 1;
  *b = 0;
  if (stat(argv[1], &s) < 0) {
    fprintf(stdout, "error >%s<\r\n", argv[1]);
    return 0;
  }
  fd = open(argv[1], O_RDONLY);
  start = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
  fd2 =
      open(sciezka, O_TRUNC | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
  write(fd2, start, s.st_size);
  close(fd2);
  munmap(start, s.st_size);
  close(fd);
  fprintf(stdout, "%s\r\n", sciezka);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x484(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f0 <main+0x50>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    161d <main+0x47d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x418(%rbp)
mov    -0x420(%rbp),%rdi
lea    0xdef(%rip),%rsi
mov    $0x9,%edx
call   10a0 <memcpy@plt>
mov    -0x420(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    126b <main+0xcb>
jmp    137a <main+0x1da>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1332 <main+0x192>
mov    -0x418(%rbp),%rax
mov    %rax,-0x428(%rbp)
cmpl   $0x2,-0x484(%rbp)
jge    131b <main+0x17b>
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    12d2 <main+0x132>
lea    -0x410(%rbp),%rdi
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
call   1030 <mkdir@plt>
mov    -0x420(%rbp),%rcx
movslq -0x484(%rbp),%rax
mov    %rcx,-0x480(%rbp,%rax,8)
ff
mov    -0x484(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x484(%rbp)
mov    -0x418(%rbp),%rax
mov    (%rax),%cl
mov    -0x420(%rbp),%rax
mov    %cl,(%rax)
mov    -0x420(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1253 <main+0xb3>
cmpl   $0x2,-0x484(%rbp)
jge    1363 <main+0x1c3>
mov    -0x418(%rbp),%rax
mov    (%rax),%cl
mov    -0x420(%rbp),%rax
mov    %cl,(%rax)
mov    -0x420(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1253 <main+0xb3>
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    $0xc8,%edx
call   1050 <generate_dir@plt>
mov    -0x420(%rbp),%rdi
lea    -0x210(%rbp),%rsi
add    $0x1,%rsi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
mov    -0x420(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    140b <main+0x26b>
lea    -0x410(%rbp),%rdi
mov    0x2bc4(%rip),%rax
mov    (%rax),%esi
call   1030 <mkdir@plt>
mov    -0x420(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x420(%rbp),%rdi
add    $0x1,%rdi
lea    -0x210(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
mov    -0x420(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    1480 <main+0x2e0>
lea    -0x410(%rbp),%rdi
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
call   1030 <mkdir@plt>
mov    -0x420(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x420(%rbp),%rdi
add    $0x1,%rdi
mov    -0x428(%rbp),%rsi
mov    -0x418(%rbp),%rax
mov    -0x428(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   10a0 <memcpy@plt>
mov    -0x418(%rbp),%rax
mov    -0x428(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
add    -0x420(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    1527 <main+0x387>
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xb12(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    161d <main+0x47d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2a8a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x494(%rbp)
mov    -0x18(%rbp),%esi
mov    0x2a99(%rip),%rax
mov    (%rax),%edx
mov    0x2a80(%rip),%rax
mov    (%rax),%ecx
mov    -0x494(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x490(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2a6e(%rip),%rax
mov    (%rax),%esi
mov    0x2a6d(%rip),%rax
or     (%rax),%esi
mov    0x29ec(%rip),%rax
or     (%rax),%esi
mov    0x29fb(%rip),%rax
mov    (%rax),%edx
mov    0x2a12(%rip),%rax
or     (%rax),%edx
mov    0x29f1(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x498(%rbp)
mov    -0x498(%rbp),%edi
mov    -0x490(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <write@plt>
mov    -0x498(%rbp),%edi
call   1070 <close@plt>
mov    -0x490(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10b0 <munmap@plt>
mov    -0x494(%rbp),%edi
call   1070 <close@plt>
mov    0x2991(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xa24(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x2,%edi
jne    128f <main+0xef>
mov    %rsi,0x8(%rsp)
mov    0x8(%rsi),%r13
add    $0x6,%r13
lea    0xe4e(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x9,%edx
call   10a0 <memcpy@plt>
lea    0x19(%rsp),%rbx
movb   $0x0,0x19(%rsp)
xor    %r14d,%r14d
mov    %rsp,%rsi
mov    %r13,%r12
sub    %r15,%r12
mov    %r15d,%ebp
not    %ebp
add    %r13d,%ebp
jmp    120b <main+0x6b>
nopl   (%rax)
add    $0x1,%r13
add    $0x1,%r12
add    $0x1,%ebp
movzbl 0x0(%r13),%eax
test   %al,%al
je     12ab <main+0x10b>
cmp    $0x2f,%al
je     1230 <main+0x90>
cmp    $0x1,%r14d
jg     1200 <main+0x60>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1200 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%eax
cmp    $0x1,%r14d
jg     1280 <main+0xe0>
movb   $0x0,(%rbx)
lea    0x10(%rsp),%rdi
mov    %rsi,%rbp
call   1090 <stat@plt>
test   %rax,%rax
jns    1263 <main+0xc3>
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1030 <mkdir@plt>
add    $0x1,%r14d
mov    0x0(%r13),%al
mov    %al,(%rbx)
add    $0x1,%rbx
mov    %rbp,%rsi
jmp    1283 <main+0xe3>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%r14d
mov    %r13,%r15
add    $0x1,%r13
jmp    11ed <main+0x4d>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1451 <main+0x2b1>
add    $0x1,%r15
lea    0x210(%rsp),%rsi
mov    %r15,%rdi
mov    $0xc8,%edx
call   1050 <generate_dir@plt>
lea    0x211(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
movb   $0x0,0x2(%rbx)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
jns    1302 <main+0x162>
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1030 <mkdir@plt>
movb   $0x2f,0x2(%rbx)
lea    0x3(%rbx),%rdi
lea    0x214(%rsp),%rsi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
movb   $0x0,0x5(%rbx)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
jns    1345 <main+0x1a5>
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1030 <mkdir@plt>
movb   $0x2f,0x5(%rbx)
lea    0x6(%rbx),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   10a0 <memcpy@plt>
movb   $0x0,0x5(%rbx,%r12,1)
mov    0x8(%rsp),%rbx
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
js     1436 <main+0x296>
mov    0x8(%rbx),%rdi
mov    0x2c3e(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%r15d
mov    (%rsp),%esi
mov    0x2c50(%rip),%rax
mov    (%rax),%edx
mov    0x2c37(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    0x2c39(%rip),%rcx
mov    0x2c3a(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    0x2bb7(%rip),%rcx
or     (%rcx),%esi
mov    0x2bc6(%rip),%rcx
mov    0x2bdf(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    %rax,%rbp
mov    0x2bb9(%rip),%rax
or     (%rax),%edx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%ebx
mov    (%rsp),%edx
mov    %eax,%edi
mov    %rbp,%rsi
call   1040 <write@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    (%rsp),%esi
mov    %rbp,%rdi
call   10b0 <munmap@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2b68(%rip),%rax
mov    (%rax),%edi
lea    0xc02(%rip),%rsi
mov    %r14,%rdx
jmp    144a <main+0x2aa>
mov    0x2b53(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xbdc(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"xdb_copy needs parameter.\0D\0A\00"
@.str.1 = [10 x i8] c"./spool1/\00"
@S_IRWXU = global i32 0
@stdout = global i32 0
@.str.2 = [13 x i8] c"error >%s<\0D\0A\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@.str.3 = [5 x i8] c"%s\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca [500 x i8]
%8 = alloca [500 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [10 x i8*]
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %13
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %194
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %9
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
store i8* %26, i8** %10
%27 = load i8*, i8** %9
%28 = getelementptr inbounds i8, i8* %27, i64 6
store i8* %28, i8** %9
%29 = load i8*, i8** %10
%30 = call i32 @memcpy(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%31 = load i8*, i8** %10
%32 = getelementptr inbounds i8, i8* %31, i64 9
store i8* %32, i8** %10
%33 = load i8*, i8** %10
store i8 0, i8* %33
br label %34
34: ; preds = %22, %70, %82
%35 = load i8*, i8** %9
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
br label %85
40: ; preds = %34
%41 = load i8*, i8** %9
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 47
br i1 %44, label %45, label %73
45: ; preds = %40
%46 = load i8*, i8** %9
store i8* %46, i8** %11
%47 = load i32, i32* %13
%48 = icmp slt i32 %47, 2
br i1 %48, label %49, label %70
49: ; preds = %45
%50 = load i8*, i8** %10
store i8 0, i8* %50
%51 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%52 = call i64 @stat(i8* %51, %struct.stat* %6)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%56 = load i32, i32* @S_IRWXU
%57 = call i32 @mkdir(i8* %55, i32 %56)
br label %58
58: ; preds = %54, %49
%59 = load i8*, i8** %10
%60 = load i32, i32* %13
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 %61
store i8* %59, i8** %62
%63 = load i32, i32* %13
%64 = add nsw i32 %63, 1
store i32 %64, i32* %13
%65 = load i8*, i8** %9
%66 = load i8, i8* %65
%67 = load i8*, i8** %10
store i8 %66, i8* %67
%68 = load i8*, i8** %10
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %10
br label %70
70: ; preds = %58, %45
%71 = load i8*, i8** %9
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %9
br label %34
73: ; preds = %40
%74 = load i32, i32* %13
%75 = icmp slt i32 %74, 2
br i1 %75, label %76, label %82
76: ; preds = %73
%77 = load i8*, i8** %9
%78 = load i8, i8* %77
%79 = load i8*, i8** %10
store i8 %78, i8* %79
%80 = load i8*, i8** %10
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %10
br label %82
82: ; preds = %76, %73
%83 = load i8*, i8** %9
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %9
br label %34
85: ; preds = %39
%86 = load i8*, i8** %11
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %11
%88 = load i8*, i8** %11
%89 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%90 = call i32 @generate_dir(i8* %88, i8* %89, i32 200)
%91 = load i8*, i8** %10
%92 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%93 = getelementptr inbounds i8, i8* %92, i64 1
%94 = call i32 @memcpy(i8* %91, i8* %93, i32 2)
%95 = load i8*, i8** %10
%96 = getelementptr inbounds i8, i8* %95, i64 2
store i8* %96, i8** %10
%97 = load i8*, i8** %10
store i8 0, i8* %97
%98 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%99 = call i64 @stat(i8* %98, %struct.stat* %6)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %85
%102 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%103 = load i32, i32* @S_IRWXU
%104 = call i32 @mkdir(i8* %102, i32 %103)
br label %105
105: ; preds = %101, %85
%106 = load i8*, i8** %10
store i8 47, i8* %106
%107 = load i8*, i8** %10
%108 = getelementptr inbounds i8, i8* %107, i64 1
%109 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%110 = getelementptr inbounds i8, i8* %109, i64 4
%111 = call i32 @memcpy(i8* %108, i8* %110, i32 2)
%112 = load i8*, i8** %10
%113 = getelementptr inbounds i8, i8* %112, i64 3
store i8* %113, i8** %10
%114 = load i8*, i8** %10
store i8 0, i8* %114
%115 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%116 = call i64 @stat(i8* %115, %struct.stat* %6)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %105
%119 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%120 = load i32, i32* @S_IRWXU
%121 = call i32 @mkdir(i8* %119, i32 %120)
br label %122
122: ; preds = %118, %105
%123 = load i8*, i8** %10
store i8 47, i8* %123
%124 = load i8*, i8** %10
%125 = getelementptr inbounds i8, i8* %124, i64 1
%126 = load i8*, i8** %11
%127 = load i8*, i8** %9
%128 = load i8*, i8** %11
%129 = ptrtoint i8* %127 to i64
%130 = ptrtoint i8* %128 to i64
%131 = sub i64 %129, %130
%132 = trunc i64 %131 to i32
%133 = call i32 @memcpy(i8* %125, i8* %126, i32 %132)
%134 = load i8*, i8** %9
%135 = load i8*, i8** %11
%136 = ptrtoint i8* %134 to i64
%137 = ptrtoint i8* %135 to i64
%138 = sub i64 %136, %137
%139 = add nsw i64 %138, 1
%140 = load i8*, i8** %10
%141 = getelementptr inbounds i8, i8* %140, i64 %139
store i8* %141, i8** %10
%142 = load i8*, i8** %10
store i8 0, i8* %142
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 1
%145 = load i8*, i8** %144
%146 = call i64 @stat(i8* %145, %struct.stat* %6)
%147 = icmp slt i64 %146, 0
br i1 %147, label %148, label %154
148: ; preds = %122
%149 = load i32, i32* @stdout
%150 = load i8**, i8*** %5
%151 = getelementptr inbounds i8*, i8** %150, i64 1
%152 = load i8*, i8** %151
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %152)
store i32 0, i32* %3
br label %194
154: ; preds = %122
%155 = load i8**, i8*** %5
%156 = getelementptr inbounds i8*, i8** %155, i64 1
%157 = load i8*, i8** %156
%158 = load i32, i32* @O_RDONLY
%159 = call i32 (i8*, i32, ...) @open(i8* %157, i32 %158)
store i32 %159, i32* %15
%160 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%161 = load i32, i32* %160
%162 = load i32, i32* @PROT_READ
%163 = load i32, i32* @MAP_SHARED
%164 = load i32, i32* %15
%165 = call i8* @mmap(i32* null, i32 %161, i32 %162, i32 %163, i32 %164, i32 0)
store i8* %165, i8** %14
%166 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%167 = load i32, i32* @O_TRUNC
%168 = load i32, i32* @O_CREAT
%169 = or i32 %167, %168
%170 = load i32, i32* @O_WRONLY
%171 = or i32 %169, %170
%172 = load i32, i32* @S_IRUSR
%173 = load i32, i32* @S_IWUSR
%174 = or i32 %172, %173
%175 = load i32, i32* @S_IRGRP
%176 = or i32 %174, %175
%177 = call i32 (i8*, i32, ...) @open(i8* %166, i32 %171, i32 %176)
store i32 %177, i32* %16
%178 = load i32, i32* %16
%179 = load i8*, i8** %14
%180 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%181 = load i32, i32* %180
%182 = call i32 @write(i32 %178, i8* %179, i32 %181)
%183 = load i32, i32* %16
%184 = call i32 @close(i32 %183)
%185 = load i8*, i8** %14
%186 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%187 = load i32, i32* %186
%188 = call i32 @munmap(i8* %185, i32 %187)
%189 = load i32, i32* %15
%190 = call i32 @close(i32 %189)
%191 = load i32, i32* @stdout
%192 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%193 = call i32 (i32, i8*, ...) @fprintf(i32 %191, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %192)
store i32 0, i32* %3
br label %194
194: ; preds = %154, %148, %19
%195 = load i32, i32* %3
ret i32 %195
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"xdb_copy needs parameter.\0D\0A\00"
@.str.1 = [10 x i8] c"./spool1/\00"
@S_IRWXU = global i32 0
@stdout = global i32 0
@.str.2 = [13 x i8] c"error >%s<\0D\0A\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@.str.3 = [5 x i8] c"%s\0D\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %115
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 6
%17 = call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 9
store i8 0, i8* %18
br label %19
19: ; preds = %40, %13
%20 = phi i8* [ %27, %40 ], [ undef, %13 ]
%21 = phi i32 [ %41, %40 ], [ 0, %13 ]
%22 = phi i8* [ %42, %40 ], [ %18, %13 ]
%23 = phi i8* [ %43, %40 ], [ %16, %13 ]
%24 = icmp slt i32 %21, 2
br label %25
25: ; preds = %19, %47
%26 = phi i8* [ %48, %47 ], [ %22, %19 ]
%27 = phi i8* [ %49, %47 ], [ %23, %19 ]
%28 = load i8, i8* %27
switch i8 %28, label %44 [
i8 0, label %50
i8 47, label %29
]
29: ; preds = %25
br i1 %24, label %30, label %40
30: ; preds = %29
store i8 0, i8* %26
%31 = call i64 @stat(i8* %8, %struct.stat* %3)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* @S_IRWXU
%35 = call i32 @mkdir(i8* %8, i32 %34)
br label %36
36: ; preds = %33, %30
%37 = add nsw i32 %21, 1
%38 = load i8, i8* %27
store i8 %38, i8* %26
%39 = getelementptr inbounds i8, i8* %26, i64 1
br label %40
40: ; preds = %36, %29
%41 = phi i32 [ %37, %36 ], [ 2, %29 ]
%42 = phi i8* [ %39, %36 ], [ %26, %29 ]
%43 = getelementptr inbounds i8, i8* %27, i64 1
br label %19
44: ; preds = %25
br i1 %24, label %45, label %47
45: ; preds = %44
store i8 %28, i8* %26
%46 = getelementptr inbounds i8, i8* %26, i64 1
br label %47
47: ; preds = %45, %44
%48 = phi i8* [ %46, %45 ], [ %26, %44 ]
%49 = getelementptr inbounds i8, i8* %27, i64 1
br label %25
50: ; preds = %25
%51 = getelementptr inbounds i8, i8* %20, i64 1
%52 = call i32 @generate_dir(i8* %51, i8* %7, i32 200)
%53 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 1
%54 = call i32 @memcpy(i8* %26, i8* %53, i32 2)
%55 = getelementptr inbounds i8, i8* %26, i64 2
store i8 0, i8* %55
%56 = call i64 @stat(i8* %8, %struct.stat* %3)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %50
%59 = load i32, i32* @S_IRWXU
%60 = call i32 @mkdir(i8* %8, i32 %59)
br label %61
61: ; preds = %58, %50
store i8 47, i8* %55
%62 = getelementptr inbounds i8, i8* %26, i64 3
%63 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 4
%64 = call i32 @memcpy(i8* %62, i8* %63, i32 2)
%65 = getelementptr inbounds i8, i8* %26, i64 5
store i8 0, i8* %65
%66 = call i64 @stat(i8* %8, %struct.stat* %3)
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %61
%69 = load i32, i32* @S_IRWXU
%70 = call i32 @mkdir(i8* %8, i32 %69)
br label %71
71: ; preds = %68, %61
store i8 47, i8* %65
%72 = getelementptr inbounds i8, i8* %26, i64 6
%73 = ptrtoint i8* %27 to i64
%74 = ptrtoint i8* %51 to i64
%75 = sub i64 %73, %74
%76 = trunc i64 %75 to i32
%77 = call i32 @memcpy(i8* %72, i8* %51, i32 %76)
%78 = add nsw i64 %75, 1
%79 = getelementptr inbounds i8, i8* %65, i64 %78
store i8 0, i8* %79
%80 = load i8*, i8** %14
%81 = call i64 @stat(i8* %80, %struct.stat* %3)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %87
83: ; preds = %71
%84 = load i32, i32* @stdout
%85 = load i8*, i8** %14
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %85)
br label %115
87: ; preds = %71
%88 = load i8*, i8** %14
%89 = load i32, i32* @O_RDONLY
%90 = call i32 (i8*, i32, ...) @open(i8* %88, i32 %89)
%91 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%92 = load i32, i32* %91
%93 = load i32, i32* @PROT_READ
%94 = load i32, i32* @MAP_SHARED
%95 = call i8* @mmap(i32* null, i32 %92, i32 %93, i32 %94, i32 %90, i32 0)
%96 = load i32, i32* @O_TRUNC
%97 = load i32, i32* @O_CREAT
%98 = or i32 %97, %96
%99 = load i32, i32* @O_WRONLY
%100 = or i32 %98, %99
%101 = load i32, i32* @S_IRUSR
%102 = load i32, i32* @S_IWUSR
%103 = or i32 %102, %101
%104 = load i32, i32* @S_IRGRP
%105 = or i32 %103, %104
%106 = call i32 (i8*, i32, ...) @open(i8* %8, i32 %100, i32 %105)
%107 = load i32, i32* %91
%108 = call i32 @write(i32 %106, i8* %95, i32 %107)
%109 = call i32 @close(i32 %106)
%110 = load i32, i32* %91
%111 = call i32 @munmap(i8* %95, i32 %110)
%112 = call i32 @close(i32 %90)
%113 = load i32, i32* @stdout
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %8)
br label %115
115: ; preds = %87, %83, %10
ret i32 0
}