#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ puts(char *);
int readlink(char *, char *, int);
int /*<<< orphan*/ symlink(char *, char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main() {
  symlink(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/moehuster/czq/refs/heads/master/day04/link.c",
      "mylink");
  char buf[100];
  int n = readlink("mylink", buf, sizeof(buf));
  write(STDOUT_FILENO, buf, n);
  puts("");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xeae(%rip),%rdi
lea    0xf2e(%rip),%rsi
call   1060 <symlink@plt>
lea    -0x70(%rbp),%rsi
lea    0xf1e(%rip),%rdi
mov    $0x64,%edx
call   1040 <readlink@plt>
mov    %eax,-0x74(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   1050 <write@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xeb2(%rip),%rdi
lea    0xf32(%rip),%rbx
mov    %rbx,%rsi
call   1060 <symlink@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1040 <readlink@plt>
mov    0x2e79(%rip),%rcx
mov    (%rcx),%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/moehuster/czq/refs/heads/master/day04/link.c\00"
@.str.1 = [7 x i8] c"mylink\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = call i32 @symlink(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @readlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 100)
store i32 %5, i32* %2
%6 = load i32, i32* @STDOUT_FILENO
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @write(i32 %6, i8* %7, i32 %8)
%10 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/moehuster/czq/refs/heads/master/day04/link.c\00"
@.str.1 = [7 x i8] c"mylink\00"
@STDOUT_FILENO = global i32 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 @symlink(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @readlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 100)
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @write(i32 %5, i8* %3, i32 %4)
%7 = tail call i32 @putchar(i32 10)
ret i32 0
}