char *httpd_quote_meta(const char *p1) {
  char *buf = (char *)aMalloc_(
      strlen(p1) * 6 + 1,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/AurigaProject/root/refs/heads/master/src/"
      "common/httpd.c",
      3102, __FUNCTION__);
  char *p2 = buf;
  while (*p1) {
    switch (*p1) {
    case '<':
      memcpy(p2, "&lt;", 4);
      p2 += 4;
      p1++;
      break;
    case '>':
      memcpy(p2, "&gt;", 4);
      p2 += 4;
      p1++;
      break;
    case '&':
      memcpy(p2, "&amp;", 5);
      p2 += 5;
      p1++;
      break;
    case '"':
      memcpy(p2, "&quot;", 6);
      p2 += 6;
      p1++;
      break;
    default:
      *(p2++) = *(p1++);
    }
  }
  *p2 = 0;
  return buf;
}


x86 assembly (clang, -O0):
<httpd_quote_meta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
imul   $0x6,%rax,%rdi
add    $0x1,%rdi
lea    0xf30(%rip),%rsi
mov    $0xc1e,%edx
lea    0xfb6(%rip),%rcx
mov    $0x0,%al
call   1040 <aMalloc_@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     127e <httpd_quote_meta+0x15e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1c,%eax
ja     1257 <httpd_quote_meta+0x137>
mov    -0x20(%rbp),%rax
lea    0xe6a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    0xf6e(%rip),%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1279 <httpd_quote_meta+0x159>
mov    -0x18(%rbp),%rax
mov    0xf4a(%rip),%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1279 <httpd_quote_meta+0x159>
mov    -0x18(%rbp),%rax
mov    0xf26(%rip),%ecx
mov    %ecx,(%rax)
mov    0xf22(%rip),%cl
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1279 <httpd_quote_meta+0x159>
mov    -0x18(%rbp),%rax
mov    0xefa(%rip),%ecx
mov    %ecx,(%rax)
mov    0xef5(%rip),%cx
mov    %cx,0x4(%rax)
mov    -0x18(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1279 <httpd_quote_meta+0x159>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1165 <httpd_quote_meta+0x45>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_quote_meta>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
add    %rax,%rax
lea    (%rax,%rax,2),%rdi
or     $0x1,%rdi
lea    0xf39(%rip),%rsi
lea    0xfc4(%rip),%rcx
mov    $0xc1e,%edx
xor    %eax,%eax
call   1040 <aMalloc_@plt>
cltq
mov    (%rbx),%dl
mov    %rax,%rcx
test   %dl,%dl
je     11ec <httpd_quote_meta+0xcc>
add    $0x1,%rbx
lea    0xe98(%rip),%rsi
mov    %rax,%rcx
jmp    118b <httpd_quote_meta+0x6b>
nopl   (%rax)
mov    %dl,(%rcx)
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%edx
add    $0x1,%rbx
test   %dl,%dl
je     11ec <httpd_quote_meta+0xcc>
movsbl %dl,%edi
add    $0xffffffde,%edi
cmp    $0x1c,%edi
ja     1170 <httpd_quote_meta+0x50>
movslq (%rsi,%rdi,4),%rdi
add    %rsi,%rdi
jmp    *%rdi
movw   $0x3b74,0x4(%rcx)
movl   $0x6f757126,(%rcx)
add    $0x6,%rcx
jmp    1180 <httpd_quote_meta+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x3b,0x4(%rcx)
movl   $0x706d6126,(%rcx)
add    $0x5,%rcx
jmp    1180 <httpd_quote_meta+0x60>
movl   $0x3b746c26,(%rcx)
add    $0x4,%rcx
jmp    1180 <httpd_quote_meta+0x60>
nopl   0x0(%rax)
movl   $0x3b746726,(%rcx)
add    $0x4,%rcx
jmp    1180 <httpd_quote_meta+0x60>
movb   $0x0,(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AurigaProject/root/refs/heads/master/src/common/httpd.c\00"
@__FUNCTION__.httpd_quote_meta = [17 x i8] c"httpd_quote_meta\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
@.str.4 = [7 x i8] c"&quot;\00"
define i8* @httpd_quote_meta(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
%7 = mul i64 %6, 6
%8 = add i64 %7, 1
%9 = call i32 (i64, i8*, i32, i8*, ...) bitcast (i32 (...)* @aMalloc_ to i32 (i64, i8*, i32, i8*, ...)*)(i64 %8, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 3102, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.httpd_quote_meta, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %3
store i8* %12, i8** %4
br label %13
13: ; preds = %51, %1
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %52
17: ; preds = %13
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %45 [
i32 60, label %21
i32 62, label %27
i32 38, label %33
i32 34, label %39
]
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 4
store i8* %24, i8** %4
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %51
27: ; preds = %17
%28 = load i8*, i8** %4
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 4
store i8* %30, i8** %4
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %2
br label %51
33: ; preds = %17
%34 = load i8*, i8** %4
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 5
store i8* %36, i8** %4
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %2
br label %51
39: ; preds = %17
%40 = load i8*, i8** %4
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 6
store i8* %42, i8** %4
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %2
br label %51
45: ; preds = %17
%46 = load i8*, i8** %2
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %2
%48 = load i8, i8* %46
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %4
store i8 %48, i8* %49
br label %51
51: ; preds = %45, %39, %33, %27, %21
br label %13
52: ; preds = %13
%53 = load i8*, i8** %4
store i8 0, i8* %53
%54 = load i8*, i8** %3
ret i8* %54
}

LLVM IR (-O2):
@.str = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AurigaProject/root/refs/heads/master/src/common/httpd.c\00"
@__FUNCTION__.httpd_quote_meta = [17 x i8] c"httpd_quote_meta\00"
@.str.3 = [6 x i8] c"&amp;\00"
@.str.4 = [7 x i8] c"&quot;\00"
define i8* @httpd_quote_meta(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = mul i64 %2, 6
%4 = or i64 %3, 1
%5 = tail call i32 (i64, i8*, i32, i8*, ...) bitcast (i32 (...)* @aMalloc_ to i32 (i64, i8*, i32, i8*, ...)*)(i64 %4, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 3102, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.httpd_quote_meta, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %32, label %10
10: ; preds = %1, %27
%11 = phi i8 [ %30, %27 ], [ %8, %1 ]
%12 = phi i8* [ %28, %27 ], [ %7, %1 ]
%13 = phi i8* [ %29, %27 ], [ %0, %1 ]
%14 = sext i8 %11 to i32
switch i32 %14, label %25 [
i32 60, label %15
i32 62, label %18
i32 38, label %21
i32 34, label %23
]
15: ; preds = %10
%16 = bitcast i8* %12 to i32*
store i32 997485606, i32* %16
%17 = getelementptr inbounds i8, i8* %12, i64 4
br label %27
18: ; preds = %10
%19 = bitcast i8* %12 to i32*
store i32 997484326, i32* %19
%20 = getelementptr inbounds i8, i8* %12, i64 4
br label %27
21: ; preds = %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %12, i8* align 1 dereferenceable(5) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 5, i1 false)
%22 = getelementptr inbounds i8, i8* %12, i64 5
br label %27
23: ; preds = %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) %12, i8* align 1 dereferenceable(6) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i1 false)
%24 = getelementptr inbounds i8, i8* %12, i64 6
br label %27
25: ; preds = %10
%26 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %11, i8* %12
br label %27
27: ; preds = %25, %23, %21, %18, %15
%28 = phi i8* [ %26, %25 ], [ %24, %23 ], [ %22, %21 ], [ %20, %18 ], [ %17, %15 ]
%29 = getelementptr inbounds i8, i8* %13, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %10
32: ; preds = %27, %1
%33 = phi i8* [ %7, %1 ], [ %28, %27 ]
store i8 0, i8* %33
ret i8* %7
}