#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 */
struct statfs {
  int f_flags;
};

/* Variables and functions */
int /*<<< orphan*/ die(char *, char *);
int /*<<< orphan*/ errno;
int statfs(char *, struct statfs *);
char *strerror(int /*<<< orphan*/);
void test_statfs(bool nosymfollow) {
  struct statfs buf;
  int ret;
  ret = statfs("/tmp", &buf);
  if (ret)
    die("statfs failed: %s\n", strerror(errno));
  if (nosymfollow) {
    if ((buf.f_flags & 0x2000) == 0)
      die("ST_NOSYMFOLLOW not set on %s\n", "/tmp");
  } else {
    if ((buf.f_flags & 0x2000) != 0)
      die("ST_NOSYMFOLLOW set on %s\n", "/tmp");
  }
}


x86 assembly (clang, -O0):
<test_statfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <statfs@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1175 <test_statfs+0x45>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe95(%rip),%rdi
call   1040 <die@plt>
cmpl   $0x0,-0x4(%rbp)
je     11a8 <test_statfs+0x78>
mov    -0x8(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
jne    11a3 <test_statfs+0x73>
lea    0xe81(%rip),%rdi
lea    0xe62(%rip),%rsi
call   1040 <die@plt>
jmp    11d1 <test_statfs+0xa1>
mov    -0x8(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     11cc <test_statfs+0x9c>
lea    0xe76(%rip),%rdi
lea    0xe39(%rip),%rsi
call   1040 <die@plt>
jmp    11d1 <test_statfs+0xa1>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_statfs>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xec2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <statfs@plt>
test   %eax,%eax
je     1169 <test_statfs+0x39>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xea4(%rip),%rdi
mov    %rax,%rsi
call   1040 <die@plt>
mov    0x8(%rsp),%eax
test   %ebx,%ebx
je     1181 <test_statfs+0x51>
test   $0x2000,%eax
jne    119b <test_statfs+0x6b>
lea    0xe99(%rip),%rdi
jmp    118f <test_statfs+0x5f>
test   $0x2000,%eax
je     119b <test_statfs+0x6b>
lea    0xea7(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <die@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statfs = type { i32 }
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [19 x i8] c"statfs failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [30 x i8] c"ST_NOSYMFOLLOW not set on %s\0A\00"
@.str.3 = [26 x i8] c"ST_NOSYMFOLLOW set on %s\0A\00"
define void @test_statfs(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.statfs
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @statfs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.statfs* %3)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8, %1
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i32 0, i32 0
%17 = load i32, i32* %16
%18 = and i32 %17, 8192
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
br label %31
23: ; preds = %12
%24 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i32 0, i32 0
%25 = load i32, i32* %24
%26 = and i32 %25, 8192
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %23
br label %31
31: ; preds = %30, %22
ret void
}

LLVM IR (-O2):
%struct.statfs = type { i32 }
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [19 x i8] c"statfs failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [30 x i8] c"ST_NOSYMFOLLOW not set on %s\0A\00"
@.str.3 = [26 x i8] c"ST_NOSYMFOLLOW set on %s\0A\00"
define void @test_statfs(i32 %0) {
%2 = alloca %struct.statfs
%3 = bitcast %struct.statfs* %2 to i8*
%4 = call i32 @statfs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.statfs* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %1
%11 = icmp eq i32 %0, 0
%12 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, 8192
%15 = icmp eq i32 %14, 0
br i1 %11, label %17, label %16
16: ; preds = %10
br i1 %15, label %18, label %21
17: ; preds = %10
br i1 %15, label %21, label %18
18: ; preds = %17, %16
%19 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %16 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %17 ]
%20 = call i32 @die(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %18, %17, %16
ret void
}