void expand(str) char *str;
{
  char *a;
  static char b[128];
  char *p = str;
  int len = (2048) - 1;
  a = malloc((unsigned)(strlen(str) + 1));
  if (!a)
    fatal("No memory for expand");
  strcpy(a, str);
  doexp(&p, a, &len, b);
  free(a);
}


x86 assembly (clang, -O0):
<expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x7ff,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%rax
mov    %eax,%eax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <expand+0x4e>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1080 <fatal@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rdx
lea    0x2e92(%rip),%rcx
mov    $0x0,%al
call   1070 <doexp@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    %rdi,0x10(%rsp)
movl   $0x7ff,0xc(%rsp)
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    119a <expand+0x3a>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1080 <fatal@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0x2eb4(%rip),%rcx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <doexp@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@expand.b = internal global [128 x i8] zeroinitializer
@.str = [21 x i8] c"No memory for expand\00"
define void @expand(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %4
store i32 2047, i32* %5
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = zext i32 %10 to i64
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %1
%18 = load i8*, i8** %3
%19 = load i8*, i8** %2
%20 = call i8* @strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 (i8**, i8*, i32*, i8*, ...) bitcast (i32 (...)* @doexp to i32 (i8**, i8*, i32*, i8*, ...)*)(i8** %4, i8* %21, i32* %5, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @expand.b, i64 0, i64 0))
%23 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@expand.b = internal global [128 x i8] zeroinitializer
@.str = [21 x i8] c"No memory for expand\00"
define void @expand(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = bitcast i8** %2 to i8*
store i8* %0, i8** %2
%5 = bitcast i32* %3 to i8*
store i32 2047, i32* %3
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add i64 %6, 1
%8 = and i64 %7, 4294967295
%9 = tail call i8* @malloc(i64 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = tail call i8* @strcpy(i8* dereferenceable(1) %9, i8* dereferenceable(1) %0)
%15 = call i32 (i8**, i8*, i32*, i8*, ...) bitcast (i32 (...)* @doexp to i32 (i8**, i8*, i32*, i8*, ...)*)(i8** %2, i8* %9, i32* %3, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @expand.b, i64 0, i64 0))
ret void
}