#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 stat {
  int /*<<< orphan*/ st_mtime;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
scalar_t__ stat(char const *, struct stat *);
char *vstrcat(char *, int /*<<< orphan*/ *);
extern char *tolmfile(const char *fn) {
  struct stat buf;
  if (stat(fn, &buf))
    return 0;
  char tolm[24];
  sprintf(tolm, "%ld", buf.st_mtime);
  return vstrcat(tolm, NULL);
}


x86 assembly (clang, -O0):
<tolmfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
je     1160 <tolmfile+0x30>
movq   $0x0,-0x8(%rbp)
jmp    1184 <tolmfile+0x54>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe92(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <vstrcat@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tolmfile>:
push   %rbx
sub    $0x30,%rsp
lea    0x8(%rsp),%rsi
call   1030 <stat@plt>
test   %rax,%rax
je     1148 <tolmfile+0x18>
xor    %eax,%eax
jmp    116a <tolmfile+0x3a>
mov    0x8(%rsp),%edx
lea    0xead(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <vstrcat@plt>
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [4 x i8] c"%ld\00"
define i8* @tolmfile(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca [24 x i8]
%4 = bitcast %struct.stat* %2 to i8*
%5 = call i64 @stat(i8* %0, %struct.stat* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i8* @vstrcat(i8* %8, i32* null)
br label %13
13: ; preds = %1, %7
%14 = phi i8* [ %12, %7 ], [ null, %1 ]
ret i8* %14
}