#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 */
struct yaffs_utimbuf {
  int dummy;
};
struct yaffs_obj {
  int dummy;
};

/* Variables and functions */
scalar_t__ yaffsfs_CheckPath(char const *);
int yaffsfs_DoUtime(struct yaffs_obj *, struct yaffs_utimbuf const *);
struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *, char const *,
                                     int /*<<< orphan*/, int,
                                     struct yaffs_obj **, int *, int *);
int /*<<< orphan*/ yaffsfs_Lock();
int /*<<< orphan*/ yaffsfs_SetError(int);
int /*<<< orphan*/ yaffsfs_Unlock();
int yaffs_utime_reldir(struct yaffs_obj *reldir, const char *path,
                       const struct yaffs_utimbuf *buf) {
  struct yaffs_obj *obj = (0);
  struct yaffs_obj *dir = (0);
  int retVal = -1;
  int notDir = 0;
  int loop = 0;
  if (!path) {
    yaffsfs_SetError(-14);
    return -1;
  }
  if (yaffsfs_CheckPath(path) < 0) {
    yaffsfs_SetError(-36);
    return -1;
  }
  yaffsfs_Lock();
  obj = yaffsfs_FindObject(reldir, path, 0, 1, &dir, &notDir, &loop);
  if (!dir && notDir)
    yaffsfs_SetError(-20);
  else if (loop)
    yaffsfs_SetError(-40);
  else if (!dir || !obj)
    yaffsfs_SetError(-2);
  else
    retVal = yaffsfs_DoUtime(obj, buf);
  yaffsfs_Unlock();
  return retVal;
}


