#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 tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct stat {
  int /*<<< orphan*/ st_ctime;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int errno;
scalar_t__ fstat(int, struct stat *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
void print_dtime(int fd) {
  struct tm *ptm = 0;
  struct stat statbuf = {0};
  if (fstat(fd, &statbuf) < 0)
    printf("stat error for '%d', errno = %d\n", fd, errno);
  else {
    char stra[64], strm[64], strc[64];
    ptm = localtime(&statbuf.st_atime);
    sprintf(stra, "%d-%d-%d %d:%d:%d", ptm->tm_year + 1900, ptm->tm_mon + 1,
            ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
    ptm = localtime(&statbuf.st_mtime);
    sprintf(strm, "%d-%d-%d %d:%d:%d", ptm->tm_year + 1900, ptm->tm_mon + 1,
            ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
    ptm = localtime(&statbuf.st_ctime);
    sprintf(strc, "%d-%d-%d %d:%d:%d", ptm->tm_year + 1900, ptm->tm_mon + 1,
            ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
    printf("atime: %s, mtime: %s, ctime: %s\n", stra, strm, strc);
  }
}


x86 assembly (clang, -O0):
<print_dtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1070 <fstat@plt>
cmp    $0x0,%rax
jge    11ab <print_dtime+0x5b>
mov    -0x4(%rbp),%esi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e7 <print_dtime+0x197>
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe25(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
lea    -0x20(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xdc4(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xd67(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
lea    -0x60(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_dtime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
call   1060 <fstat@plt>
test   %rax,%rax
js     1249 <print_dtime+0x109>
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
mov    $0x76c,%ebp
mov    (%rax),%edx
add    %ebp,%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0xe88(%rip),%r12
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    %r12,%rsi
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
add    %ebp,%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0x50(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
mov    %rsp,%rdi
call   1030 <localtime@plt>
add    (%rax),%ebp
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
lea    0xe0c(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d90(%rip),%rax
mov    (%rax),%edx
lea    0xda7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.stat = type { i32, i32, i32, i32 }
@.str = [33 x i8] c"stat error for '%d', errno = %d\0A\00"
@errno = global i32 0
@.str.1 = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
@.str.2 = [33 x i8] c"atime: %s, mtime: %s, ctime: %s\0A\00"
define void @print_dtime(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca %struct.stat
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
store i32 %0, i32* %2
store %struct.tm* null, %struct.tm** %3
%8 = bitcast %struct.stat* %4 to i8*
%9 = load i32, i32* %2
%10 = call i64 @fstat(i32 %9, %struct.stat* %4)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* %2
%14 = load i32, i32* @errno
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
br label %93
16: ; preds = %1
%17 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 2
%18 = call %struct.tm* @localtime(i32* %17)
store %struct.tm* %18, %struct.tm** %3
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1900
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
%28 = load %struct.tm*, %struct.tm** %3
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 2
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %3
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 3
%33 = load i32, i32* %32
%34 = load %struct.tm*, %struct.tm** %3
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 4
%36 = load i32, i32* %35
%37 = load %struct.tm*, %struct.tm** %3
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 5
%39 = load i32, i32* %38
%40 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %27, i32 %30, i32 %33, i32 %36, i32 %39)
%41 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%42 = call %struct.tm* @localtime(i32* %41)
store %struct.tm* %42, %struct.tm** %3
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%44 = load %struct.tm*, %struct.tm** %3
%45 = getelementptr inbounds %struct.tm, %struct.tm* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1900
%48 = load %struct.tm*, %struct.tm** %3
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
%52 = load %struct.tm*, %struct.tm** %3
%53 = getelementptr inbounds %struct.tm, %struct.tm* %52, i32 0, i32 2
%54 = load i32, i32* %53
%55 = load %struct.tm*, %struct.tm** %3
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 3
%57 = load i32, i32* %56
%58 = load %struct.tm*, %struct.tm** %3
%59 = getelementptr inbounds %struct.tm, %struct.tm* %58, i32 0, i32 4
%60 = load i32, i32* %59
%61 = load %struct.tm*, %struct.tm** %3
%62 = getelementptr inbounds %struct.tm, %struct.tm* %61, i32 0, i32 5
%63 = load i32, i32* %62
%64 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %51, i32 %54, i32 %57, i32 %60, i32 %63)
%65 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%66 = call %struct.tm* @localtime(i32* %65)
store %struct.tm* %66, %struct.tm** %3
%67 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%68 = load %struct.tm*, %struct.tm** %3
%69 = getelementptr inbounds %struct.tm, %struct.tm* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = add nsw i32 %70, 1900
%72 = load %struct.tm*, %struct.tm** %3
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = add nsw i32 %74, 1
%76 = load %struct.tm*, %struct.tm** %3
%77 = getelementptr inbounds %struct.tm, %struct.tm* %76, i32 0, i32 2
%78 = load i32, i32* %77
%79 = load %struct.tm*, %struct.tm** %3
%80 = getelementptr inbounds %struct.tm, %struct.tm* %79, i32 0, i32 3
%81 = load i32, i32* %80
%82 = load %struct.tm*, %struct.tm** %3
%83 = getelementptr inbounds %struct.tm, %struct.tm* %82, i32 0, i32 4
%84 = load i32, i32* %83
%85 = load %struct.tm*, %struct.tm** %3
%86 = getelementptr inbounds %struct.tm, %struct.tm* %85, i32 0, i32 5
%87 = load i32, i32* %86
%88 = call i32 @sprintf(i8* %67, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %71, i32 %75, i32 %78, i32 %81, i32 %84, i32 %87)
%89 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%90 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%91 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %89, i8* %90, i8* %91)
br label %93
93: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [33 x i8] c"stat error for '%d', errno = %d\0A\00"
@errno = global i32 0
@.str.1 = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
@.str.2 = [33 x i8] c"atime: %s, mtime: %s, ctime: %s\0A\00"
define void @print_dtime(i32 %0) {
%2 = alloca %struct.stat
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = bitcast %struct.stat* %2 to i8*
%7 = call i64 @fstat(i32 %0, %struct.stat* %2)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %10)
br label %68
12: ; preds = %1
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%17 = call %struct.tm* @localtime(i32* %16)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 0
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1900
%21 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 1
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
%24 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 2
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 3
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 4
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 5
%31 = load i32, i32* %30
%32 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %23, i32 %25, i32 %27, i32 %29, i32 %31)
%33 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%34 = call %struct.tm* @localtime(i32* %33)
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 0
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1900
%38 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 1
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
%41 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 2
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 3
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 4
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.tm, %struct.tm* %34, i64 0, i32 5
%48 = load i32, i32* %47
%49 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %40, i32 %42, i32 %44, i32 %46, i32 %48)
%50 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%51 = call %struct.tm* @localtime(i32* %50)
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 0
%53 = load i32, i32* %52
%54 = add nsw i32 %53, 1900
%55 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 1
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
%58 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 3
%61 = load i32, i32* %60
%62 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 4
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.tm, %struct.tm* %51, i64 0, i32 5
%65 = load i32, i32* %64
%66 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %57, i32 %59, i32 %61, i32 %63, i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14, i8* %15)
br label %68
68: ; preds = %12, %9
ret void
}