#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*/ name;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int readlink(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char const *, unsigned long,
                            unsigned long);
void fail(const char *fmt, unsigned long a, unsigned long b) {
  char name[64];
  char buf[64];
  snprintf(name, sizeof(name), fmt, a, b);
  if (readlink(name, buf, sizeof(buf)) == -1 && errno == ENOENT)
    return;
  exit(1);
}


x86 assembly (clang, -O0):
<fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x40,%esi
call   1040 <snprintf@plt>
lea    -0x60(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x40,%edx
call   1030 <readlink@plt>
cmp    $0xffffffff,%eax
jne    11a2 <fail+0x72>
mov    0x2e5a(%rip),%rax
mov    (%rax),%rax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11a2 <fail+0x72>
add    $0xa0,%rsp
pop    %rbp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<fail>:
push   %rbx
sub    $0x80,%rsp
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <snprintf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   1030 <readlink@plt>
cmp    $0xffffffff,%eax
jne    1187 <fail+0x57>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%rax
jne    1187 <fail+0x57>
add    $0x80,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@ENOENT = global i64 0
define void @fail(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [64 x i8]
%8 = alloca [64 x i8]
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = call i32 @snprintf(i8* %9, i32 64, i8* %10, i64 %11, i64 %12)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%16 = call i32 @readlink(i8* %14, i8* %15, i32 64)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %23
18: ; preds = %3
%19 = load i64, i64* @errno
%20 = load i64, i64* @ENOENT
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %18
ret void
23: ; preds = %18, %3
%24 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@errno = global i64 0
@ENOENT = global i64 0
define void @fail(i8* %0, i64 %1, i64 %2) {
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = call i32 @snprintf(i8* %6, i32 64, i8* %0, i64 %1, i64 %2)
%9 = call i32 @readlink(i8* %6, i8* %7, i32 64)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i64, i64* @errno
%13 = load i64, i64* @ENOENT
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
ret void
16: ; preds = %11, %3
%17 = call i32 @exit(i32 1)
unreachable
}