#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*/ uint64_t;
struct btrfs_ioctl_ino_lookup_args {
  unsigned long long objectid;
  int /*<<< orphan*/ treeid;
};
typedef int /*<<< orphan*/ args;

/* Variables and functions */
int /*<<< orphan*/ BTRFS_IOC_INO_LOOKUP;
int errno;
int ioctl(int, int /*<<< orphan*/, struct btrfs_ioctl_ino_lookup_args *);
int /*<<< orphan*/ memset(struct btrfs_ioctl_ino_lookup_args *,
                          int /*<<< orphan*/, int);
int lookup_btrfs_subvolid(int fd, uint64_t *subvolid) {
  int ret;
  struct btrfs_ioctl_ino_lookup_args args;
  memset(&args, 0, sizeof(args));
  args.objectid = 256ULL;
  ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
  if (ret)
    return errno;
  *subvolid = args.treeid;
  return 0;
}


x86 assembly (clang, -O0):
<lookup_btrfs_subvolid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movq   $0x100,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117a <lookup_btrfs_subvolid+0x5a>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <lookup_btrfs_subvolid+0x6a>
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup_btrfs_subvolid>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0x8(%rsp),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movq   $0x100,0x8(%rsp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r15,%rdx
call   1040 <ioctl@plt>
test   %eax,%eax
je     1170 <lookup_btrfs_subvolid+0x50>
mov    0x2e6c(%rip),%rax
mov    (%rax),%ebx
jmp    1177 <lookup_btrfs_subvolid+0x57>
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.btrfs_ioctl_ino_lookup_args = type { i64, i32 }
@BTRFS_IOC_INO_LOOKUP = global i32 0
@errno = global i32 0
define i32 @lookup_btrfs_subvolid(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.btrfs_ioctl_ino_lookup_args
store i32 %0, i32* %4
store i32* %1, i32** %5
%8 = call i32 @memset(%struct.btrfs_ioctl_ino_lookup_args* %7, i32 0, i32 16)
%9 = getelementptr inbounds %struct.btrfs_ioctl_ino_lookup_args, %struct.btrfs_ioctl_ino_lookup_args* %7, i32 0, i32 0
store i64 256, i64* %9
%10 = load i32, i32* %4
%11 = load i32, i32* @BTRFS_IOC_INO_LOOKUP
%12 = call i32 @ioctl(i32 %10, i32 %11, %struct.btrfs_ioctl_ino_lookup_args* %7)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* @errno
store i32 %16, i32* %3
br label %21
17: ; preds = %2
%18 = getelementptr inbounds %struct.btrfs_ioctl_ino_lookup_args, %struct.btrfs_ioctl_ino_lookup_args* %7, i32 0, i32 1
%19 = load i32, i32* %18
%20 = load i32*, i32** %5
store i32 %19, i32* %20
store i32 0, i32* %3
br label %21
21: ; preds = %17, %15
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.btrfs_ioctl_ino_lookup_args = type { i64, i32 }
@BTRFS_IOC_INO_LOOKUP = global i32 0
@errno = global i32 0
define i32 @lookup_btrfs_subvolid(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.btrfs_ioctl_ino_lookup_args
%4 = bitcast %struct.btrfs_ioctl_ino_lookup_args* %3 to i8*
%5 = call i32 @memset(%struct.btrfs_ioctl_ino_lookup_args* %3, i32 0, i32 16)
%6 = getelementptr inbounds %struct.btrfs_ioctl_ino_lookup_args, %struct.btrfs_ioctl_ino_lookup_args* %3, i64 0, i32 0
store i64 256, i64* %6
%7 = load i32, i32* @BTRFS_IOC_INO_LOOKUP
%8 = call i32 @ioctl(i32 %0, i32 %7, %struct.btrfs_ioctl_ino_lookup_args* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = load i32, i32* @errno
br label %15
12: ; preds = %2
%13 = getelementptr inbounds %struct.btrfs_ioctl_ino_lookup_args, %struct.btrfs_ioctl_ino_lookup_args* %3, i64 0, i32 1
%14 = load i32, i32* %13
store i32 %14, i32* %1
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ %11, %10 ], [ 0, %12 ]
ret i32 %16
}