#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int symlink(char const *, char const *);
int main(int argc, char **argv) {
  const char *newpath, *oldpath;
  int r;
  if (argc != 3) {
    fprintf(stderr, "%s <oldpath> <newpath>\n", argv[0]);
    return 1;
  }
  oldpath = argv[1];
  newpath = argv[2];
  r = symlink(oldpath, newpath);
  if (r != 0) {
    fprintf(stderr, "failed to create symlink %s\n", newpath);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1168 <main+0x48>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xea9(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <symlink@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11bf <main+0x9f>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <main+0xa6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jne    114f <main+0x2f>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbx
mov    %rbx,%rsi
call   1030 <symlink@plt>
test   %eax,%eax
je     116e <main+0x4e>
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
lea    0xece(%rip),%rsi
mov    %rbx,%rdx
jmp    1162 <main+0x42>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"%s <oldpath> <newpath>\0A\00"
@.str.1 = [29 x i8] c"failed to create symlink %s\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %34
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i8*, i8** %7
%25 = load i8*, i8** %6
%26 = call i32 @symlink(i8* %24, i8* %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %17
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %6
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 1, i32* %3
br label %34
33: ; preds = %17
store i32 0, i32* %3
br label %34
34: ; preds = %33, %29, %11
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"%s <oldpath> <newpath>\0A\00"
@.str.1 = [29 x i8] c"failed to create symlink %s\0A\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 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %18
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @symlink(i8* %10, i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %18
18: ; preds = %8, %15, %4
%19 = phi i32 [ 1, %4 ], [ 1, %15 ], [ 0, %8 ]
ret i32 %19
}