#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 timespec {
  int dummy;
};

/* Variables and functions */
int errno;
int utimensat(int, char const *, struct timespec *, int);
int __sulong_posix_utimensat(int dfd, const char *filename,
                             struct timespec *utimes, int flags) {
  {
    int native_errno = errno;
    int result = utimensat(dfd, filename, utimes, flags);
    if (result == (int)-1) {
      result = (int)(long)-errno;
    }
    errno = native_errno;
    return result;
  };
}


x86 assembly (clang, -O0):
<__sulong_posix_utimensat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <utimensat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1162 <__sulong_posix_utimensat+0x52>
xor    %eax,%eax
mov    0x2e85(%rip),%rcx
sub    (%rcx),%eax
cltq
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%ecx
mov    0x2e74(%rip),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sulong_posix_utimensat>:
push   %rbp
push   %rbx
push   %rax
mov    0x2ec6(%rip),%rbx
mov    (%rbx),%ebp
call   1030 <utimensat@plt>
xor    %ecx,%ecx
sub    (%rbx),%ecx
cmp    $0xffffffff,%eax
cmove  %ecx,%eax
mov    %ebp,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.timespec = type { i32 }
@errno = global i32 0
define i32 @__sulong_posix_utimensat(i32 %0, i8* %1, %struct.timespec* %2, i32 %3) {
%5 = load i32, i32* @errno
%6 = tail call i32 @utimensat(i32 %0, i8* %1, %struct.timespec* %2, i32 %3)
%7 = icmp eq i32 %6, -1
%8 = load i32, i32* @errno
%9 = sub nsw i32 0, %8
%10 = select i1 %7, i32 %9, i32 %6
store i32 %5, i32* @errno
ret i32 %10
}