#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 errno;
int mkdir(char *, char *);
int /*<<< orphan*/ printf(char *, int, int);
int rmdir(char *);
int symlink(char *, char *);
int main() {
  int err;
  err = symlink("aa", "stoaa");
  printf("err=%d, errno=%d\n", err, errno);
  err = 0;
  err = mkdir("aa", "777");
  printf("err=%d, errno=%d\n", err, errno);
  err = 0;
  err = rmdir("stoaa");
  printf("err=%d, errno=%d\n", err, errno);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xead(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1060 <symlink@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
lea    0xe78(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
lea    0xe40(%rip),%rdi
call   1040 <rmdir@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e0e(%rip),%rax
mov    (%rax),%edx
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb4(%rip),%r15
lea    0xeaa(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <symlink@plt>
mov    0x2e78(%rip),%r12
mov    (%r12),%edx
lea    0xe93(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
lea    0xe94(%rip),%rsi
mov    %r15,%rdi
call   1030 <mkdir@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <rmdir@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"aa\00"
@.str.1 = [6 x i8] c"stoaa\00"
@.str.2 = [18 x i8] c"err=%d, errno=%d\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"777\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @errno
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5)
store i32 0, i32* %2
%7 = call i32 @mkdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* @errno
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
store i32 0, i32* %2
%11 = call i32 @rmdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = load i32, i32* @errno
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"aa\00"
@.str.1 = [6 x i8] c"stoaa\00"
@.str.2 = [18 x i8] c"err=%d, errno=%d\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"777\00"
define i32 @main() {
%1 = tail call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @errno
%3 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %2)
%4 = tail call i32 @mkdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%5 = load i32, i32* @errno
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5)
%7 = tail call i32 @rmdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @errno
%9 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8)
ret i32 0
}