#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 */
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ CreateLink(char *, char *);
scalar_t__ IsVerbose();
char *getcwd(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int main(int argc, char *argv[], char *envp[]) {
  char cwd[64 * 1024], argv1[64 * 1024], argv2[64 * 1024], *p;
  if (argc != 3) {
    printf("Usage: symlink <to> <from>\n");
    return -1;
  }
  p = getcwd(cwd, sizeof(cwd));
  for (; *p != '\0'; ++p)
    if (*p == '\\')
      *p = '/';
  sprintf(argv1, "%s/%s", cwd, argv[1]);
  sprintf(argv2, "%s/%s", cwd, argv[2]);
  if (IsVerbose()) {
    printf("symlink: linktarget: %s; tocreate: %s\n", argv2, argv1);
  }
  CreateLink(argv2, argv1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1191 <main+0x41>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <main+0x130>
lea    -0x10020(%rbp),%rdi
mov    $0x10000,%esi
call   1050 <getcwd@plt>
mov    %rax,-0x30028(%rbp)
mov    -0x30028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f5 <main+0xa5>
mov    -0x30028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11d9 <main+0x89>
mov    -0x30028(%rbp),%rax
movb   $0x2f,(%rax)
jmp    11de <main+0x8e>
mov    -0x30028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30028(%rbp)
jmp    11a9 <main+0x59>
lea    -0x20020(%rbp),%rdi
lea    -0x10020(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe0a(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30020(%rbp),%rdi
lea    -0x10020(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xde8(%rip),%rsi
call   1070 <sprintf@plt>
mov    $0x0,%al
call   1060 <IsVerbose@plt>
cmp    $0x0,%rax
je     1266 <main+0x116>
lea    -0x30020(%rbp),%rsi
lea    -0x20020(%rbp),%rdx
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30020(%rbp),%rdi
lea    -0x20020(%rbp),%rsi
call   1030 <CreateLink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30000,%rsp
cmp    $0x3,%edi
jne    1214 <main+0xb4>
mov    %rsi,%rbx
lea    0x20000(%rsp),%rdi
mov    $0x10000,%esi
call   1060 <getcwd@plt>
jmp    1197 <main+0x37>
nopl   0x0(%rax)
movb   $0x2f,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x5c,%cl
je     1190 <main+0x30>
test   %cl,%cl
jne    1193 <main+0x33>
mov    0x8(%rbx),%rcx
lea    0xe52(%rip),%r14
lea    0x10000(%rsp),%rdi
lea    0x20000(%rsp),%r15
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <sprintf@plt>
mov    0x10(%rbx),%rcx
mov    %rsp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <sprintf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <IsVerbose@plt>
test   %rax,%rax
je     1202 <main+0xa2>
lea    0xe16(%rip),%rdi
mov    %rsp,%rsi
lea    0x10000(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
lea    0x10000(%rsp),%rsi
call   1040 <CreateLink@plt>
jmp    1225 <main+0xc5>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x30000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Usage: symlink <to> <from>\0A\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [39 x i8] c"symlink: linktarget: %s; tocreate: %s\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [65536 x i8]
%9 = alloca [65536 x i8]
%10 = alloca [65536 x i8]
%11 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %58
16: ; preds = %3
%17 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%18 = call i8* @getcwd(i8* %17, i32 65536)
store i8* %18, i8** %11
br label %19
19: ; preds = %32, %16
%20 = load i8*, i8** %11
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %19
%25 = load i8*, i8** %11
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 92
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i8*, i8** %11
store i8 47, i8* %30
br label %31
31: ; preds = %29, %24
br label %32
32: ; preds = %31
%33 = load i8*, i8** %11
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %11
br label %19
35: ; preds = %19
%36 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* %40)
%42 = getelementptr inbounds [65536 x i8], [65536 x i8]* %10, i64 0, i64 0
%43 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%44 = load i8**, i8*** %6
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %43, i8* %46)
%48 = call i64 (...) @IsVerbose()
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %35
%51 = getelementptr inbounds [65536 x i8], [65536 x i8]* %10, i64 0, i64 0
%52 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %51, i8* %52)
br label %54
54: ; preds = %50, %35
%55 = getelementptr inbounds [65536 x i8], [65536 x i8]* %10, i64 0, i64 0
%56 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%57 = call i32 @CreateLink(i8* %55, i8* %56)
store i32 0, i32* %4
br label %58
58: ; preds = %54, %14
%59 = load i32, i32* %4
ret i32 %59
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [39 x i8] c"symlink: linktarget: %s; tocreate: %s\0A\00"
@str = [27 x i8] c"Usage: symlink <to> <from>\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca [65536 x i8]
%5 = alloca [65536 x i8]
%6 = alloca [65536 x i8]
%7 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%10 = icmp eq i32 %0, 3
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %34
13: ; preds = %3
%14 = call i8* @getcwd(i8* %7, i32 65536)
br label %15
15: ; preds = %19, %13
%16 = phi i8* [ %14, %13 ], [ %20, %19 ]
%17 = load i8, i8* %16
switch i8 %17, label %19 [
i8 0, label %21
i8 92, label %18
]
18: ; preds = %15
store i8 47, i8* %16
br label %19
19: ; preds = %15, %18
%20 = getelementptr inbounds i8, i8* %16, i64 1
br label %15
21: ; preds = %15
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %26)
%28 = call i64 (...) @IsVerbose()
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %8)
br label %32
32: ; preds = %30, %21
%33 = call i32 @CreateLink(i8* %9, i8* %8)
br label %34
34: ; preds = %32, %11
%35 = phi i32 [ -1, %11 ], [ 0, %32 ]
ret i32 %35
}