#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*/ uintmax_t;
typedef scalar_t__ time_t;
struct timeval {
  scalar_t__ tv_sec;
  unsigned int tv_usec;
};
struct stat {
  scalar_t__ st_mtime;
  scalar_t__ st_size;
  scalar_t__ st_ino;
  scalar_t__ st_dev;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long,
                           unsigned int, unsigned int, unsigned long,
                           int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void printstat(FILE *out, struct stat *s) {
  struct timeval now;
  time_t sec;
  unsigned usec;
  gettimeofday(&now, NULL);
  sec = s->st_mtime;
  usec = 0;
  if (now.tv_sec <= s->st_mtime + 1) {
    sec = now.tv_sec;
    usec = now.tv_usec;
  }
  fprintf(out, "%lu.%06u d=%u,i=%lu %ju\n", (unsigned long)sec, usec,
          (unsigned)s->st_dev, (unsigned long)s->st_ino,
          (uintmax_t)(s->st_size));
}


x86 assembly (clang, -O0):
<printstat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jg     1175 <printstat+0x55>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
lea    0xe5e(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstat>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %r15d,%r15d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rbx),%rdx
mov    0x10(%rsp),%rax
lea    0x1(%rdx),%rcx
cmp    %rcx,%rax
jg     1157 <printstat+0x37>
mov    0x18(%rsp),%r15d
mov    %rax,%rdx
mov    0x18(%rbx),%r8d
mov    0x10(%rbx),%r9
mov    0x8(%rbx),%eax
mov    %eax,(%rsp)
lea    0xe94(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%ecx
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64, i64, i64 }
%struct.timeval = type { i64, i32 }
@.str = [25 x i8] c"%lu.%06u d=%u,i=%lu %ju\0A\00"
define void @printstat(i32* %0, %struct.stat* %1) {
%3 = alloca i32*
%4 = alloca %struct.stat*
%5 = alloca %struct.timeval
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %3
store %struct.stat* %1, %struct.stat** %4
%8 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%9 = load %struct.stat*, %struct.stat** %4
%10 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%11 = load i64, i64* %10
store i64 %11, i64* %6
store i32 0, i32* %7
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load %struct.stat*, %struct.stat** %4
%15 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = add nsw i64 %16, 1
%18 = icmp sle i64 %13, %17
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%21 = load i64, i64* %20
store i64 %21, i64* %6
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %7
br label %24
24: ; preds = %19, %2
%25 = load i32*, i32** %3
%26 = load i64, i64* %6
%27 = load i32, i32* %7
%28 = load %struct.stat*, %struct.stat** %4
%29 = getelementptr inbounds %struct.stat, %struct.stat* %28, i32 0, i32 3
%30 = load i64, i64* %29
%31 = trunc i64 %30 to i32
%32 = load %struct.stat*, %struct.stat** %4
%33 = getelementptr inbounds %struct.stat, %struct.stat* %32, i32 0, i32 2
%34 = load i64, i64* %33
%35 = load %struct.stat*, %struct.stat** %4
%36 = getelementptr inbounds %struct.stat, %struct.stat* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = trunc i64 %37 to i32
%39 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %26, i32 %27, i32 %31, i64 %34, i32 %38)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i64, i64, i64 }
%struct.timeval = type { i64, i32 }
@.str = [25 x i8] c"%lu.%06u d=%u,i=%lu %ju\0A\00"
define void @printstat(i32* nocapture %0, %struct.stat* nocapture %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%6 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%9 = load i64, i64* %8
%10 = add nsw i64 %7, 1
%11 = icmp sgt i64 %9, %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%13 = load i32, i32* %12
%14 = select i1 %11, i64 %7, i64 %9
%15 = select i1 %11, i32 0, i32 %13
%16 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %14, i32 %15, i32 %18, i64 %20, i32 %23)
ret void
}