#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 */

/* Variables and functions */
char *getfilename(char *);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void truncfilefourcc(char *path) {
  char *i = getfilename(path);
  memmove(path, i, strlen(i) + 1);
  path[4] = 0;
  while (strlen(path) < 4)
    strcat(path, "_");
}


x86 assembly (clang, -O0):
<truncfilefourcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getfilename@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <memmove@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jge    11b3 <truncfilefourcc+0x73>
mov    -0x8(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcat@plt>
jmp    118c <truncfilefourcc+0x4c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncfilefourcc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getfilename@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <memmove@plt>
movb   $0x0,0x4(%rbx)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jg     1198 <truncfilefourcc+0x58>
lea    0xe83(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jl     1180 <truncfilefourcc+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
define void @truncfilefourcc(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @getfilename(i8* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = load i8*, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
%11 = call i32 @memmove(i8* %6, i8* %7, i32 %10)
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8 0, i8* %13
br label %14
14: ; preds = %18, %1
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %14
21: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
define void @truncfilefourcc(i8* %0) {
%2 = tail call i8* @getfilename(i8* %0)
%3 = tail call i32 @strlen(i8* %2)
%4 = add nsw i32 %3, 1
%5 = tail call i32 @memmove(i8* %0, i8* %2, i32 %4)
%6 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %6
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %13
9: ; preds = %1, %9
%10 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp slt i32 %11, 4
br i1 %12, label %9, label %13
13: ; preds = %9, %1
ret void
}