char *remember(s)
register char *s;
{
  register char *p;
  register n;
  static nleft = 0;
  static char *next;
  p = s;
  n = 0;
  do
    n++;
  while (*p++);
  if ((nleft -= n) < 0) {
    next = malloc(2048);
    if (next == 0)
      fatal("out of memory");
    nleft = (2048 / sizeof(char)) - n;
    {
      if (!(nleft >= 0))
        assert2("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/h31nr1ch/SOP/refs/heads/"
                "master/Assembly/as_src/comm7.c",
                78);
    };
  }
  p = next;
  while (*p++ = *s++)
    ;
  s = next;
  next = p;
  return (s);
}


x86 assembly (clang, -O0):
<remember>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,(%rax)
jne    114b <remember+0x1b>
mov    -0x14(%rbp),%ecx
mov    0x2ecb(%rip),%eax
sub    %ecx,%eax
mov    %eax,0x2ec3(%rip)
cmp    $0x0,%eax
jge    11ea <remember+0xba>
mov    $0x800,%edi
call   1030 <malloc@plt>
mov    %rax,0x2eb1(%rip)
cmpq   $0x0,0x2ea9(%rip)
jne    11b3 <remember+0x83>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <fatal@plt>
movslq -0x14(%rbp),%rcx
mov    $0x800,%eax
sub    %rcx,%rax
mov    %eax,0x2e7b(%rip)
cmpl   $0x0,0x2e74(%rip)
jge    11e5 <remember+0xb5>
lea    0xe35(%rip),%rdi
mov    $0x4e,%esi
mov    $0x0,%al
call   1040 <assert2@plt>
jmp    11ea <remember+0xba>
mov    0x2e57(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     1224 <remember+0xf4>
jmp    11f5 <remember+0xc5>
mov    0x2e1d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,0x2e0e(%rip)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remember>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%r14,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1140 <remember+0x10>
sub    %ebx,0x2eef(%rip)
jns    11a4 <remember+0x74>
lea    -0x1(%rbx),%r15
mov    $0x800,%edi
call   1030 <malloc@plt>
mov    %rax,0x2ee0(%rip)
test   %rax,%rax
jne    117b <remember+0x4b>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <fatal@plt>
mov    $0x800,%eax
sub    %ebx,%eax
mov    %eax,0x2eb8(%rip)
cmp    $0x800,%r15d
jb     11a4 <remember+0x74>
lea    0xe76(%rip),%rdi
mov    $0x4e,%esi
xor    %eax,%eax
call   1040 <assert2@plt>
mov    0x2e9d(%rip),%rax
xor    %ecx,%ecx
nopl   (%rax)
movzbl (%r14,%rcx,1),%edx
mov    %dl,(%rax,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    11b0 <remember+0x80>
add    %rax,%rcx
mov    %rcx,0x2e7e(%rip)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@remember.nleft = internal global i32 0
@remember.next = internal global i8* null
@.str = [14 x i8] c"out of memory\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/h31nr1ch/SOP/refs/heads/master/Assembly/as_src/comm7.c\00"
define i8* @remember(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %9, %1
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 1
store i32 %8, i32* %4
br label %9
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
%12 = load i8, i8* %10
%13 = icmp ne i8 %12, 0
br i1 %13, label %6, label %14
14: ; preds = %9
%15 = load i32, i32* %4
%16 = load i32, i32* @remember.nleft
%17 = sub nsw i32 %16, %15
store i32 %17, i32* @remember.nleft
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %14
%20 = call i8* @malloc(i64 2048)
store i8* %20, i8** @remember.next
%21 = load i8*, i8** @remember.next
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = sub i64 2048, %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* @remember.nleft
%30 = load i32, i32* @remember.nleft
%31 = icmp sge i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %25
%33 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @assert2 to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 78)
br label %34
34: ; preds = %32, %25
br label %35
35: ; preds = %34, %14
%36 = load i8*, i8** @remember.next
store i8* %36, i8** %3
br label %37
37: ; preds = %44, %35
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %2
%40 = load i8, i8* %38
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
store i8 %40, i8* %41
%43 = icmp ne i8 %40, 0
br i1 %43, label %44, label %45
44: ; preds = %37
br label %37
45: ; preds = %37
%46 = load i8*, i8** @remember.next
store i8* %46, i8** %2
%47 = load i8*, i8** %3
store i8* %47, i8** @remember.next
%48 = load i8*, i8** %2
ret i8* %48
}

LLVM IR (-O2):
@remember.nleft = internal unnamed_addr global i32 0
@remember.next = internal unnamed_addr global i8* null
@.str = [14 x i8] c"out of memory\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/h31nr1ch/SOP/refs/heads/master/Assembly/as_src/comm7.c\00"
define i8* @remember(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = phi i32 [ 0, %1 ], [ %5, %2 ]
%5 = add nuw nsw i32 %4, 1
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %2
9: ; preds = %2
%10 = load i32, i32* @remember.nleft
%11 = sub nsw i32 %10, %5
store i32 %11, i32* @remember.nleft
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = tail call dereferenceable_or_null(2048) i8* @malloc(i64 2048)
store i8* %14, i8** @remember.next
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = sub nsw i32 2047, %4
store i32 %19, i32* @remember.nleft
%20 = icmp ult i32 %4, 2048
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @assert2 to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 78)
br label %23
23: ; preds = %18, %21, %9
%24 = load i8*, i8** @remember.next
br label %25
25: ; preds = %25, %23
%26 = phi i8* [ %0, %23 ], [ %28, %25 ]
%27 = phi i8* [ %24, %23 ], [ %30, %25 ]
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %26
%30 = getelementptr inbounds i8, i8* %27, i64 1
store i8 %29, i8* %27
%31 = icmp eq i8 %29, 0
br i1 %31, label %32, label %25
32: ; preds = %25
store i8* %30, i8** @remember.next
ret i8* %24
}