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

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int /*<<< orphan*/ exit(int);
scalar_t__ mkdir(char *, int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
char *strcat(char *, char *);
int strlen(char *);
int write(int, char *, int);
void main(int argc, char **argv) {
  int i, j, fd1, fd2, ret, len;
  char buff[10];
  char cwd[1024];
  char *path;
  char *temp;
  if (argc == 1) {
    printf(
        "cp: missing file operand\nTry 'cp --help' for more information. \n");
    exit(1);
  }
  if (argc == 2) {
    printf("missing destination file operand after '%s'\n Try 'cp --help' for "
           "more information\n ",
           argv[1]);
    exit(1);
  }
  if (argc == 3) {
    if ((fd1 = open(argv[1], O_RDONLY)) < 0) {
      perror(" source file does not exist");
      exit(1);
    }
    if ((fd2 = open(argv[2], O_WRONLY | O_CREAT, 0777)) < 0) {
      perror("destination file creation fails");
      exit(1);
    }
    while ((ret = read(fd1, buff, 10)) > 0) {
      if (write(fd2, buff, ret) != ret) {
        printf(" write error");
        exit(1);
      }
      if (ret == 0) {
        close(fd2);
        close(fd1);
        exit(0);
      }
    }
  }
  if ((*(argv[argc - 1]) == '/') &&
      (*(argv[argc - 1] + strlen(argv[argc - 1]) - 1) == '/')) {
    len = strlen(argv[argc - 1]);
    if (mkdir(argv[argc - 1], 0777) < 0) {
      printf("directory creation fails\n");
      exit(1);
    }
    for (i = 1; i <= argc - 2; i++) {
      if ((fd1 = open(argv[i], O_RDONLY)) < 0) {
        perror(" File opening error");
        exit(1);
      }
      path = strcat(temp, argv[i]);
      for (j = 0; j <= len; j++) {
        if (j != len)
          temp[j] = *(argv[argc - 1] + j);
        else
          temp[len] = '\0';
      }
      if ((fd2 = creat(path, 0777)) < 0) {
        perror(" file creation in directory fails");
        exit(1);
      }
      while ((ret = read(fd1, buff, 10)) > 0) {
        if (write(fd2, buff, ret) != ret) {
          printf(" write error");
          exit(1);
        }
        if (ret == 0) {
          close(fd2);
          close(fd1);
          exit(0);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    11e4 <main+0x34>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x2,-0x4(%rbp)
jne    120e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x3,-0x4(%rbp)
jne    1317 <main+0x167>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1252 <main+0xa2>
lea    0xe52(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
mov    0x2d8e(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    129a <main+0xea>
lea    0xe26(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    129f <main+0xef>
mov    -0x1c(%rbp),%edi
lea    -0x32(%rbp),%rsi
mov    $0xa,%edx
call   1080 <read@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jle    1312 <main+0x162>
mov    -0x20(%rbp),%edi
lea    -0x32(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <write@plt>
cmp    -0x24(%rbp),%eax
je     12ec <main+0x13c>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jne    130d <main+0x15d>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    129f <main+0xef>
jmp    1317 <main+0x167>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1576 <main+0x3c6>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x458(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x458(%rbp),%rax
movslq %ecx,%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1576 <main+0x3c6>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jge    13d2 <main+0x222>
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     1571 <main+0x3c1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2be3(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1428 <main+0x278>
lea    0xcdf(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x450(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10b0 <strcat@plt>
mov    %rax,-0x448(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     14b3 <main+0x303>
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     1491 <main+0x2e1>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x450(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14a0 <main+0x2f0>
mov    -0x450(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14a5 <main+0x2f5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    144e <main+0x29e>
mov    -0x448(%rbp),%rdi
mov    $0x1ff,%esi
call   10c0 <creat@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    14e6 <main+0x336>
lea    0xc35(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    14eb <main+0x33b>
mov    -0x1c(%rbp),%edi
lea    -0x32(%rbp),%rsi
mov    $0xa,%edx
call   1080 <read@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jle    155e <main+0x3ae>
mov    -0x20(%rbp),%edi
lea    -0x32(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <write@plt>
cmp    -0x24(%rbp),%eax
je     1538 <main+0x388>
lea    0xbaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jne    1559 <main+0x3a9>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    14eb <main+0x33b>
jmp    1563 <main+0x3b3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13d9 <main+0x229>
jmp    1576 <main+0x3c6>
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
cmp    $0x3,%edi
je     1237 <main+0x87>
cmp    $0x2,%r14d
je     138d <main+0x1dd>
cmp    $0x1,%r14d
je     13a9 <main+0x1f9>
lea    -0x1(%r14),%r12d
movslq %r12d,%rbp
mov    (%r15,%rbp,8),%rbx
cmpb   $0x2f,(%rbx)
jne    1228 <main+0x78>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rbx,%rax,1)
jne    1228 <main+0x78>
mov    (%r15,%rbp,8),%rdi
call   1060 <strlen@plt>
mov    (%r15,%rbp,8),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
js     13c4 <main+0x214>
cmp    $0x3,%r14d
jge    12c0 <main+0x110>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r15),%rdi
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
js     13b2 <main+0x202>
mov    %eax,%r12d
mov    0x10(%r15),%rdi
mov    0x2d67(%rip),%rax
mov    0x2d90(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1ff,%edx
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
js     13bb <main+0x20b>
mov    %eax,%r13d
lea    0xe(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1080 <read@plt>
test   %eax,%eax
jle    11dd <main+0x2d>
mov    %eax,%ebp
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebp,%eax
je     1290 <main+0xe0>
jmp    1356 <main+0x1a6>
mov    %r12d,%eax
mov    %rax,(%rsp)
mov    $0x1,%r13d
lea    0xe(%rsp),%r14
jmp    12ee <main+0x13e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13
cmp    (%rsp),%r13
je     1228 <main+0x78>
mov    (%r15,%r13,8),%rdi
mov    0x2ce7(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
js     136e <main+0x1be>
mov    %eax,%r12d
mov    (%r15,%r13,8),%rsi
call   10b0 <strcat@plt>
mov    $0x1ff,%esi
call   10c0 <creat@plt>
test   %eax,%eax
js     1377 <main+0x1c7>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1080 <read@plt>
test   %eax,%eax
jle    12e0 <main+0x130>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebp,%eax
je     1330 <main+0x180>
lea    0xd33(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd28(%rip),%rdi
jmp    137e <main+0x1ce>
lea    0xd33(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x8(%r15),%rsi
lea    0xc68(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd3c(%rip),%rdi
jmp    13cb <main+0x21b>
lea    0xc9b(%rip),%rdi
jmp    137e <main+0x1ce>
lea    0xcae(%rip),%rdi
jmp    137e <main+0x1ce>
lea    0xd08(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"cp: missing file operand\0ATry 'cp --help' for more information. \0A\00"
@.str.1 = [84 x i8] c"missing destination file operand after '%s'\0A Try 'cp --help' for more information\0A \00"
@O_RDONLY = global i32 0
@.str.2 = [28 x i8] c" source file does not exist\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.3 = [32 x i8] c"destination file creation fails\00"
@.str.4 = [13 x i8] c" write error\00"
@.str.5 = [26 x i8] c"directory creation fails\0A\00"
@.str.6 = [20 x i8] c" File opening error\00"
@.str.7 = [34 x i8] c" file creation in directory fails\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10 x i8]
%12 = alloca [1024 x i8]
%13 = alloca i8*
%14 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %20
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %81
32: ; preds = %29
%33 = load i8**, i8*** %4
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDONLY
%37 = call i32 (i8*, i32, ...) @open(i8* %35, i32 %36)
store i32 %37, i32* %7
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %32
%43 = load i8**, i8*** %4
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = load i32, i32* @O_WRONLY
%47 = load i32, i32* @O_CREAT
%48 = or i32 %46, %47
%49 = call i32 (i8*, i32, ...) @open(i8* %45, i32 %48, i32 511)
store i32 %49, i32* %8
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %42
%52 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %42
br label %55
55: ; preds = %79, %54
%56 = load i32, i32* %7
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%58 = call i32 @read(i32 %56, i8* %57, i32 10)
store i32 %58, i32* %9
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %80
60: ; preds = %55
%61 = load i32, i32* %8
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%63 = load i32, i32* %9
%64 = call i32 @write(i32 %61, i8* %62, i32 %63)
%65 = load i32, i32* %9
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %60
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %60
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %70
%74 = load i32, i32* %8
%75 = call i32 @close(i32 %74)
%76 = load i32, i32* %7
%77 = call i32 @close(i32 %76)
%78 = call i32 @exit(i32 0)
unreachable
79: ; preds = %70
br label %55
80: ; preds = %55
br label %81
81: ; preds = %80, %29
%82 = load i8**, i8*** %4
%83 = load i32, i32* %3
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %82, i64 %85
%87 = load i8*, i8** %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 47
br i1 %90, label %91, label %226
91: ; preds = %81
%92 = load i8**, i8*** %4
%93 = load i32, i32* %3
%94 = sub nsw i32 %93, 1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8*, i8** %92, i64 %95
%97 = load i8*, i8** %96
%98 = load i8**, i8*** %4
%99 = load i32, i32* %3
%100 = sub nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %98, i64 %101
%103 = load i8*, i8** %102
%104 = call i32 @strlen(i8* %103)
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %97, i64 %105
%107 = getelementptr inbounds i8, i8* %106, i64 -1
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = icmp eq i32 %109, 47
br i1 %110, label %111, label %226
111: ; preds = %91
%112 = load i8**, i8*** %4
%113 = load i32, i32* %3
%114 = sub nsw i32 %113, 1
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %112, i64 %115
%117 = load i8*, i8** %116
%118 = call i32 @strlen(i8* %117)
store i32 %118, i32* %10
%119 = load i8**, i8*** %4
%120 = load i32, i32* %3
%121 = sub nsw i32 %120, 1
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8*, i8** %119, i64 %122
%124 = load i8*, i8** %123
%125 = call i64 @mkdir(i8* %124, i32 511)
%126 = icmp slt i64 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %111
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %111
store i32 1, i32* %5
br label %131
131: ; preds = %222, %130
%132 = load i32, i32* %5
%133 = load i32, i32* %3
%134 = sub nsw i32 %133, 2
%135 = icmp sle i32 %132, %134
br i1 %135, label %136, label %225
136: ; preds = %131
%137 = load i8**, i8*** %4
%138 = load i32, i32* %5
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i8*, i8** %137, i64 %139
%141 = load i8*, i8** %140
%142 = load i32, i32* @O_RDONLY
%143 = call i32 (i8*, i32, ...) @open(i8* %141, i32 %142)
store i32 %143, i32* %7
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %148
145: ; preds = %136
%146 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%147 = call i32 @exit(i32 1)
unreachable
148: ; preds = %136
%149 = load i8*, i8** %14
%150 = load i8**, i8*** %4
%151 = load i32, i32* %5
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8*, i8** %150, i64 %152
%154 = load i8*, i8** %153
%155 = call i8* @strcat(i8* %149, i8* %154)
store i8* %155, i8** %13
store i32 0, i32* %6
br label %156
156: ; preds = %185, %148
%157 = load i32, i32* %6
%158 = load i32, i32* %10
%159 = icmp sle i32 %157, %158
br i1 %159, label %160, label %188
160: ; preds = %156
%161 = load i32, i32* %6
%162 = load i32, i32* %10
%163 = icmp ne i32 %161, %162
br i1 %163, label %164, label %179
164: ; preds = %160
%165 = load i8**, i8*** %4
%166 = load i32, i32* %3
%167 = sub nsw i32 %166, 1
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds i8*, i8** %165, i64 %168
%170 = load i8*, i8** %169
%171 = load i32, i32* %6
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %170, i64 %172
%174 = load i8, i8* %173
%175 = load i8*, i8** %14
%176 = load i32, i32* %6
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
store i8 %174, i8* %178
br label %184
179: ; preds = %160
%180 = load i8*, i8** %14
%181 = load i32, i32* %10
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %180, i64 %182
store i8 0, i8* %183
br label %184
184: ; preds = %179, %164
br label %185
185: ; preds = %184
%186 = load i32, i32* %6
%187 = add nsw i32 %186, 1
store i32 %187, i32* %6
br label %156
188: ; preds = %156
%189 = load i8*, i8** %13
%190 = call i32 @creat(i8* %189, i32 511)
store i32 %190, i32* %8
%191 = icmp slt i32 %190, 0
br i1 %191, label %192, label %195
192: ; preds = %188
%193 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%194 = call i32 @exit(i32 1)
unreachable
195: ; preds = %188
br label %196
196: ; preds = %220, %195
%197 = load i32, i32* %7
%198 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%199 = call i32 @read(i32 %197, i8* %198, i32 10)
store i32 %199, i32* %9
%200 = icmp sgt i32 %199, 0
br i1 %200, label %201, label %221
201: ; preds = %196
%202 = load i32, i32* %8
%203 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%204 = load i32, i32* %9
%205 = call i32 @write(i32 %202, i8* %203, i32 %204)
%206 = load i32, i32* %9
%207 = icmp ne i32 %205, %206
br i1 %207, label %208, label %211
208: ; preds = %201
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%210 = call i32 @exit(i32 1)
unreachable
211: ; preds = %201
%212 = load i32, i32* %9
%213 = icmp eq i32 %212, 0
br i1 %213, label %214, label %220
214: ; preds = %211
%215 = load i32, i32* %8
%216 = call i32 @close(i32 %215)
%217 = load i32, i32* %7
%218 = call i32 @close(i32 %217)
%219 = call i32 @exit(i32 0)
unreachable
220: ; preds = %211
br label %196
221: ; preds = %196
br label %222
222: ; preds = %221
%223 = load i32, i32* %5
%224 = add nsw i32 %223, 1
store i32 %224, i32* %5
br label %131
225: ; preds = %131
br label %226
226: ; preds = %225, %91, %81
ret void
}

LLVM IR (-O2):
@.str.1 = [84 x i8] c"missing destination file operand after '%s'\0A Try 'cp --help' for more information\0A \00"
@O_RDONLY = global i32 0
@.str.2 = [28 x i8] c" source file does not exist\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.3 = [32 x i8] c"destination file creation fails\00"
@.str.4 = [13 x i8] c" write error\00"
@.str.6 = [20 x i8] c" File opening error\00"
@.str.7 = [34 x i8] c" file creation in directory fails\00"
@str = [25 x i8] c"directory creation fails\00"
@str.8 = [64 x i8] c"cp: missing file operand\0ATry 'cp --help' for more information. \00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
switch i32 %0, label %42 [
i32 1, label %5
i32 2, label %8
i32 3, label %13
]
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 (i8*, i32, ...) @open(i8* %15, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_WRONLY
%26 = load i32, i32* @O_CREAT
%27 = or i32 %26, %25
%28 = tail call i32 (i8*, i32, ...) @open(i8* %24, i32 %27, i32 511)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %22, %36
%34 = call i32 @read(i32 %17, i8* %4, i32 10)
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = call i32 @write(i32 %28, i8* %4, i32 %34)
%38 = icmp eq i32 %37, %34
br i1 %38, label %33, label %39
39: ; preds = %36
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %33, %2
%43 = add i32 %0, -1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 47
br i1 %48, label %49, label %100
49: ; preds = %42
%50 = tail call i32 @strlen(i8* %46)
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %46, i64 %51
%53 = getelementptr inbounds i8, i8* %52, i64 -1
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 47
br i1 %55, label %56, label %100
56: ; preds = %49
%57 = load i8*, i8** %45
%58 = tail call i32 @strlen(i8* %57)
%59 = load i8*, i8** %45
%60 = tail call i64 @mkdir(i8* %59, i32 511)
%61 = icmp slt i64 %60, 0
br i1 %61, label %67, label %62
62: ; preds = %56
%63 = icmp slt i32 %0, 3
br i1 %63, label %100, label %64
64: ; preds = %62
%65 = icmp slt i32 %58, 0
%66 = zext i32 %43 to i64
br label %70
67: ; preds = %56
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%69 = tail call i32 @exit(i32 1)
unreachable
70: ; preds = %64, %97
%71 = phi i64 [ 1, %64 ], [ %98, %97 ]
%72 = getelementptr inbounds i8*, i8** %1, i64 %71
%73 = load i8*, i8** %72
%74 = load i32, i32* @O_RDONLY
%75 = tail call i32 (i8*, i32, ...) @open(i8* %73, i32 %74)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %70
%78 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%79 = tail call i32 @exit(i32 1)
unreachable
80: ; preds = %70
%81 = load i8*, i8** %72
%82 = tail call i8* @strcat(i8* dereferenceable(1) undef, i8* dereferenceable(1) %81)
tail call void @llvm.assume(i1 %65)
%83 = tail call i32 @creat(i8* undef, i32 511)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%87 = tail call i32 @exit(i32 1)
unreachable
88: ; preds = %80, %91
%89 = call i32 @read(i32 %75, i8* %4, i32 10)
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %97
91: ; preds = %88
%92 = call i32 @write(i32 %83, i8* %4, i32 %89)
%93 = icmp eq i32 %92, %89
br i1 %93, label %88, label %94
94: ; preds = %91
%95 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%96 = tail call i32 @exit(i32 1)
unreachable
97: ; preds = %88
%98 = add nuw nsw i64 %71, 1
%99 = icmp eq i64 %98, %66
br i1 %99, label %100, label %70
100: ; preds = %97, %62, %49, %42
ret void
}