char *hashstring(unsigned char *unhashed, unsigned size) {
  unsigned usize;
  unsigned char *bstring;
  unsigned char *hash;
  int chr;
  unsigned char *hsh;
  hsh = unhashed;
  usize = size;
  usize++;
  bstring = (char *)__pmalloc(
      (usize * 2 + 1),
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/nawawi/psybnc/refs/heads/master/src/p_idea.c",
      __FUNCTION__, 440);
  usize = size;
  while (usize > 0) {
    chr = *hsh++;
    hash = hashdot(chr);
    strcat(bstring, hash);
    usize--;
  }
  return bstring;
}


x86 assembly (clang, -O0):
<hashstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
lea    0xe9a(%rip),%rsi
lea    0xf1a(%rip),%rdx
mov    $0x1b8,%ecx
mov    $0x0,%al
call   1030 <__pmalloc@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jbe    11cf <hashstring+0x9f>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x0,%al
call   1040 <hashdot@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <hashstring+0x55>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashstring>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x3(%r15,%r15,1),%edi
lea    0xeb6(%rip),%rsi
lea    0xf36(%rip),%rdx
mov    $0x1b8,%ecx
xor    %eax,%eax
call   1030 <__pmalloc@plt>
movslq %eax,%r12
test   %r15d,%r15d
je     1190 <hashstring+0x60>
mov    %r15d,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%edi
xor    %eax,%eax
call   1040 <hashdot@plt>
movslq %eax,%rsi
mov    %r12,%rdi
call   1050 <strcat@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1170 <hashstring+0x40>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nawawi/psybnc/refs/heads/master/src/p_idea.c\00"
@__FUNCTION__.hashstring = [11 x i8] c"hashstring\00"
define i8* @hashstring(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
store i8* %10, i8** %9
%11 = load i32, i32* %4
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = add i32 %12, 1
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = mul i32 %14, 2
%16 = add i32 %15, 1
%17 = call i32 (i32, i8*, i8*, i32, ...) bitcast (i32 (...)* @__pmalloc to i32 (i32, i8*, i8*, i32, ...)*)(i32 %16, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.hashstring, i64 0, i64 0), i32 440)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %6
%20 = load i32, i32* %4
store i32 %20, i32* %5
br label %21
21: ; preds = %24, %2
%22 = load i32, i32* %5
%23 = icmp ugt i32 %22, 0
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %9
%27 = load i8, i8* %25
%28 = zext i8 %27 to i32
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = call i32 (i32, ...) bitcast (i32 (...)* @hashdot to i32 (i32, ...)*)(i32 %29)
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %7
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i8* @strcat(i8* %33, i8* %34)
%36 = load i32, i32* %5
%37 = add i32 %36, -1
store i32 %37, i32* %5
br label %21
38: ; preds = %21
%39 = load i8*, i8** %6
ret i8* %39
}

LLVM IR (-O2):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nawawi/psybnc/refs/heads/master/src/p_idea.c\00"
@__FUNCTION__.hashstring = [11 x i8] c"hashstring\00"
define i8* @hashstring(i8* nocapture %0, i32 %1) {
%3 = shl i32 %1, 1
%4 = add i32 %3, 3
%5 = tail call i32 (i32, i8*, i8*, i32, ...) bitcast (i32 (...)* @__pmalloc to i32 (i32, i8*, i8*, i32, ...)*)(i32 %4, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.hashstring, i64 0, i64 0), i32 440)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i32 %1, 0
br i1 %8, label %21, label %9
9: ; preds = %2, %9
%10 = phi i8* [ %12, %9 ], [ %0, %2 ]
%11 = phi i32 [ %19, %9 ], [ %1, %2 ]
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = load i8, i8* %10
%14 = zext i8 %13 to i32
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @hashdot to i32 (i32, ...)*)(i32 %14)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = tail call i8* @strcat(i8* dereferenceable(1) %7, i8* dereferenceable(1) %17)
%19 = add i32 %11, -1
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %9
21: ; preds = %9, %2
ret i8* %7
}