#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 /*<<< orphan*/ AT_FDCWD;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ close(int);
int futimesat(int /*<<< orphan*/, char const *, int /*<<< orphan*/ *);
int open(char const *, int, int);
int /*<<< orphan*/ unlink(char const *);
int main(void) {
  static const char *filename = "/tmp/futimes.tmp";
  int fd, ret;
  fd = open(filename, O_RDWR | O_CREAT, 0666);
  if (fd < 0)
    return 1;
  ret = futimesat(AT_FDCWD, filename, NULL);
  (void)unlink(filename);
  (void)ret;
  (void)close(fd);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eea(%rip),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    0x2e92(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    118b <main+0x4b>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <main+0x82>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    0x2ea5(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <futimesat@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e92(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    0x2ea6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xea3(%rip),%rdi
mov    $0x1b6,%edx
call   1050 <open@plt>
test   %eax,%eax
js     1196 <main+0x56>
mov    %eax,%ebx
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%r14
mov    %r14,%rsi
xor    %edx,%edx
call   1060 <futimesat@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@main.filename = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0)
@.str = [17 x i8] c"/tmp/futimes.tmp\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@AT_FDCWD = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i8*, i8** @main.filename
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_CREAT
%7 = or i32 %5, %6
%8 = call i32 @open(i8* %4, i32 %7, i32 438)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 1, i32* %1
br label %21
12: ; preds = %0
%13 = load i32, i32* @AT_FDCWD
%14 = load i8*, i8** @main.filename
%15 = call i32 @futimesat(i32 %13, i8* %14, i32* null)
store i32 %15, i32* %3
%16 = load i8*, i8** @main.filename
%17 = call i32 @unlink(i8* %16)
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 @close(i32 %19)
store i32 1, i32* %1
br label %21
21: ; preds = %12, %11
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [17 x i8] c"/tmp/futimes.tmp\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@AT_FDCWD = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = tail call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %3, i32 438)
%5 = icmp slt i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = load i32, i32* @AT_FDCWD
%8 = tail call i32 @futimesat(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* null)
%9 = tail call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @close(i32 %4)
br label %11
11: ; preds = %0, %6
ret i32 1
}