char *Strsafe(y)
char *y;
{
  char *z;
  if (y == 0)
    return 0;
  z = Strsafe_find(y);
  if (z == 0 && (z = malloc(((int)strlen(y)) + 1)) != 0) {
    strcpy(z, y);
    Strsafe_insert(z);
  }
  if ((z) == 0) {
    extern void memory_error();
    memory_error();
  };
  return z;
}


x86 assembly (clang, -O0):
<Strsafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1184 <Strsafe+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11f4 <Strsafe+0x94>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <Strsafe_find@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11da <Strsafe+0x7a>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11da <Strsafe+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1070 <Strsafe_insert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11ec <Strsafe+0x8c>
mov    $0x0,%al
call   1080 <memory_error@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Strsafe>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117c <Strsafe+0x1c>
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <Strsafe_find@plt>
test   %eax,%eax
je     1181 <Strsafe+0x21>
movslq %eax,%r14
jmp    11bd <Strsafe+0x5d>
xor    %r14d,%r14d
jmp    11bd <Strsafe+0x5d>
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     11b3 <Strsafe+0x53>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <Strsafe_insert@plt>
jmp    11bd <Strsafe+0x5d>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <memory_error@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @Strsafe(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %35
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @Strsafe_find to i32 (i8*, ...)*)(i8* %9)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %29
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
%18 = trunc i64 %17 to i32
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = call i8* @malloc(i64 %20)
store i8* %21, i8** %4
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %29
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = load i8*, i8** %3
%26 = call i8* @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %4
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @Strsafe_insert to i32 (i8*, ...)*)(i8* %27)
br label %29
29: ; preds = %23, %15, %8
%30 = load i8*, i8** %4
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %29
br label %33
33: ; preds = %32, %29
%34 = load i8*, i8** %4
store i8* %34, i8** %2
br label %35
35: ; preds = %33, %7
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
define i8* @Strsafe(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @Strsafe_find to i32 (i8*, ...)*)(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i64 @strlen(i8* %0)
%8 = shl i64 %7, 32
%9 = add i64 %8, 4294967296
%10 = ashr exact i64 %9, 32
%11 = tail call i8* @malloc(i64 %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %19, label %13
13: ; preds = %6
%14 = tail call i8* @strcpy(i8* %11, i8* %0)
%15 = tail call i32 (i8*, ...) bitcast (i32 (...)* @Strsafe_insert to i32 (i8*, ...)*)(i8* %11)
br label %20
16: ; preds = %3
%17 = sext i32 %4 to i64
%18 = inttoptr i64 %17 to i8*
br label %20
19: ; preds = %6
tail call void (...) @memory_error()
br label %20
20: ; preds = %16, %13, %19, %1
%21 = phi i8* [ null, %1 ], [ null, %19 ], [ %18, %16 ], [ %11, %13 ]
ret i8* %21
}