#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 timespec {
  int tv_sec;
  int tv_nsec;
};
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ pathname;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, unsigned long long, unsigned long long,
                          char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main() {
  int i;
  for (i = 0; i < 200000; i++) {
    char pathname[1024];
    struct stat buf;
    struct timespec tp1, tp2;
    snprintf(pathname, sizeof(pathname), "/etc/hosts/_foo_%d_", i);
    clock_gettime(CLOCK_MONOTONIC, &tp1);
    lstat(pathname, &buf);
    clock_gettime(CLOCK_MONOTONIC, &tp2);
    long long unsigned int ts1 = tp1.tv_sec * 1000 * 1000 * 1000 + tp1.tv_nsec;
    long long unsigned int ts2 = tp2.tv_sec * 1000 * 1000 * 1000 + tp2.tv_nsec;
    printf("%llu %llu %s\n", ts1, ts2, pathname);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x30d40,-0x8(%rbp)
jge    1237 <main+0xf7>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x400,%esi
lea    0xe84(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x410(%rbp),%rdi
lea    -0x418(%rbp),%rsi
call   1060 <lstat@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    -0x428(%rbp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x3e8,-0x420(%rbp),%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
add    -0x41c(%rbp),%eax
cltq
mov    %rax,-0x430(%rbp)
imul   $0x3e8,-0x428(%rbp),%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
add    -0x424(%rbp),%eax
cltq
mov    %rax,-0x438(%rbp)
mov    -0x430(%rbp),%rsi
mov    -0x438(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    0xdf0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
xor    %ebx,%ebx
lea    0x20(%rsp),%r15
mov    0x2e89(%rip),%r12
lea    0x18(%rsp),%r13
lea    0x8(%rsp),%rbp
lea    0xea4(%rip),%r14
mov    %r15,%rdi
mov    $0x400,%esi
lea    0xe81(%rip),%rdx
mov    %ebx,%ecx
call   1050 <snprintf@plt>
mov    (%r12),%edi
lea    0x10(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <lstat@plt>
mov    (%r12),%edi
mov    %rbp,%rsi
call   1030 <clock_gettime@plt>
imul   $0x3b9aca00,0x10(%rsp),%eax
3b
movslq 0x14(%rsp),%rcx
movslq %eax,%rsi
imul   $0x3b9aca00,0x8(%rsp),%eax
3b
add    %rcx,%rsi
movslq 0xc(%rsp),%rcx
movslq %eax,%rdx
add    %rcx,%rdx
mov    %r14,%rdi
mov    %r15,%rcx
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x30d40,%ebx
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.timespec = type { i32, i32 }
@.str = [20 x i8] c"/etc/hosts/_foo_%d_\00"
@CLOCK_MONOTONIC = global i32 0
@.str.1 = [14 x i8] c"%llu %llu %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca %struct.stat
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
br label %9
9: ; preds = %44, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 200000
br i1 %11, label %12, label %47
12: ; preds = %9
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %2
%15 = call i32 @snprintf(i8* %13, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @CLOCK_MONOTONIC
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %5)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 @lstat(i8* %18, %struct.stat* %4)
%20 = load i32, i32* @CLOCK_MONOTONIC
%21 = call i32 @clock_gettime(i32 %20, %struct.timespec* %6)
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 1000
%25 = mul nsw i32 %24, 1000
%26 = mul nsw i32 %25, 1000
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%28 = load i32, i32* %27
%29 = add nsw i32 %26, %28
%30 = sext i32 %29 to i64
store i64 %30, i64* %7
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%32 = load i32, i32* %31
%33 = mul nsw i32 %32, 1000
%34 = mul nsw i32 %33, 1000
%35 = mul nsw i32 %34, 1000
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%37 = load i32, i32* %36
%38 = add nsw i32 %35, %37
%39 = sext i32 %38 to i64
store i64 %39, i64* %8
%40 = load i64, i64* %7
%41 = load i64, i64* %8
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %40, i64 %41, i8* %42)
br label %44
44: ; preds = %12
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %9
47: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.timespec = type { i32, i32 }
@.str = [20 x i8] c"/etc/hosts/_foo_%d_\00"
@CLOCK_MONOTONIC = global i32 0
@.str.1 = [14 x i8] c"%llu %llu %s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca %struct.stat
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = bitcast %struct.stat* %2 to i8*
%7 = bitcast %struct.timespec* %3 to i8*
%8 = bitcast %struct.timespec* %4 to i8*
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
br label %13
13: ; preds = %0, %13
%14 = phi i32 [ 0, %0 ], [ %32, %13 ]
%15 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @CLOCK_MONOTONIC
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %3)
%18 = call i32 @lstat(i8* %5, %struct.stat* %2)
%19 = load i32, i32* @CLOCK_MONOTONIC
%20 = call i32 @clock_gettime(i32 %19, %struct.timespec* %4)
%21 = load i32, i32* %9
%22 = mul i32 %21, 1000000000
%23 = load i32, i32* %10
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = load i32, i32* %11
%27 = mul i32 %26, 1000000000
%28 = load i32, i32* %12
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %25, i64 %30, i8* %5)
%32 = add nuw nsw i32 %14, 1
%33 = icmp eq i32 %32, 200000
br i1 %33, label %34, label %13
34: ; preds = %13
ret i32 0
}