#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*/ uid_t;
typedef int /*<<< orphan*/ gid_t;
typedef int /*<<< orphan*/ XDR;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ eacces(int);
scalar_t__ get_fn(int, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ status_return(int, int /*<<< orphan*/);
int /*<<< orphan*/ xdr_u_int(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void ltspfs_chown(int sockfd, XDR *in) {
  char path[PATH_MAX];
  uid_t uid;
  gid_t gid;
  if (!xdr_u_int(in, &uid)) {
    eacces(sockfd);
    return;
  }
  if (!xdr_u_int(in, &gid)) {
    eacces(sockfd);
    return;
  }
  if (get_fn(sockfd, in, path)) {
    eacces(sockfd);
    return;
  }
  status_return(sockfd, chown(path, uid, gid));
}


x86 assembly (clang, -O0):
<ltspfs_chown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    11b5 <ltspfs_chown+0x65>
mov    -0x4(%rbp),%edi
call   1040 <eacces@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1233 <ltspfs_chown+0xe3>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    11df <ltspfs_chown+0x8f>
mov    -0x4(%rbp),%edi
call   1040 <eacces@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1233 <ltspfs_chown+0xe3>
mov    -0x38(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <get_fn@plt>
cmp    $0x0,%rax
je     120d <ltspfs_chown+0xbd>
mov    -0x4(%rbp),%edi
call   1040 <eacces@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1233 <ltspfs_chown+0xe3>
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <chown@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   1030 <status_return@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltspfs_chown>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x20(%rbp),%rsi
mov    %r15,%rdi
call   1070 <xdr_u_int@plt>
test   %eax,%eax
je     11ad <ltspfs_chown+0x5d>
lea    -0x1c(%rbp),%rsi
mov    %r15,%rdi
call   1070 <xdr_u_int@plt>
test   %eax,%eax
je     11ad <ltspfs_chown+0x5d>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <get_fn@plt>
test   %rax,%rax
je     11c0 <ltspfs_chown+0x70>
mov    %r14d,%edi
call   1040 <eacces@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %rbx,%rdi
call   1050 <chown@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1030 <status_return@plt>
jmp    11b5 <ltspfs_chown+0x65>

LLVM IR (-O0):
@PATH_MAX = global i32 0
define void @ltspfs_chown(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%10 = load i32, i32* @PATH_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i8, i64 %11
store i64 %11, i64* %6
%14 = load i32*, i32** %4
%15 = call i32 @xdr_u_int(i32* %14, i32* %7)
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %3
%19 = call i32 @eacces(i32 %18)
store i32 1, i32* %9
br label %41
20: ; preds = %2
%21 = load i32*, i32** %4
%22 = call i32 @xdr_u_int(i32* %21, i32* %8)
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i32, i32* %3
%26 = call i32 @eacces(i32 %25)
store i32 1, i32* %9
br label %41
27: ; preds = %20
%28 = load i32, i32* %3
%29 = load i32*, i32** %4
%30 = call i64 @get_fn(i32 %28, i32* %29, i8* %13)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %3
%34 = call i32 @eacces(i32 %33)
store i32 1, i32* %9
br label %41
35: ; preds = %27
%36 = load i32, i32* %3
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = call i32 @chown(i8* %13, i32 %37, i32 %38)
%40 = call i32 @status_return(i32 %36, i32 %39)
store i32 0, i32* %9
br label %41
41: ; preds = %35, %32, %24, %17
%42 = load i8*, i8** %5
%43 = load i32, i32* %9
switch i32 %43, label %45 [
i32 0, label %44
i32 1, label %44
]
44: ; preds = %41, %41
ret void
45: ; preds = %41
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
define void @ltspfs_chown(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = call i32 @xdr_u_int(i32* %1, i32* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @eacces(i32 %0)
br label %29
14: ; preds = %2
%15 = call i32 @xdr_u_int(i32* %1, i32* %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @eacces(i32 %0)
br label %29
19: ; preds = %14
%20 = call i64 @get_fn(i32 %0, i32* %1, i8* %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @eacces(i32 %0)
br label %29
24: ; preds = %19
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 @chown(i8* %7, i32 %25, i32 %26)
%28 = call i32 @status_return(i32 %0, i32 %27)
br label %29
29: ; preds = %24, %22, %17, %12
ret void
}