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

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ eacces(int);
scalar_t__ get_fn(int, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ status_return(int, int /*<<< orphan*/);
int /*<<< orphan*/ truncate(char *, int /*<<< orphan*/);
int /*<<< orphan*/ xdr_longlong_t(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void ltspfs_truncate(int sockfd, XDR *in) {
  char path[PATH_MAX];
  off_t offset;
  if (!xdr_longlong_t(in, &offset)) {
    eacces(sockfd);
    return;
  }
  if (get_fn(sockfd, in, path)) {
    eacces(sockfd);
    return;
  }
  status_return(sockfd, truncate(path, offset));
}


x86 assembly (clang, -O0):
<ltspfs_truncate>:
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,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <xdr_longlong_t@plt>
cmp    $0x0,%eax
jne    11b5 <ltspfs_truncate+0x65>
mov    -0x4(%rbp),%edi
call   1060 <eacces@plt>
movl   $0x1,-0x28(%rbp)
jmp    1206 <ltspfs_truncate+0xb6>
mov    -0x30(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <get_fn@plt>
cmp    $0x0,%rax
je     11e3 <ltspfs_truncate+0x93>
mov    -0x4(%rbp),%edi
call   1060 <eacces@plt>
movl   $0x1,-0x28(%rbp)
jmp    1206 <ltspfs_truncate+0xb6>
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%esi
call   1050 <truncate@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1030 <status_return@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltspfs_truncate>:
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    -0x1c(%rbp),%rsi
mov    %r15,%rdi
call   1040 <xdr_longlong_t@plt>
test   %eax,%eax
je     119d <ltspfs_truncate+0x4d>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <get_fn@plt>
test   %rax,%rax
je     11a7 <ltspfs_truncate+0x57>
mov    %r14d,%edi
call   1060 <eacces@plt>
jmp    11bc <ltspfs_truncate+0x6c>
mov    -0x1c(%rbp),%esi
mov    %rbx,%rdi
call   1050 <truncate@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1030 <status_return@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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