#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 *);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int);
int symlink(char *);
int main() {
  int output = 0;
  int error_code = 0;
  output = symlink("timothy/home/tests/new_dir"
                   "timothy/home/test/new_dir_link");
  output = mkdir("timothy/home/test/new_dir_link");
  printf("output %d\n", output);
  if (output < 0) {
    error_code = errno;
    printf("error code %d\n", error_code);
    printf("Error description is : %s\n", strerror(errno));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe9c(%rip),%rdi
call   1050 <symlink@plt>
mov    %eax,-0x8(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11d2 <main+0x92>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <symlink@plt>
lea    0xec6(%rip),%rdi
call   1030 <mkdir@plt>
mov    %eax,%ebx
lea    0xed7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jns    119e <main+0x5e>
mov    0x2e6a(%rip),%rbx
mov    (%rbx),%esi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1060 <strerror@plt>
lea    0xebf(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"timothy/home/tests/new_dirtimothy/home/test/new_dir_link\00"
@.str.1 = [31 x i8] c"timothy/home/test/new_dir_link\00"
@.str.2 = [11 x i8] c"output %d\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"error code %d\0A\00"
@.str.4 = [27 x i8] c"Error description is : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 @symlink(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %2
%5 = call i32 @mkdir(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %0
%11 = load i32, i32* @errno
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %10, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"timothy/home/tests/new_dirtimothy/home/test/new_dir_link\00"
@.str.1 = [31 x i8] c"timothy/home/test/new_dir_link\00"
@.str.2 = [11 x i8] c"output %d\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"error code %d\0A\00"
@.str.4 = [27 x i8] c"Error description is : %s\0A\00"
define i32 @main() {
%1 = tail call i32 @symlink(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @mkdir(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%4 = icmp slt i32 %2, 0
br i1 %4, label %5, label %11
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %5, %0
ret i32 0
}