#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 */
typedef int /*<<< orphan*/ int8_t;

/* Variables and functions */
intptr_t find_super_type_args_size(const int8_t *const *instructions,
                                   intptr_t *type_arg_offsets) {
  intptr_t size = 0;
  while (true) {
    const int8_t *inst = *instructions++;
    if ((intptr_t)inst == -1) {
      break;
    } else if ((intptr_t)inst & 0x1) {
      intptr_t arg = (intptr_t)inst >> 1;
      intptr_t arg_size =
          arg == 0 ? type_arg_offsets[0]
                   : type_arg_offsets[arg] - type_arg_offsets[arg - 1];
      size += arg_size;
    } else {
      size += 1;
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<find_super_type_args_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    $0xffffffffffffffff,%rax
jne    113d <find_super_type_args_size+0x3d>
jmp    11c5 <find_super_type_args_size+0xc5>
mov    -0x20(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11af <find_super_type_args_size+0xaf>
mov    -0x20(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1176 <find_super_type_args_size+0x76>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1196 <find_super_type_args_size+0x96>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
sub    (%rcx,%rdx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11bb <find_super_type_args_size+0xbb>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11c0 <find_super_type_args_size+0xc0>
jmp    1114 <find_super_type_args_size+0x14>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_super_type_args_size>:
mov    (%rdi),%rcx
cmp    $0xffffffffffffffff,%rcx
je     1152 <find_super_type_args_size+0x52>
add    $0x8,%rdi
xor    %eax,%eax
jmp    113c <find_super_type_args_size+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
sar    %rcx
mov    (%rsi,%rcx,8),%rdx
sub    -0x8(%rsi,%rcx,8),%rdx
add    %rdx,%rax
mov    (%rdi),%rcx
add    $0x8,%rdi
cmp    $0xffffffffffffffff,%rcx
je     1151 <find_super_type_args_size+0x51>
mov    $0x1,%edx
test   $0x1,%cl
je     112c <find_super_type_args_size+0x2c>
cmp    $0x1,%rcx
ja     1120 <find_super_type_args_size+0x20>
mov    (%rsi),%rdx
jmp    112c <find_super_type_args_size+0x2c>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i64 @find_super_type_args_size(i32** %0, i64* %1) {
%3 = alloca i32**
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i32** %0, i32*** %3
store i64* %1, i64** %4
store i64 0, i64* %5
br label %9
9: ; preds = %2, %52
%10 = load i32**, i32*** %3
%11 = getelementptr inbounds i32*, i32** %10, i32 1
store i32** %11, i32*** %3
%12 = load i32*, i32** %10
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = ptrtoint i32* %13 to i64
%15 = icmp eq i64 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %9
br label %53
17: ; preds = %9
%18 = load i32*, i32** %6
%19 = ptrtoint i32* %18 to i64
%20 = and i64 %19, 1
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %48
22: ; preds = %17
%23 = load i32*, i32** %6
%24 = ptrtoint i32* %23 to i64
%25 = ashr i64 %24, 1
store i64 %25, i64* %7
%26 = load i64, i64* %7
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i64*, i64** %4
%30 = getelementptr inbounds i64, i64* %29, i64 0
%31 = load i64, i64* %30
br label %43
32: ; preds = %22
%33 = load i64*, i64** %4
%34 = load i64, i64* %7
%35 = getelementptr inbounds i64, i64* %33, i64 %34
%36 = load i64, i64* %35
%37 = load i64*, i64** %4
%38 = load i64, i64* %7
%39 = sub nsw i64 %38, 1
%40 = getelementptr inbounds i64, i64* %37, i64 %39
%41 = load i64, i64* %40
%42 = sub nsw i64 %36, %41
br label %43
43: ; preds = %32, %28
%44 = phi i64 [ %31, %28 ], [ %42, %32 ]
store i64 %44, i64* %8
%45 = load i64, i64* %8
%46 = load i64, i64* %5
%47 = add nsw i64 %46, %45
store i64 %47, i64* %5
br label %51
48: ; preds = %17
%49 = load i64, i64* %5
%50 = add nsw i64 %49, 1
store i64 %50, i64* %5
br label %51
51: ; preds = %48, %43
br label %52
52: ; preds = %51
br label %9
53: ; preds = %16
%54 = load i64, i64* %5
ret i64 %54
}

LLVM IR (-O2):
define i64 @find_super_type_args_size(i32** nocapture %0, i64* nocapture %1) {
%3 = load i32*, i32** %0
%4 = icmp eq i32* %3, inttoptr (i64 -1 to i32*)
br i1 %4, label %30, label %5
5: ; preds = %2, %25
%6 = phi i32* [ %28, %25 ], [ %3, %2 ]
%7 = phi i32** [ %9, %25 ], [ %0, %2 ]
%8 = phi i64 [ %27, %25 ], [ 0, %2 ]
%9 = getelementptr inbounds i32*, i32** %7, i64 1
%10 = ptrtoint i32* %6 to i64
%11 = and i64 %10, 1
%12 = icmp eq i64 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %5
%14 = ashr i64 %10, 1
%15 = icmp ult i32* %6, inttoptr (i64 2 to i32*)
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i64, i64* %1
br label %25
18: ; preds = %13
%19 = getelementptr inbounds i64, i64* %1, i64 %14
%20 = load i64, i64* %19
%21 = add nsw i64 %14, -1
%22 = getelementptr inbounds i64, i64* %1, i64 %21
%23 = load i64, i64* %22
%24 = sub nsw i64 %20, %23
br label %25
25: ; preds = %18, %16, %5
%26 = phi i64 [ %17, %16 ], [ %24, %18 ], [ 1, %5 ]
%27 = add nsw i64 %26, %8
%28 = load i32*, i32** %9
%29 = icmp eq i32* %28, inttoptr (i64 -1 to i32*)
br i1 %29, label %30, label %5
30: ; preds = %25, %2
%31 = phi i64 [ 0, %2 ], [ %27, %25 ]
ret i64 %31
}