int m_lookup(int m, int key) {
  int p, *d;
  if (m_len(key) == 0)
    deb_err(
        1330,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/xtforever/xtcw/refs/heads/master/lib/mls.c",
        __FUNCTION__, "Key of zero size");
  for (p = -1; m_next(m, &p, &d);)
    if (m_cmp(*d, key) == 0)
      return *d;
  m_put(m, &key);
  return key;
}


x86 assembly (clang, -O0):
<m_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1030 <m_len@plt>
cmp    $0x0,%eax
jne    1192 <m_lookup+0x42>
mov    $0x532,%edi
lea    0xe83(%rip),%rsi
lea    0xf01(%rip),%rdx
lea    0xf03(%rip),%rcx
mov    $0x0,%al
call   1060 <deb_err@plt>
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1070 <m_next@plt>
cmp    $0x0,%eax
je     11e0 <m_lookup+0x90>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1050 <m_cmp@plt>
cmp    $0x0,%eax
jne    11db <m_lookup+0x8b>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f4 <m_lookup+0xa4>
jmp    1199 <m_lookup+0x49>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <m_put@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_lookup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %esi,0xc(%rsp)
mov    %esi,%edi
xor    %eax,%eax
call   1030 <m_len@plt>
test   %eax,%eax
jne    1190 <m_lookup+0x40>
lea    0xe8a(%rip),%rsi
lea    0xf08(%rip),%rdx
lea    0xf0a(%rip),%rcx
mov    $0x532,%edi
xor    %eax,%eax
call   1060 <deb_err@plt>
movl   $0xffffffff,0x8(%rsp)
ff
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <m_next@plt>
test   %eax,%eax
je     11de <m_lookup+0x8e>
mov    0x10(%rsp),%rax
mov    (%rax),%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <m_cmp@plt>
test   %eax,%eax
jne    11b0 <m_lookup+0x60>
mov    0x10(%rsp),%rbp
jmp    11ef <m_lookup+0x9f>
lea    0xc(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <m_put@plt>
mov    0x0(%rbp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/xtforever/xtcw/refs/heads/master/lib/mls.c\00"
@__FUNCTION__.m_lookup = [9 x i8] c"m_lookup\00"
@.str.1 = [17 x i8] c"Key of zero size\00"
define i32 @m_lookup(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = call i32 (i32, ...) bitcast (i32 (...)* @m_len to i32 (i32, ...)*)(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @deb_err to i32 (i32, i8*, i8*, i8*, ...)*)(i32 1330, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__FUNCTION__.m_lookup, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
store i32 -1, i32* %6
br label %14
14: ; preds = %27, %13
%15 = load i32, i32* %4
%16 = call i32 (i32, i32*, i32**, ...) bitcast (i32 (...)* @m_next to i32 (i32, i32*, i32**, ...)*)(i32 %15, i32* %6, i32** %7)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = load i32, i32* %5
%22 = call i32 (i32, i32, ...) bitcast (i32 (...)* @m_cmp to i32 (i32, i32, ...)*)(i32 %20, i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32*, i32** %7
%26 = load i32, i32* %25
store i32 %26, i32* %3
br label %32
27: ; preds = %18
br label %14
28: ; preds = %14
%29 = load i32, i32* %4
%30 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @m_put to i32 (i32, i32*, ...)*)(i32 %29, i32* %5)
%31 = load i32, i32* %5
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %24
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/xtforever/xtcw/refs/heads/master/lib/mls.c\00"
@__FUNCTION__.m_lookup = [9 x i8] c"m_lookup\00"
@.str.1 = [17 x i8] c"Key of zero size\00"
define i32 @m_lookup(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %1, i32* %3
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32** %5 to i8*
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @m_len to i32 (i32, ...)*)(i32 %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @deb_err to i32 (i32, i8*, i8*, i8*, ...)*)(i32 1330, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__FUNCTION__.m_lookup, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
store i32 -1, i32* %4
br label %13
13: ; preds = %16, %12
%14 = call i32 (i32, i32*, i32**, ...) bitcast (i32 (...)* @m_next to i32 (i32, i32*, i32**, ...)*)(i32 %0, i32* %4, i32** %5)
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = call i32 (i32, i32, ...) bitcast (i32 (...)* @m_cmp to i32 (i32, i32, ...)*)(i32 %18, i32 %1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %16
%22 = load i32*, i32** %5
br label %25
23: ; preds = %13
%24 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @m_put to i32 (i32, i32*, ...)*)(i32 %0, i32* %3)
br label %25
25: ; preds = %23, %21
%26 = phi i32* [ %22, %21 ], [ %3, %23 ]
%27 = load i32, i32* %26
ret i32 %27
}