#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__ EEXIST;
scalar_t__ errno;
int execl(char *, char *, char *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ legal_string(char *);
scalar_t__ malloc(scalar_t__);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  char *src_dir = "/nfs/garbage/incoming/";
  char *dest_dir = "/nfs/garbage/sourceforge/";
  char *move_path = "/bin/mv";
  char *move_file = "mv";
  char *dest_file;
  char *src_file;
  if (argc != 3) {
    fprintf(stderr, "FAILURE: usage: fileforge file group");
    exit(1);
  } else {
    src_file = (char *)malloc(strlen(src_dir) + strlen(argv[1]) + 1);
    strcpy(src_file, src_dir);
    strcat(src_file, argv[1]);
    dest_file = (char *)malloc(strlen(dest_dir) + strlen(argv[2]) + 1);
    strcpy(dest_file, dest_dir);
    strcat(dest_file, argv[2]);
    if (!legal_string(src_file)) {
      fprintf(stderr, "FAILURE: illegal characters in source file\n");
      exit(1);
    }
    if (!legal_string(dest_file)) {
      fprintf(stderr, "FAILURE: illegal characters in destination file\n");
      exit(1);
    }
    if ((mkdir(dest_file, 0775) != 0) && errno != EEXIST) {
      fprintf(stderr, "FAILURE: destination directory could not be created\n");
      exit(1);
    }
    if (execl(move_path, move_file, src_file, dest_file, (char *)0) == -1) {
      perror("FAILURE");
      exit(1);
    }
  }
  printf("OK\n");
  free(dest_file);
  free(src_file);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe23(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe2f(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe3e(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe38(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     122b <main+0x6b>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10b0 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   10b0 <strcat@plt>
mov    -0x40(%rbp),%rdi
call   10e0 <legal_string@plt>
cmp    $0x0,%eax
jne    12f4 <main+0x134>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <legal_string@plt>
cmp    $0x0,%eax
jne    1325 <main+0x165>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xd74(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
cmp    $0x0,%rax
je     1376 <main+0x1b6>
mov    0x2c8c(%rip),%rax
mov    (%rax),%rax
mov    0x2c92(%rip),%rcx
cmp    (%rcx),%rax
je     1376 <main+0x1b6>
mov    0x2c7a(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10d0 <execl@plt>
cmp    $0xffffffff,%eax
jne    13af <main+0x1ef>
lea    0xd50(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    13b4 <main+0x1f4>
lea    0xd3d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    124f <main+0x8f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <strlen@plt>
lea    0x17(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
lea    0xe13(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
mov    0x10(%rbx),%rdi
call   1070 <strlen@plt>
lea    0x1a(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r15
lea    0xdfa(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rsi
mov    %r15,%rdi
call   10b0 <strcat@plt>
mov    %r14,%rdi
call   10e0 <legal_string@plt>
test   %eax,%eax
jne    126e <main+0xae>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
jmp    125f <main+0x9f>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %r15,%rdi
call   10e0 <legal_string@plt>
test   %eax,%eax
jne    128c <main+0xcc>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
jmp    125f <main+0x9f>
mov    %r15,%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
test   %rax,%rax
je     12b4 <main+0xf4>
mov    0x2d2b(%rip),%rax
mov    (%rax),%rax
mov    0x2d31(%rip),%rcx
cmp    (%rcx),%rax
jne    130e <main+0x14e>
lea    0xd76(%rip),%rdi
lea    0xd74(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   10d0 <execl@plt>
cmp    $0xffffffff,%eax
jne    12eb <main+0x12b>
lea    0xe14(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xe06(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
jmp    125f <main+0x9f>

LLVM IR (-O0):
@.str = [23 x i8] c"/nfs/garbage/incoming/\00"
@.str.1 = [26 x i8] c"/nfs/garbage/sourceforge/\00"
@.str.2 = [8 x i8] c"/bin/mv\00"
@.str.3 = [3 x i8] c"mv\00"
@stderr = global i32 0
@.str.4 = [37 x i8] c"FAILURE: usage: fileforge file group\00"
@.str.5 = [44 x i8] c"FAILURE: illegal characters in source file\0A\00"
@.str.6 = [49 x i8] c"FAILURE: illegal characters in destination file\0A\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.7 = [53 x i8] c"FAILURE: destination directory could not be created\0A\00"
@.str.8 = [8 x i8] c"FAILURE\00"
@.str.9 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %9
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = call i64 @strlen(i8* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strlen(i8* %23)
%25 = add nsw i64 %20, %24
%26 = add nsw i64 %25, 1
%27 = call i64 @malloc(i64 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %11
%29 = load i8*, i8** %11
%30 = load i8*, i8** %6
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %11
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcat(i8* %32, i8* %35)
%37 = load i8*, i8** %7
%38 = call i64 @strlen(i8* %37)
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i64 @strlen(i8* %41)
%43 = add nsw i64 %38, %42
%44 = add nsw i64 %43, 1
%45 = call i64 @malloc(i64 %44)
%46 = inttoptr i64 %45 to i8*
store i8* %46, i8** %10
%47 = load i8*, i8** %10
%48 = load i8*, i8** %7
%49 = call i32 @strcpy(i8* %47, i8* %48)
%50 = load i8*, i8** %10
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32 @strcat(i8* %50, i8* %53)
%55 = load i8*, i8** %11
%56 = call i32 @legal_string(i8* %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %18
%59 = load i32, i32* @stderr
%60 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %18
%63 = load i8*, i8** %10
%64 = call i32 @legal_string(i8* %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %62
%71 = load i8*, i8** %10
%72 = call i64 @mkdir(i8* %71, i32 509)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %82
74: ; preds = %70
%75 = load i64, i64* @errno
%76 = load i64, i64* @EEXIST
%77 = icmp ne i64 %75, %76
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %74, %70
%83 = load i8*, i8** %8
%84 = load i8*, i8** %9
%85 = load i8*, i8** %11
%86 = load i8*, i8** %10
%87 = call i32 @execl(i8* %83, i8* %84, i8* %85, i8* %86, i8* null)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %92
89: ; preds = %82
%90 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %82
br label %93
93: ; preds = %92
%94 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%95 = load i8*, i8** %10
%96 = call i32 @free(i8* %95)
%97 = load i8*, i8** %11
%98 = call i32 @free(i8* %97)
%99 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"/nfs/garbage/incoming/\00"
@.str.1 = [26 x i8] c"/nfs/garbage/sourceforge/\00"
@.str.2 = [8 x i8] c"/bin/mv\00"
@.str.3 = [3 x i8] c"mv\00"
@stderr = global i32 0
@.str.4 = [37 x i8] c"FAILURE: usage: fileforge file group\00"
@.str.5 = [44 x i8] c"FAILURE: illegal characters in source file\0A\00"
@.str.6 = [49 x i8] c"FAILURE: illegal characters in destination file\0A\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.7 = [53 x i8] c"FAILURE: destination directory could not be created\0A\00"
@.str.8 = [8 x i8] c"FAILURE\00"
@str = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, 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 i64 @strlen(i8* dereferenceable(1) %10)
%12 = add nsw i64 %11, 23
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %9
%17 = tail call i32 @strcat(i8* %14, i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i64 @strlen(i8* dereferenceable(1) %19)
%21 = add nsw i64 %20, 26
%22 = tail call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i8*
%24 = tail call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8*, i8** %18
%26 = tail call i32 @strcat(i8* %23, i8* %25)
%27 = tail call i32 @legal_string(i8* %14)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %8
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %8
%34 = tail call i32 @legal_string(i8* %23)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %33
%41 = tail call i64 @mkdir(i8* %23, i32 509)
%42 = icmp eq i64 %41, 0
br i1 %42, label %51, label %43
43: ; preds = %40
%44 = load i64, i64* @errno
%45 = load i64, i64* @EEXIST
%46 = icmp eq i64 %44, %45
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %43, %40
%52 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %14, i8* %23, i8* null)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%56 = tail call i32 @exit(i32 1)
unreachable
57: ; preds = %51
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%59 = tail call i32 @free(i8* %23)
%60 = tail call i32 @free(i8* %14)
%61 = tail call i32 @exit(i32 0)
unreachable
}