#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ ENOMEM;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ errno;
void *slurm_xmalloc(int, char *, int, char *);
void *list_alloc_aux(int size, void *pfreelist) {
  void **px;
  void **pfree = pfreelist;
  void **plast;
  assert(sizeof(char) == 1);
  assert(size >= sizeof(void *));
  assert(pfreelist != NULL);
  assert(128 > 0);
  ;
  if (!*pfree) {
    if ((*pfree = slurm_xmalloc(
             128 * size,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/"
             "heads/master/src/common/list.c",
             1022, ""))) {
      px = *pfree;
      plast = (void **)((char *)*pfree + ((128 - 1) * size));
      while (px < plast)
        *px = (char *)px + size, px = *px;
      *plast = NULL;
    }
  }
  if ((px = *pfree))
    *pfree = *px;
  else
    errno = ENOMEM;
  ;
  return px;
}


x86 assembly (clang, -O0):
<list_alloc_aux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   1040 <assert@plt>
movslq -0x4(%rbp),%rax
cmp    $0x8,%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x1,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    120f <list_alloc_aux+0xef>
mov    -0x4(%rbp),%edi
shl    $0x7,%edi
lea    0xe73(%rip),%rsi
mov    $0x3fe,%edx
lea    0xf01(%rip),%rcx
call   1030 <slurm_xmalloc@plt>
mov    -0x20(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
je     120a <list_alloc_aux+0xea>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
imul   $0x7f,-0x4(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11ff <list_alloc_aux+0xdf>
mov    -0x18(%rbp),%rcx
movslq -0x4(%rbp),%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11cf <list_alloc_aux+0xaf>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
jmp    120f <list_alloc_aux+0xef>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1237 <list_alloc_aux+0x117>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1249 <list_alloc_aux+0x129>
mov    0x2da2(%rip),%rax
mov    (%rax),%ecx
mov    0x2d91(%rip),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_alloc_aux>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
mov    $0x1,%edi
call   1040 <assert@plt>
xor    %edi,%edi
cmp    $0x8,%r14d
setae  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
mov    $0x1,%edi
call   1040 <assert@plt>
mov    (%rbx),%rax
test   %rax,%rax
je     116b <list_alloc_aux+0x4b>
mov    (%rax),%rcx
mov    %rcx,(%rbx)
jmp    11e2 <list_alloc_aux+0xc2>
mov    %r14d,%ebp
shl    $0x7,%ebp
lea    0xe88(%rip),%rsi
lea    0xf1b(%rip),%rcx
mov    %ebp,%edi
mov    $0x3fe,%edx
call   1030 <slurm_xmalloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11ce <list_alloc_aux+0xae>
sub    %r14d,%ebp
movslq %ebp,%rcx
add    %rax,%rcx
test   %r14d,%r14d
jle    11bf <list_alloc_aux+0x9f>
movslq %r14d,%rdx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rax,%rdx,1),%rsi
mov    %rsi,(%rax)
mov    %rsi,%rax
cmp    %rcx,%rsi
jb     11b0 <list_alloc_aux+0x90>
movq   $0x0,(%rcx)
mov    (%rbx),%rax
test   %rax,%rax
jne    1163 <list_alloc_aux+0x43>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    0x2dfa(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/list.c\00"
@.str.1 = [1 x i8] zeroinitializer
@ENOMEM = global i32 0
@errno = global i32 0
define i8* @list_alloc_aux(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i8**
store i8** %9, i8*** %6
%10 = call i32 @assert(i32 1)
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = icmp uge i64 %12, 8
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @assert(i32 1)
%21 = load i8**, i8*** %6
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %58, label %24
24: ; preds = %2
%25 = load i32, i32* %3
%26 = mul nsw i32 128, %25
%27 = call i8* @slurm_xmalloc(i32 %26, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str, i64 0, i64 0), i32 1022, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8**, i8*** %6
store i8* %27, i8** %28
%29 = icmp ne i8* %27, null
br i1 %29, label %30, label %57
30: ; preds = %24
%31 = load i8**, i8*** %6
%32 = load i8*, i8** %31
%33 = bitcast i8* %32 to i8**
store i8** %33, i8*** %5
%34 = load i8**, i8*** %6
%35 = load i8*, i8** %34
%36 = load i32, i32* %3
%37 = mul nsw i32 127, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = bitcast i8* %39 to i8**
store i8** %40, i8*** %7
br label %41
41: ; preds = %45, %30
%42 = load i8**, i8*** %5
%43 = load i8**, i8*** %7
%44 = icmp ult i8** %42, %43
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i8**, i8*** %5
%47 = bitcast i8** %46 to i8*
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8**, i8*** %5
store i8* %50, i8** %51
%52 = load i8**, i8*** %5
%53 = load i8*, i8** %52
%54 = bitcast i8* %53 to i8**
store i8** %54, i8*** %5
br label %41
55: ; preds = %41
%56 = load i8**, i8*** %7
store i8* null, i8** %56
br label %57
57: ; preds = %55, %24
br label %58
58: ; preds = %57, %2
%59 = load i8**, i8*** %6
%60 = load i8*, i8** %59
%61 = bitcast i8* %60 to i8**
store i8** %61, i8*** %5
%62 = icmp ne i8** %61, null
br i1 %62, label %63, label %67
63: ; preds = %58
%64 = load i8**, i8*** %5
%65 = load i8*, i8** %64
%66 = load i8**, i8*** %6
store i8* %65, i8** %66
br label %69
67: ; preds = %58
%68 = load i32, i32* @ENOMEM
store i32 %68, i32* @errno
br label %69
69: ; preds = %67, %63
%70 = load i8**, i8*** %5
%71 = bitcast i8** %70 to i8*
ret i8* %71
}

LLVM IR (-O2):
@.str = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/list.c\00"
@.str.1 = [1 x i8] zeroinitializer
@ENOMEM = global i32 0
@errno = global i32 0
define i8* @list_alloc_aux(i32 %0, i8* %1) {
%3 = bitcast i8* %1 to i8**
%4 = tail call i32 @assert(i32 1)
%5 = sext i32 %0 to i64
%6 = icmp ugt i32 %0, 7
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp ne i8* %1, null
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @assert(i32 1)
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %33
15: ; preds = %2
%16 = shl nsw i32 %0, 7
%17 = tail call i8* @slurm_xmalloc(i32 %16, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str, i64 0, i64 0), i32 1022, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %3
%18 = icmp eq i8* %17, null
br i1 %18, label %37, label %19
19: ; preds = %15
%20 = mul nsw i32 %0, 127
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = bitcast i8* %22 to i8**
%24 = icmp sgt i32 %0, 0
br i1 %24, label %25, label %30
25: ; preds = %19, %25
%26 = phi i8* [ %28, %25 ], [ %17, %19 ]
%27 = bitcast i8* %26 to i8**
%28 = getelementptr inbounds i8, i8* %26, i64 %5
store i8* %28, i8** %27
%29 = icmp ult i8* %28, %22
br i1 %29, label %25, label %30
30: ; preds = %25, %19
store i8* null, i8** %23
%31 = load i8*, i8** %3
%32 = icmp eq i8* %31, null
br i1 %32, label %37, label %33
33: ; preds = %2, %30
%34 = phi i8* [ %31, %30 ], [ %13, %2 ]
%35 = bitcast i8* %34 to i8**
%36 = load i8*, i8** %35
store i8* %36, i8** %3
br label %39
37: ; preds = %15, %30
%38 = load i32, i32* @ENOMEM
store i32 %38, i32* @errno
br label %39
39: ; preds = %37, %33
%40 = phi i8* [ null, %37 ], [ %34, %33 ]
ret i8* %40
}