#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;
struct afp_volume {
  int dummy;
};
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int EPERM;
int extra_translate(struct afp_volume *, char const *, char **);
int /*<<< orphan*/ free(char *);
int appledouble_chown(struct afp_volume *volume, const char *path, uid_t uid,
                      gid_t gid) {
  int resource;
  char *newpath;
  resource = extra_translate(volume, path, &newpath);
  free(newpath);
  if (resource == 0)
    return 0;
  return -EPERM;
}


x86 assembly (clang, -O0):
<appledouble_chown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <extra_translate@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x24(%rbp)
jne    1169 <appledouble_chown+0x49>
movl   $0x0,-0x4(%rbp)
jmp    1177 <appledouble_chown+0x57>
xor    %eax,%eax
mov    0x2e66(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appledouble_chown>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdx
call   1040 <extra_translate@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x2e96(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
test   %ebx,%ebx
cmove  %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.afp_volume = type { i32 }
@EPERM = global i32 0
define i32 @appledouble_chown(%struct.afp_volume* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.afp_volume*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store %struct.afp_volume* %0, %struct.afp_volume** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load %struct.afp_volume*, %struct.afp_volume** %6
%13 = load i8*, i8** %7
%14 = call i32 @extra_translate(%struct.afp_volume* %12, i8* %13, i8** %11)
store i32 %14, i32* %10
%15 = load i8*, i8** %11
%16 = call i32 @free(i8* %15)
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %4
store i32 0, i32* %5
br label %23
20: ; preds = %4
%21 = load i32, i32* @EPERM
%22 = sub nsw i32 0, %21
store i32 %22, i32* %5
br label %23
23: ; preds = %20, %19
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
%struct.afp_volume = type { i32 }
@EPERM = global i32 0
define i32 @appledouble_chown(%struct.afp_volume* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i32 @extra_translate(%struct.afp_volume* %0, i8* %1, i8** %5)
%8 = load i8*, i8** %5
%9 = call i32 @free(i8* %8)
%10 = icmp eq i32 %7, 0
%11 = load i32, i32* @EPERM
%12 = sub nsw i32 0, %11
%13 = select i1 %10, i32 0, i32 %12
ret i32 %13
}