#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 scalar_t__ ssize_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int readlinkat(int, char *, char *, int);
int main(int argc, char *argv[]) {
  char linkname[63 + 1] = {0};
  ssize_t r;
  r = (argc < 2) ? -1 : readlinkat(1, argv[1], linkname, 63);
  return (r > 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
jge    115d <main+0x3d>
mov    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    117b <main+0x5b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x1,%edi
mov    $0x3f,%ecx
call   1040 <readlinkat@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cltq
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jle    11a0 <main+0x80>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
jmp    11ac <main+0x8c>
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
cmp    $0x1,%edi
jle    1152 <main+0x42>
mov    0x8(%rsi),%rsi
mov    %rsp,%rdx
mov    $0x1,%edi
mov    $0x3f,%ecx
call   1030 <readlinkat@plt>
test   %eax,%eax
jle    1152 <main+0x42>
mov    0x2e88(%rip),%rax
jmp    1159 <main+0x49>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [64 x i8]* %6 to i8*
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
br label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%17 = call i32 @readlinkat(i32 1, i8* %15, i8* %16, i32 63)
br label %18
18: ; preds = %12, %11
%19 = phi i32 [ -1, %11 ], [ %17, %12 ]
%20 = sext i32 %19 to i64
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i32, i32* @EXIT_SUCCESS
br label %27
25: ; preds = %18
%26 = load i32, i32* @EXIT_FAILURE
br label %27
27: ; preds = %25, %23
%28 = phi i32 [ %24, %23 ], [ %26, %25 ]
ret i32 %28
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
br label %16
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @readlinkat(i32 1, i8* %10, i8* %4, i32 63)
%12 = icmp sgt i32 %11, 0
%13 = load i32, i32* @EXIT_SUCCESS
%14 = load i32, i32* @EXIT_FAILURE
%15 = select i1 %12, i32 %13, i32 %14
br label %16
16: ; preds = %8, %6
%17 = phi i32 [ %7, %6 ], [ %15, %8 ]
ret i32 %17
}