#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 timeval {
  int tv_sec;
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
scalar_t__ ENOSYS;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int lutimes(char *, struct timeval *);
int /*<<< orphan*/ mktemp(char *);
int symlink(char *, char *);
int /*<<< orphan*/ unlink(char *);
int main() {
  int status;
  struct timeval times[2] = {{.tv_sec = 52353, .tv_usec = 0},
                             {.tv_sec = 52353, .tv_usec = 0}};
  char tmp[] = "proot-XXXXXX";
  mktemp(tmp);
  if (tmp[0] == '\0')
    exit(EXIT_FAILURE);
  (void)unlink(tmp);
  status = symlink("/etc/fstab", tmp);
  if (status < 0)
    exit(EXIT_FAILURE);
  status = lutimes(tmp, times);
  exit(status < 0 && errno != ENOSYS ? EXIT_FAILURE : EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x2d(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x25(%rbp)
mov    0xe8d(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2d(%rbp),%rdi
call   1070 <mktemp@plt>
movsbl -0x2d(%rbp),%eax
cmp    $0x0,%eax
jne    11b6 <main+0x66>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    -0x2d(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x2d(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <symlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11ea <main+0x9a>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    -0x2d(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <lutimes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    122f <main+0xdf>
mov    0x2dcd(%rip),%rax
mov    (%rax),%rax
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%rax
je     122f <main+0xdf>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    123b <main+0xeb>
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x5858585858582d,%rax
mov    %rax,0x5(%rsp)
movabs $0x58582d746f6f7270,%rax
2d 58 58
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1070 <mktemp@plt>
cmpb   $0x0,(%rsp)
je     11df <main+0x8f>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <symlink@plt>
test   %eax,%eax
js     11df <main+0x8f>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1050 <lutimes@plt>
test   %eax,%eax
jns    11d1 <main+0x81>
mov    0x2e16(%rip),%rax
mov    (%rax),%rax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%rax
jne    11df <main+0x8f>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@__const.main.times = [2 x %struct.timeval] [%struct.timeval { i32 52353, i32 0 }, %struct.timeval { i32 52353, i32 0 }]
@__const.main.tmp = [13 x i8] c"proot-XXXXXX\00"
@EXIT_FAILURE = global i32 0
@.str = [11 x i8] c"/etc/fstab\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x %struct.timeval]
%4 = alloca [13 x i8]
store i32 0, i32* %1
%5 = bitcast [2 x %struct.timeval]* %3 to i8*
%6 = bitcast [13 x i8]* %4 to i8*
%7 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%8 = call i32 @mktemp(i8* %7)
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %0
%17 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%18 = call i32 @unlink(i8* %17)
%19 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%20 = call i32 @symlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %16
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%29 = call i32 @lutimes(i8* %27, %struct.timeval* %28)
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i64, i64* @errno
%34 = load i64, i64* @ENOSYS
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* @EXIT_FAILURE
br label %40
38: ; preds = %32, %26
%39 = load i32, i32* @EXIT_SUCCESS
br label %40
40: ; preds = %38, %36
%41 = phi i32 [ %37, %36 ], [ %39, %38 ]
%42 = call i32 @exit(i32 %41)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@__const.main.times = [2 x %struct.timeval] [%struct.timeval { i32 52353, i32 0 }, %struct.timeval { i32 52353, i32 0 }]
@__const.main.tmp = [13 x i8] c"proot-XXXXXX\00"
@EXIT_FAILURE = global i32 0
@.str = [11 x i8] c"/etc/fstab\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [2 x %struct.timeval]
%2 = alloca [13 x i8]
%3 = bitcast [2 x %struct.timeval]* %1 to i8*
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = call i32 @mktemp(i8* %4)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = call i32 @unlink(i8* %4)
%13 = call i32 @symlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
%19 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %1, i64 0, i64 0
%20 = call i32 @lutimes(i8* %4, %struct.timeval* %19)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i64, i64* @errno
%24 = load i64, i64* @ENOSYS
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22, %18
br label %27
27: ; preds = %22, %26
%28 = phi i32* [ @EXIT_SUCCESS, %26 ], [ @EXIT_FAILURE, %22 ]
%29 = load i32, i32* %28
%30 = call i32 @exit(i32 %29)
unreachable
}