x86 assembly (clang, -O0):
<yaffs_utime_reldir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ba <yaffs_utime_reldir+0x5a>
mov    $0xfffffff2,%edi
call   1050 <yaffsfs_SetError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129b <yaffs_utime_reldir+0x13b>
mov    -0x18(%rbp),%rdi
call   1070 <yaffsfs_CheckPath@plt>
cmp    $0x0,%rax
jge    11e3 <yaffs_utime_reldir+0x83>
mov    $0xffffffdc,%edi
call   1050 <yaffsfs_SetError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129b <yaffs_utime_reldir+0x13b>
mov    $0x0,%al
call   1060 <yaffsfs_Lock@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
mov    $0x1,%ecx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x3c(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <yaffsfs_FindObject@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1236 <yaffs_utime_reldir+0xd6>
cmpl   $0x0,-0x38(%rbp)
je     1236 <yaffs_utime_reldir+0xd6>
mov    $0xffffffec,%edi
call   1050 <yaffsfs_SetError@plt>
jmp    128e <yaffs_utime_reldir+0x12e>
cmpl   $0x0,-0x3c(%rbp)
je     124f <yaffs_utime_reldir+0xef>
mov    $0xffffffd8,%edi
call   1050 <yaffsfs_SetError@plt>
jmp    1289 <yaffs_utime_reldir+0x129>
cmpq   $0x0,-0x30(%rbp)
je     1265 <yaffs_utime_reldir+0x105>
cmpq   $0x0,-0x28(%rbp)
jne    1274 <yaffs_utime_reldir+0x114>
mov    $0xfffffffe,%edi
call   1050 <yaffsfs_SetError@plt>
jmp    1284 <yaffs_utime_reldir+0x124>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <yaffsfs_DoUtime@plt>
mov    %eax,-0x34(%rbp)
jmp    1289 <yaffs_utime_reldir+0x129>
jmp    128e <yaffs_utime_reldir+0x12e>
mov    $0x0,%al
call   1040 <yaffsfs_Unlock@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yaffs_utime_reldir>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
test   %rsi,%rsi
je     11e1 <yaffs_utime_reldir+0x81>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1070 <yaffsfs_CheckPath@plt>
test   %rax,%rax
js     11e8 <yaffs_utime_reldir+0x88>
xor    %eax,%eax
call   1060 <yaffsfs_Lock@plt>
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0x18(%rsp),%r8
lea    0x14(%rsp),%r9
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <yaffsfs_FindObject@plt>
mov    0x18(%rsp),%rcx
test   %rcx,%rcx
jne    11f9 <yaffs_utime_reldir+0x99>
cmpl   $0x0,0x14(%rsp)
je     11f9 <yaffs_utime_reldir+0x99>
mov    $0xffffffec,%edi
jmp    1225 <yaffs_utime_reldir+0xc5>
mov    $0xfffffff2,%edi
jmp    11ed <yaffs_utime_reldir+0x8d>
mov    $0xffffffdc,%edi
call   1050 <yaffsfs_SetError@plt>
mov    $0xffffffff,%ebx
jmp    1236 <yaffs_utime_reldir+0xd6>
cmpl   $0x0,0x10(%rsp)
je     1207 <yaffs_utime_reldir+0xa7>
mov    $0xffffffd8,%edi
jmp    1225 <yaffs_utime_reldir+0xc5>
test   %rcx,%rcx
je     1220 <yaffs_utime_reldir+0xc0>
test   %rax,%rax
je     1220 <yaffs_utime_reldir+0xc0>
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <yaffsfs_DoUtime@plt>
mov    %eax,%ebx
jmp    122f <yaffs_utime_reldir+0xcf>
mov    $0xfffffffe,%edi
call   1050 <yaffsfs_SetError@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   1040 <yaffsfs_Unlock@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.yaffs_obj = type { i32 }
%struct.yaffs_utimbuf = type { i32 }
define i32 @yaffs_utime_reldir(%struct.yaffs_obj* %0, i8* %1, %struct.yaffs_utimbuf* %2) {
%4 = alloca i32
%5 = alloca %struct.yaffs_obj*
%6 = alloca i8*
%7 = alloca %struct.yaffs_utimbuf*
%8 = alloca %struct.yaffs_obj*
%9 = alloca %struct.yaffs_obj*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store %struct.yaffs_obj* %0, %struct.yaffs_obj** %5
store i8* %1, i8** %6
store %struct.yaffs_utimbuf* %2, %struct.yaffs_utimbuf** %7
store %struct.yaffs_obj* null, %struct.yaffs_obj** %8
store %struct.yaffs_obj* null, %struct.yaffs_obj** %9
store i32 -1, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %3
%16 = call i32 @yaffsfs_SetError(i32 -14)
store i32 -1, i32* %4
br label %57
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i64 @yaffsfs_CheckPath(i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @yaffsfs_SetError(i32 -36)
store i32 -1, i32* %4
br label %57
23: ; preds = %17
%24 = call i32 (...) @yaffsfs_Lock()
%25 = load %struct.yaffs_obj*, %struct.yaffs_obj** %5
%26 = load i8*, i8** %6
%27 = call %struct.yaffs_obj* @yaffsfs_FindObject(%struct.yaffs_obj* %25, i8* %26, i32 0, i32 1, %struct.yaffs_obj** %9, i32* %11, i32* %12)
store %struct.yaffs_obj* %27, %struct.yaffs_obj** %8
%28 = load %struct.yaffs_obj*, %struct.yaffs_obj** %9
%29 = icmp ne %struct.yaffs_obj* %28, null
br i1 %29, label %35, label %30
30: ; preds = %23
%31 = load i32, i32* %11
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @yaffsfs_SetError(i32 -20)
br label %54
35: ; preds = %30, %23
%36 = load i32, i32* %12
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @yaffsfs_SetError(i32 -40)
br label %53
40: ; preds = %35
%41 = load %struct.yaffs_obj*, %struct.yaffs_obj** %9
%42 = icmp ne %struct.yaffs_obj* %41, null
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load %struct.yaffs_obj*, %struct.yaffs_obj** %8
%45 = icmp ne %struct.yaffs_obj* %44, null
br i1 %45, label %48, label %46
46: ; preds = %43, %40
%47 = call i32 @yaffsfs_SetError(i32 -2)
br label %52
48: ; preds = %43
%49 = load %struct.yaffs_obj*, %struct.yaffs_obj** %8
%50 = load %struct.yaffs_utimbuf*, %struct.yaffs_utimbuf** %7
%51 = call i32 @yaffsfs_DoUtime(%struct.yaffs_obj* %49, %struct.yaffs_utimbuf* %50)
store i32 %51, i32* %10
br label %52
52: ; preds = %48, %46
br label %53
53: ; preds = %52, %38
br label %54
54: ; preds = %53, %33
%55 = call i32 (...) @yaffsfs_Unlock()
%56 = load i32, i32* %10
store i32 %56, i32* %4
br label %57
57: ; preds = %54, %21, %15
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
%struct.yaffs_obj = type { i32 }
%struct.yaffs_utimbuf = type { i32 }
define i32 @yaffs_utime_reldir(%struct.yaffs_obj* %0, i8* %1, %struct.yaffs_utimbuf* %2) {
%4 = alloca %struct.yaffs_obj*
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.yaffs_obj** %4 to i8*
store %struct.yaffs_obj* null, %struct.yaffs_obj** %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%10 = icmp eq i8* %1, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @yaffsfs_SetError(i32 -14)
br label %44
13: ; preds = %3
%14 = tail call i64 @yaffsfs_CheckPath(i8* %1)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @yaffsfs_SetError(i32 -36)
br label %44
18: ; preds = %13
%19 = tail call i32 (...) @yaffsfs_Lock()
%20 = call %struct.yaffs_obj* @yaffsfs_FindObject(%struct.yaffs_obj* %0, i8* %1, i32 0, i32 1, %struct.yaffs_obj** %4, i32* %5, i32* %6)
%21 = load %struct.yaffs_obj*, %struct.yaffs_obj** %4
%22 = icmp eq %struct.yaffs_obj* %21, null
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 0
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = call i32 @yaffsfs_SetError(i32 -20)
br label %41
28: ; preds = %18
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @yaffsfs_SetError(i32 -40)
br label %41
33: ; preds = %28
%34 = icmp ne %struct.yaffs_obj* %21, null
%35 = icmp ne %struct.yaffs_obj* %20, null
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = call i32 @yaffsfs_SetError(i32 -2)
br label %41
39: ; preds = %33
%40 = call i32 @yaffsfs_DoUtime(%struct.yaffs_obj* %20, %struct.yaffs_utimbuf* %2)
br label %41
41: ; preds = %31, %39, %37, %26
%42 = phi i32 [ -1, %26 ], [ -1, %31 ], [ %40, %39 ], [ -1, %37 ]
%43 = call i32 (...) @yaffsfs_Unlock()
br label %44
44: ; preds = %41, %16, %11
%45 = phi i32 [ -1, %16 ], [ %42, %41 ], [ -1, %11 ]
ret i32 %45
}