#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 */
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ sprintf(char *, char *, char *, long);
void make_filename(long filenum, char *prefix, char *filename) {
  char *psrc, *pdst;
  sprintf(filename, "%s%d.umf", prefix, filenum);
  pdst = filename;
  for (psrc = filename; *psrc; psrc++) {
    if (!isspace(*psrc))
      *pdst++ = *psrc;
  }
  *pdst = '\0';
}


x86 assembly (clang, -O0):
<make_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xeb9(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ab <make_filename+0x8b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    1195 <make_filename+0x75>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    119a <make_filename+0x7a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <make_filename+0x3c>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rcx
lea    0xecc(%rip),%rsi
mov    %r14,%rdi
call   1040 <sprintf@plt>
mov    (%r14),%al
test   %al,%al
je     1174 <make_filename+0x54>
lea    0x1(%r14),%rbx
jmp    115b <make_filename+0x3b>
nopl   0x0(%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1174 <make_filename+0x54>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1150 <make_filename+0x30>
movzbl -0x1(%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
jmp    1150 <make_filename+0x30>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s%d.umf\00"
define void @make_filename(i64 %0, i8* %1, i8* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = load i64, i64* %4
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10, i64 %11)
%13 = load i8*, i8** %6
store i8* %13, i8** %8
%14 = load i8*, i8** %6
store i8* %14, i8** %7
br label %15
15: ; preds = %30, %3
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = call i32 @isspace(i8 signext %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %8
store i8 %26, i8* %27
br label %29
29: ; preds = %24, %19
br label %30
30: ; preds = %29
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %7
br label %15
33: ; preds = %15
%34 = load i8*, i8** %8
store i8 0, i8* %34
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s%d.umf\00"
define void @make_filename(i64 %0, i8* %1, i8* nocapture %2) {
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1, i64 %0)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %3, %16
%8 = phi i8 [ %19, %16 ], [ %5, %3 ]
%9 = phi i8* [ %17, %16 ], [ %2, %3 ]
%10 = phi i8* [ %18, %16 ], [ %2, %3 ]
%11 = tail call i32 @isspace(i8 signext %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8, i8* %10
%15 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %14, i8* %9
br label %16
16: ; preds = %7, %13
%17 = phi i8* [ %9, %7 ], [ %15, %13 ]
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %16, %3
%22 = phi i8* [ %2, %3 ], [ %17, %16 ]
store i8 0, i8* %22
ret void
}