#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 */
scalar_t__ copy(char *, char *);
scalar_t__ dircopy(int, char **);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  if (argc < 3)
    return 1;
  int ret = 0;
  if (argc == 3) {
    if (copy(argv[1], argv[2]) < 0) {
      perror("cp");
      ret = 1;
    }
  } else {
    if (dircopy(argc, argv) < 0)
      ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11cc <main+0x9c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11a4 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <copy@plt>
cmp    $0x0,%rax
jge    119f <main+0x6f>
lea    0xe6d(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x14(%rbp)
jmp    11c6 <main+0x96>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <dircopy@plt>
cmp    $0x0,%rax
jge    11c1 <main+0x91>
movl   $0x1,-0x14(%rbp)
jmp    11c6 <main+0x96>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%eax
cmp    $0x3,%edi
jl     1154 <main+0x24>
jne    1156 <main+0x26>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1040 <copy@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1161 <main+0x31>
pop    %rcx
ret
call   1030 <dircopy@plt>
shr    $0x3f,%rax
pop    %rcx
ret
lea    0xe98(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cp\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %34
10: ; preds = %2
store i32 0, i32* %6
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i64 @copy(i8* %16, i8* %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %24
24: ; preds = %22, %13
br label %32
25: ; preds = %10
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i64 @dircopy(i32 %26, i8** %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 1, i32* %6
br label %31
31: ; preds = %30, %25
br label %32
32: ; preds = %31, %24
%33 = load i32, i32* %6
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %9
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"cp\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i64 @copy(i8* %8, i8* %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %6
%14 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %4
%16 = tail call i64 @dircopy(i32 %0, i8** %1)
%17 = lshr i64 %16, 63
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %15, %13, %6, %2
%20 = phi i32 [ 1, %2 ], [ 1, %13 ], [ 0, %6 ], [ %18, %15 ]
ret i32 %20
}