int print_snapshot_name(const char *name) {
  int l = strlen(name);
  assert(l >= 4 && !strcmp(name + l - 4, ".tmp") && l <= 256);
  return printf("%.*s\n", l - 4, name);
}


x86 assembly (clang, -O0):
<print_snapshot_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x4,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     119f <print_snapshot_name+0x5f>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe83(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
jne    119f <print_snapshot_name+0x5f>
cmpl   $0x100,-0xc(%rbp)
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1060 <assert@plt>
mov    -0xc(%rbp),%esi
sub    $0x4,%esi
mov    -0x8(%rbp),%rdx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_snapshot_name>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
cmp    $0x4,%ebx
jl     117d <print_snapshot_name+0x3d>
movslq %ebx,%rax
lea    (%r14,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe98(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    117d <print_snapshot_name+0x3d>
xor    %ebp,%ebp
cmp    $0x101,%ebx
setb   %bpl
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <assert@plt>
lea    -0x4(%rbx),%esi
lea    0xe75(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".tmp\00"
@.str.1 = [6 x i8] c"%.*s\0A\00"
define i32 @print_snapshot_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = trunc i64 %5 to i32
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 4
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -4
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = load i32, i32* %3
%19 = icmp sle i32 %18, 256
br label %20
20: ; preds = %17, %9, %1
%21 = phi i1 [ false, %9 ], [ false, %1 ], [ %19, %17 ]
%22 = zext i1 %21 to i32
%23 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %22)
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 4
%26 = load i8*, i8** %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26)
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c".tmp\00"
@.str.1 = [6 x i8] c"%.*s\0A\00"
define i32 @print_snapshot_name(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 3
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = shl i64 %2, 32
%7 = ashr exact i64 %6, 32
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -4
%10 = tail call i32 @strcmp(i8* %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = icmp ult i32 %3, 257
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %12, %5, %1
%16 = phi i32 [ 0, %5 ], [ 0, %1 ], [ %14, %12 ]
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %16)
%18 = add nsw i32 %3, -4
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %0)
ret i32 %19
}