#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 */
scalar_t__ MAXPATHLEN;
char *calloc(scalar_t__, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ readlink(char *, char *, scalar_t__);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  char *buf = calloc(MAXPATHLEN + 1, sizeof(char));
  if (argc < 1)
    return 1;
  (void)readlink(argv[1], buf, MAXPATHLEN);
  fprintf(stdout, "%s", buf);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1187 <main+0x47>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e4e(%rip),%rax
mov    (%rax),%rdx
call   1030 <readlink@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e95(%rip),%rbx
mov    (%rbx),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %ebp,%ebp
jg     1178 <main+0x38>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%r14
mov    0x8(%r15),%rdi
mov    (%rbx),%rdx
mov    %rax,%rsi
call   1030 <readlink@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@MAXPATHLEN = global i64 0
@stdout = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i64, i64* @MAXPATHLEN
%8 = add nsw i64 %7, 1
%9 = call i8* @calloc(i64 %8, i32 1)
store i8* %9, i8** %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
ret i32 1
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8*, i8** %6
%18 = load i64, i64* @MAXPATHLEN
%19 = call i32 @readlink(i8* %16, i8* %17, i64 %18)
%20 = load i32, i32* @stdout
%21 = load i8*, i8** %6
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@MAXPATHLEN = global i64 0
@stdout = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i64, i64* @MAXPATHLEN
%4 = add nsw i64 %3, 1
%5 = tail call i8* @calloc(i64 %4, i32 1)
%6 = icmp slt i32 %0, 1
br i1 %6, label %7, label %8
7: ; preds = %2
ret i32 1
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i64, i64* @MAXPATHLEN
%12 = tail call i32 @readlink(i8* %10, i8* %5, i64 %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%15 = tail call i32 @exit(i32 0)
unreachable
}