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

/* Variables and functions */
int ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ logWarning(char *, int, char const *, scalar_t__, char *);
char *strerror(scalar_t__);
scalar_t__ utimes(char const *, struct timeval *);
int set_file_utimes(const char *filename, const time_t new_time) {
  struct timeval tvs[2];
  tvs[0].tv_sec = new_time;
  tvs[0].tv_usec = 0;
  tvs[1].tv_sec = new_time;
  tvs[1].tv_usec = 0;
  if (utimes(filename, tvs) != 0) {
    logWarning("file: "
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/"
               "master/fastdfs-5.01/common/shared_func.c"
               ", line: %d, "
               "call utimes file: %s fail"
               ", errno: %d, error info: %s",
               2108, filename, errno,
               (strerror(errno) != NULL ? strerror(errno) : "Unkown error"));
    return errno != 0 ? errno : ENOENT;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_file_utimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <utimes@plt>
cmp    $0x0,%rax
je     1224 <set_file_utimes+0xf4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2e51(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
cmp    $0x0,%rax
je     11b9 <set_file_utimes+0x89>
mov    0x2e38(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    %rax,-0x58(%rbp)
jmp    11c9 <set_file_utimes+0x99>
lea    0xf25(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    11c9 <set_file_utimes+0x99>
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%r8
lea    0xe24(%rip),%rdi
mov    $0x83c,%esi
call   1040 <logWarning@plt>
mov    0x2df3(%rip),%rax
cmpq   $0x0,(%rax)
je     120a <set_file_utimes+0xda>
mov    0x2de2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    1218 <set_file_utimes+0xe8>
mov    0x2dbf(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    122b <set_file_utimes+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_file_utimes>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    %esi,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %esi,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rsi
call   1030 <utimes@plt>
test   %rax,%rax
je     1186 <set_file_utimes+0x56>
mov    0x2e77(%rip),%r15
mov    (%r15),%r14
mov    %r14,%rdi
call   1050 <strerror@plt>
test   %rax,%rax
je     118a <set_file_utimes+0x5a>
mov    (%r15),%rdi
call   1050 <strerror@plt>
mov    %rax,%r8
jmp    1191 <set_file_utimes+0x61>
xor    %eax,%eax
jmp    11b9 <set_file_utimes+0x89>
lea    0xf54(%rip),%r8
lea    0xe68(%rip),%rdi
mov    $0x83c,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <logWarning@plt>
mov    (%r15),%rax
test   %rax,%rax
jne    11b9 <set_file_utimes+0x89>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
@.str = [229 x i8] c"file: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/master/fastdfs-5.01/common/shared_func.c, line: %d, call utimes file: %s fail, errno: %d, error info: %s\00"
@errno = global i64 0
@.str.1 = [13 x i8] c"Unkown error\00"
@ENOENT = global i32 0
define i32 @set_file_utimes(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [2 x %struct.timeval]
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
store i32 %7, i32* %9
%10 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
store i64 0, i64* %11
%12 = load i32, i32* %5
%13 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i32 %12, i32* %14
%15 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
store i64 0, i64* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%19 = call i64 @utimes(i8* %17, %struct.timeval* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %44
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = load i64, i64* @errno
%24 = load i64, i64* @errno
%25 = call i8* @strerror(i64 %24)
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i64, i64* @errno
%29 = call i8* @strerror(i64 %28)
br label %31
30: ; preds = %21
br label %31
31: ; preds = %30, %27
%32 = phi i8* [ %29, %27 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %30 ]
%33 = call i32 @logWarning(i8* getelementptr inbounds ([229 x i8], [229 x i8]* @.str, i64 0, i64 0), i32 2108, i8* %22, i64 %23, i8* %32)
%34 = load i64, i64* @errno
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i64, i64* @errno
br label %41
38: ; preds = %31
%39 = load i32, i32* @ENOENT
%40 = sext i32 %39 to i64
br label %41
41: ; preds = %38, %36
%42 = phi i64 [ %37, %36 ], [ %40, %38 ]
%43 = trunc i64 %42 to i32
store i32 %43, i32* %3
br label %45
44: ; preds = %2
store i32 0, i32* %3
br label %45
45: ; preds = %44, %41
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
@.str = [229 x i8] c"file: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/master/fastdfs-5.01/common/shared_func.c, line: %d, call utimes file: %s fail, errno: %d, error info: %s\00"
@errno = global i64 0
@.str.1 = [13 x i8] c"Unkown error\00"
@ENOENT = global i32 0
define i32 @set_file_utimes(i8* %0, i32 %1) {
%3 = alloca [2 x %struct.timeval]
%4 = bitcast [2 x %struct.timeval]* %3 to i8*
%5 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 1
store i32 %1, i32* %6
%7 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
store i64 0, i64* %7
%8 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 1
store i32 %1, i32* %8
%9 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 0
store i64 0, i64* %9
%10 = call i64 @utimes(i8* %0, %struct.timeval* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %28, label %12
12: ; preds = %2
%13 = load i64, i64* @errno
%14 = tail call i8* @strerror(i64 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i64, i64* @errno
%18 = tail call i8* @strerror(i64 %17)
br label %19
19: ; preds = %12, %16
%20 = phi i8* [ %18, %16 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %12 ]
%21 = tail call i32 @logWarning(i8* getelementptr inbounds ([229 x i8], [229 x i8]* @.str, i64 0, i64 0), i32 2108, i8* %0, i64 %13, i8* %20)
%22 = load i64, i64* @errno
%23 = icmp eq i64 %22, 0
%24 = load i32, i32* @ENOENT
%25 = zext i32 %24 to i64
%26 = select i1 %23, i64 %25, i64 %22
%27 = trunc i64 %26 to i32
br label %28
28: ; preds = %2, %19
%29 = phi i32 [ %27, %19 ], [ 0, %2 ]
ret i32 %29
}