#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 dummy;
};
struct stat {
  int /*<<< orphan*/ st_mtim;
  int /*<<< orphan*/ st_atim;
};

/* Variables and functions */
int /*<<< orphan*/ TIMESPEC_TO_TIMEVAL(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ err(int, char *, char const *);
scalar_t__ stat(char const *, struct stat *);
void stime_file(const char *fname, struct timeval *tvp) {
  struct stat sb;
  if (stat(fname, &sb))
    err(1, "%s", fname);
  TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atim);
  TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtim);
}


x86 assembly (clang, -O0):
<stime_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
je     116c <stime_file+0x3c>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe99(%rip),%rsi
call   1040 <err@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
add    $0x4,%rsi
call   1050 <TIMESPEC_TO_TIMEVAL@plt>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
lea    -0x18(%rbp),%rsi
call   1050 <TIMESPEC_TO_TIMEVAL@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stime_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rsi
call   1030 <stat@plt>
test   %rax,%rax
je     115b <stime_file+0x2b>
lea    0xeb2(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rdx
call   1040 <err@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <TIMESPEC_TO_TIMEVAL@plt>
add    $0x4,%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <TIMESPEC_TO_TIMEVAL@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.stat = type { i32, i32 }
@.str = [3 x i8] c"%s\00"
define void @stime_file(i8* %0, %struct.timeval* %1) {
%3 = alloca i8*
%4 = alloca %struct.timeval*
%5 = alloca %struct.stat
store i8* %0, i8** %3
store %struct.timeval* %1, %struct.timeval** %4
%6 = load i8*, i8** %3
%7 = call i64 @stat(i8* %6, %struct.stat* %5)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %2
%13 = load %struct.timeval*, %struct.timeval** %4
%14 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%15 = call i32 @TIMESPEC_TO_TIMEVAL(%struct.timeval* %13, i32* %14)
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i64 1
%18 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%19 = call i32 @TIMESPEC_TO_TIMEVAL(%struct.timeval* %17, i32* %18)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.stat = type { i32, i32 }
@.str = [3 x i8] c"%s\00"
define void @stime_file(i8* %0, %struct.timeval* %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i64 @stat(i8* %0, %struct.stat* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %2
%10 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%11 = call i32 @TIMESPEC_TO_TIMEVAL(%struct.timeval* %1, i32* %10)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 1
%13 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%14 = call i32 @TIMESPEC_TO_TIMEVAL(%struct.timeval* %12, i32* %13)
ret void
}