#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 /*<<< orphan*/ exit(int);
int getxattr(char *, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int connected(void) {
  char *test_str = "1";
  char buf[2] = " \0";
  int size = 0;
  size = getxattr(".", "tsumufs.connected", buf, strlen(buf));
  if (size == -1) {
    perror("Unable to getxattr tsumufs.connected from current directory");
    exit(1);
  }
  if (strcmp(buf, test_str) == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<connected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe98(%rip),%ax
mov    %ax,-0x12(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x12(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe71(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <getxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11c2 <connected+0x72>
lea    0xe65(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x12(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e5 <connected+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11ec <connected+0x9c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connected>:
push   %rbx
sub    $0x10,%rsp
movw   $0x20,0xe(%rsp)
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe92(%rip),%rdi
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1060 <getxattr@plt>
cmp    $0xffffffff,%eax
je     11a7 <connected+0x57>
lea    0xe73(%rip),%rsi
lea    0xe(%rsp),%rdi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe68(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@__const.connected.buf = [2 x i8] c" \00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [18 x i8] c"tsumufs.connected\00"
@.str.3 = [60 x i8] c"Unable to getxattr tsumufs.connected from current directory\00"
define i32 @connected() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [2 x i8]
%4 = alloca i32
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = bitcast [2 x i8]* %3 to i8*
store i32 0, i32* %4
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @getxattr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i64 @strcmp(i8* %16, i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 1, i32* %1
br label %22
21: ; preds = %15
store i32 0, i32* %1
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [18 x i8] c"tsumufs.connected\00"
@.str.3 = [60 x i8] c"Unable to getxattr tsumufs.connected from current directory\00"
define i32 @connected() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
store i16 32, i16* %1
%3 = call i32 @strlen(i8* %2)
%4 = call i32 @getxattr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
ret i32 %12
}