#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*/ _PC_REC_XFER_ALIGN;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ die_if(int, char *);
scalar_t__ errno;
long fpathconf(int, int /*<<< orphan*/);
scalar_t__ get_physical_block_size(int);
size_t get_readbuf_align(int fd) {
  long align_l;
  errno = 0;
  align_l = fpathconf(fd, _PC_REC_XFER_ALIGN);
  assert(align_l >= -1);
  switch (align_l) {
  case -1:
    die_if(errno != 0, "fpathconf");
  case 0:
    align_l = (long)get_physical_block_size(fd);
  }
  return (size_t)align_l;
}


x86 assembly (clang, -O0):
<get_readbuf_align>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
call   1060 <fpathconf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0xffffffffffffffff,%rax
setge  %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
sub    $0xffffffffffffffff,%rax
je     11aa <get_readbuf_align+0x6a>
jmp    1198 <get_readbuf_align+0x58>
mov    -0x18(%rbp),%rax
test   %rax,%rax
je     11c9 <get_readbuf_align+0x89>
jmp    11d5 <get_readbuf_align+0x95>
mov    0x2e2f(%rip),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe3c(%rip),%rsi
call   1040 <die_if@plt>
mov    -0x4(%rbp),%edi
call   1030 <get_physical_block_size@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_readbuf_align>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    0x2e93(%rip),%r14
movq   $0x0,(%r14)
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1060 <fpathconf@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmp    $0xffffffffffffffff,%rax
setge  %dil
call   1050 <assert@plt>
test   %rbx,%rbx
je     1195 <get_readbuf_align+0x55>
cmp    $0xffffffffffffffff,%rbx
jne    11a0 <get_readbuf_align+0x60>
xor    %edi,%edi
cmpq   $0x0,(%r14)
setne  %dil
lea    0xe70(%rip),%rsi
call   1040 <die_if@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <get_physical_block_size@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@_PC_REC_XFER_ALIGN = global i32 0
@.str = [10 x i8] c"fpathconf\00"
define i64 @get_readbuf_align(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
store i64 0, i64* @errno
%4 = load i32, i32* %2
%5 = load i32, i32* @_PC_REC_XFER_ALIGN
%6 = call i64 @fpathconf(i32 %4, i32 %5)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = icmp sge i64 %7, -1
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i64, i64* %3
switch i64 %11, label %20 [
i64 -1, label %12
i64 0, label %17
]
12: ; preds = %1
%13 = load i64, i64* @errno
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @die_if(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %1, %12
%18 = load i32, i32* %2
%19 = call i64 @get_physical_block_size(i32 %18)
store i64 %19, i64* %3
br label %20
20: ; preds = %17, %1
%21 = load i64, i64* %3
ret i64 %21
}

LLVM IR (-O2):
@errno = global i64 0
@_PC_REC_XFER_ALIGN = global i32 0
@.str = [10 x i8] c"fpathconf\00"
define i64 @get_readbuf_align(i32 %0) {
store i64 0, i64* @errno
%2 = load i32, i32* @_PC_REC_XFER_ALIGN
%3 = tail call i64 @fpathconf(i32 %0, i32 %2)
%4 = icmp sgt i64 %3, -2
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
switch i64 %3, label %14 [
i64 -1, label %7
i64 0, label %12
]
7: ; preds = %1
%8 = load i64, i64* @errno
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @die_if(i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %1, %7
%13 = tail call i64 @get_physical_block_size(i32 %0)
br label %14
14: ; preds = %12, %1
%15 = phi i64 [ %3, %1 ], [ %13, %12 ]
ret i64 %15
}