#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 *malloc(int);
int /*<<< orphan*/ memcpy(char *, unsigned char *, int);
char *make_name(unsigned char *rawname) {
  int l;
  char *name;
  for (l = 0; rawname[l] != 0xa0 && l < 16; ++l)
    ;
  if ((name = malloc(l + 1)) == NULL) {
    return (NULL);
  }
  memcpy(name, rawname, l);
  name[l] = 0;
  for (l = 0; rawname[l]; ++l) {
  }
  return (name);
}


x86 assembly (clang, -O0):
<make_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa0,%ecx
mov    %al,-0x21(%rbp)
je     115a <make_name+0x3a>
cmpl   $0x10,-0x14(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    116a <make_name+0x4a>
jmp    117d <make_name+0x5d>
jmp    116f <make_name+0x4f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <make_name+0x13>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a3 <make_name+0x83>
movq   $0x0,-0x8(%rbp)
jmp    11f3 <make_name+0xd3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11eb <make_name+0xcb>
jmp    11dd <make_name+0xbd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c6 <make_name+0xa6>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rbx
cmpb   $0xa0,(%r14,%rax,1)
je     1144 <make_name+0x24>
cmp    $0x10,%rax
mov    %rbx,%rax
jb     1130 <make_name+0x10>
mov    %ebx,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     1168 <make_name+0x48>
lea    -0x1(%rbx),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <memcpy@plt>
movb   $0x0,-0x1(%r15,%rbx,1)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @make_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %20, %1
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp ne i32 %12, 160
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 16
br label %17
17: ; preds = %14, %6
%18 = phi i1 [ false, %6 ], [ %16, %14 ]
br i1 %18, label %19, label %23
19: ; preds = %17
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %5
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23
store i8* null, i8** %2
br label %51
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
%34 = load i8*, i8** %5
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
store i32 0, i32* %4
br label %38
38: ; preds = %46, %29
%39 = load i8*, i8** %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = icmp ne i8 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %38
49: ; preds = %38
%50 = load i8*, i8** %5
store i8* %50, i8** %2
br label %51
51: ; preds = %49, %28
%52 = load i8*, i8** %2
ret i8* %52
}

LLVM IR (-O2):
define i8* @make_name(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %9, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, -96
%7 = icmp ult i64 %3, 16
%8 = select i1 %6, i1 %7, i1 false
%9 = add nuw nsw i64 %3, 1
br i1 %8, label %2, label %10
10: ; preds = %2
%11 = trunc i64 %3 to i32
%12 = add nuw nsw i32 %11, 1
%13 = tail call i8* @malloc(i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = tail call i32 @memcpy(i8* %13, i8* %0, i32 %11)
%17 = getelementptr inbounds i8, i8* %13, i64 %3
store i8 0, i8* %17
br label %18
18: ; preds = %15, %10
ret i8* %13
}