#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 */

/* Variables and functions */
int O_CREAT;
int O_NONBLOCK;
int O_WRONLY;
int /*<<< orphan*/ close(int);
scalar_t__ futimens(int, int /*<<< orphan*/);
int open(char const *, int, int);
int ztouch(const char *pathname) {
  int fd = open(pathname, O_WRONLY | O_CREAT | O_NONBLOCK, 0666);
  if (fd < 0) {
    return -1;
  }
  if (futimens(fd, 0) < 0) {
    close(fd);
    return -1;
  }
  close(fd);
  return 1;
}


x86 assembly (clang, -O0):
<ztouch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
mov    0x2ea8(%rip),%rax
or     (%rax),%esi
mov    0x2e87(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    117e <ztouch+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <ztouch+0x85>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <futimens@plt>
cmp    $0x0,%rax
jge    11a6 <ztouch+0x76>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <ztouch+0x85>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ztouch>:
push   %r14
push   %rbx
push   %rax
mov    0x2e8d(%rip),%rax
mov    0x2eb6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e93(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1040 <open@plt>
test   %eax,%eax
js     1182 <ztouch+0x52>
mov    %eax,%ebx
mov    %eax,%edi
xor    %esi,%esi
call   1050 <futimens@plt>
xor    %r14d,%r14d
test   %rax,%rax
setns  %r14b
mov    %ebx,%edi
call   1030 <close@plt>
lea    (%r14,%r14,1),%eax
add    $0xffffffff,%eax
jmp    1187 <ztouch+0x57>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_NONBLOCK = global i32 0
define i32 @ztouch(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i32, i32* @O_WRONLY
%7 = load i32, i32* @O_CREAT
%8 = or i32 %6, %7
%9 = load i32, i32* @O_NONBLOCK
%10 = or i32 %8, %9
%11 = call i32 @open(i8* %5, i32 %10, i32 438)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %25
15: ; preds = %1
%16 = load i32, i32* %4
%17 = call i64 @futimens(i32 %16, i32 0)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %4
%21 = call i32 @close(i32 %20)
store i32 -1, i32* %2
br label %25
22: ; preds = %15
%23 = load i32, i32* %4
%24 = call i32 @close(i32 %23)
store i32 1, i32* %2
br label %25
25: ; preds = %22, %19, %14
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_NONBLOCK = global i32 0
define i32 @ztouch(i8* nocapture %0) {
%2 = load i32, i32* @O_WRONLY
%3 = load i32, i32* @O_CREAT
%4 = or i32 %3, %2
%5 = load i32, i32* @O_NONBLOCK
%6 = or i32 %4, %5
%7 = tail call i32 @open(i8* %0, i32 %6, i32 438)
%8 = icmp slt i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = tail call i64 @futimens(i32 %7, i32 0)
%11 = icmp slt i64 %10, 0
%12 = tail call i32 @close(i32 %7)
%13 = select i1 %11, i32 -1, i32 1
br label %14
14: ; preds = %9, %1
%15 = phi i32 [ -1, %1 ], [ %13, %9 ]
ret i32 %15
}