int mob_class_change(struct mob_data *md, const int *value, int value_count) {
  int count = 0;
  if (nullpo_chk("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/AurigaProject/root/refs/"
                 "heads/master/src/map/mob.c",
                 2594, __FUNCTION__, (void *)(md))) {
    return (0);
  };
  if (nullpo_chk("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/AurigaProject/root/refs/"
                 "heads/master/src/map/mob.c",
                 2595, __FUNCTION__, (void *)(value))) {
    return (0);
  };
  while (count < value_count && mobdb_checkid(value[count])) {
    count++;
  }
  if (count <= 0)
    return 0;
  return mob_class_change_id(md, value[(rand() ^ (rand() >> 8)) % count]);
}


x86 assembly (clang, -O0):
<mob_class_change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xe9b(%rip),%rdi
mov    $0xa22,%esi
lea    0xf1c(%rip),%rdx
mov    $0x0,%al
call   1040 <nullpo_chk@plt>
cmp    $0x0,%eax
je     118d <mob_class_change+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    126c <mob_class_change+0x12c>
mov    -0x18(%rbp),%rcx
lea    0xe68(%rip),%rdi
mov    $0xa23,%esi
lea    0xee9(%rip),%rdx
mov    $0x0,%al
call   1040 <nullpo_chk@plt>
cmp    $0x0,%eax
je     11c0 <mob_class_change+0x80>
movl   $0x0,-0x4(%rbp)
jmp    126c <mob_class_change+0x12c>
jmp    11c5 <mob_class_change+0x85>
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x21(%rbp)
jge    11f1 <mob_class_change+0xb1>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    $0x0,%al
call   1050 <mobdb_checkid@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1201 <mob_class_change+0xc1>
jmp    120f <mob_class_change+0xcf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c5 <mob_class_change+0x85>
cmpl   $0x0,-0x20(%rbp)
jg     1225 <mob_class_change+0xe5>
movl   $0x0,-0x4(%rbp)
jmp    126c <mob_class_change+0x12c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sar    $0x8,%ecx
xor    %ecx,%eax
cltd
idivl  -0x20(%rbp)
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <mob_class_change_id@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mob_class_change>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xea9(%rip),%rdi
lea    0xf2f(%rip),%rdx
mov    $0xa22,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <nullpo_chk@plt>
test   %eax,%eax
je     117c <mob_class_change+0x3c>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe7d(%rip),%rdi
lea    0xf03(%rip),%rdx
mov    $0xa23,%esi
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <nullpo_chk@plt>
test   %eax,%eax
jne    1171 <mob_class_change+0x31>
test   %ebp,%ebp
jle    1171 <mob_class_change+0x31>
mov    %ebp,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbp,4),%edi
xor    %eax,%eax
call   1050 <mobdb_checkid@plt>
test   %eax,%eax
je     11ca <mob_class_change+0x8a>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11b0 <mob_class_change+0x70>
mov    %ebx,%ebp
test   %ebp,%ebp
je     1171 <mob_class_change+0x31>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <rand@plt>
sar    $0x8,%eax
xor    %r15d,%eax
cltd
idiv   %ebp
movslq %edx,%rax
mov    (%r12,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mob_class_change_id@plt>

LLVM IR (-O0):
%struct.mob_data = type opaque
@.str = [141 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/map/mob.c\00"
@__FUNCTION__.mob_class_change = [17 x i8] c"mob_class_change\00"
define i32 @mob_class_change(%struct.mob_data* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.mob_data*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store %struct.mob_data* %0, %struct.mob_data** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %8
%9 = load %struct.mob_data*, %struct.mob_data** %5
%10 = bitcast %struct.mob_data* %9 to i8*
%11 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 2594, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.mob_class_change, i64 0, i64 0), i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %55
14: ; preds = %3
%15 = load i32*, i32** %6
%16 = bitcast i32* %15 to i8*
%17 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 2595, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.mob_class_change, i64 0, i64 0), i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %4
br label %55
20: ; preds = %14
br label %21
21: ; preds = %35, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32*, i32** %6
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i32, ...) bitcast (i32 (...)* @mobdb_checkid to i32 (i32, ...)*)(i32 %30)
%32 = icmp ne i32 %31, 0
br label %33
33: ; preds = %25, %21
%34 = phi i1 [ false, %21 ], [ %32, %25 ]
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %21
38: ; preds = %33
%39 = load i32, i32* %8
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 0, i32* %4
br label %55
42: ; preds = %38
%43 = load %struct.mob_data*, %struct.mob_data** %5
%44 = load i32*, i32** %6
%45 = call i32 (...) @rand()
%46 = call i32 (...) @rand()
%47 = ashr i32 %46, 8
%48 = xor i32 %45, %47
%49 = load i32, i32* %8
%50 = srem i32 %48, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %44, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (%struct.mob_data*, i32, ...) bitcast (i32 (...)* @mob_class_change_id to i32 (%struct.mob_data*, i32, ...)*)(%struct.mob_data* %43, i32 %53)
store i32 %54, i32* %4
br label %55
55: ; preds = %42, %41, %19, %13
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
%struct.mob_data = type opaque
@.str = [141 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/map/mob.c\00"
@__FUNCTION__.mob_class_change = [17 x i8] c"mob_class_change\00"
define i32 @mob_class_change(%struct.mob_data* %0, i32* %1, i32 %2) {
%4 = bitcast %struct.mob_data* %0 to i8*
%5 = tail call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 2594, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.mob_class_change, i64 0, i64 0), i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %39
7: ; preds = %3
%8 = bitcast i32* %1 to i8*
%9 = tail call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 2595, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__FUNCTION__.mob_class_change, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 %9, 0
%11 = icmp sgt i32 %2, 0
%12 = and i1 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %7
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %13, %21
%16 = phi i64 [ 0, %13 ], [ %22, %21 ]
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @mobdb_checkid to i32 (i32, ...)*)(i32 %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %14
br i1 %23, label %26, label %15
24: ; preds = %15
%25 = trunc i64 %16 to i32
br label %26
26: ; preds = %21, %24
%27 = phi i32 [ %25, %24 ], [ %2, %21 ]
%28 = icmp eq i32 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %26
%30 = tail call i32 (...) @rand()
%31 = tail call i32 (...) @rand()
%32 = ashr i32 %31, 8
%33 = xor i32 %32, %30
%34 = srem i32 %33, %27
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %1, i64 %35
%37 = load i32, i32* %36
%38 = tail call i32 (%struct.mob_data*, i32, ...) bitcast (i32 (...)* @mob_class_change_id to i32 (%struct.mob_data*, i32, ...)*)(%struct.mob_data* %0, i32 %37)
br label %39
39: ; preds = %26, %7, %3, %29
%40 = phi i32 [ %38, %29 ], [ 0, %3 ], [ 0, %7 ], [ 0, %26 ]
ret i32 %40
}