#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 */
struct ic_type_ref {
  int dummy;
};
struct ic_type_param {
  int dummy;
};
struct ic_pvector {
  int dummy;
};
struct ic_kludge {
  int dummy;
};
struct ic_decl_type {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ic_analyse_decl_type(struct ic_kludge *,
                                        struct ic_decl_type *);
struct ic_decl_type *ic_analyse_resolve_type_ref(struct ic_kludge *, char *,
                                                 char *, int /*<<< orphan*/,
                                                 struct ic_type_ref *);
struct ic_decl_type *ic_decl_type_deep_copy(struct ic_decl_type *);
scalar_t__ ic_decl_type_is_instantiated(struct ic_decl_type *);
int /*<<< orphan*/ ic_decl_type_mark_instantiated(struct ic_decl_type *);
struct ic_type_param *ic_decl_type_type_params_get(struct ic_decl_type *,
                                                   unsigned int);
unsigned int ic_decl_type_type_params_length(struct ic_decl_type *);
int /*<<< orphan*/ ic_kludge_add_tdecl(struct ic_kludge *,
                                       struct ic_decl_type *);
struct ic_type_ref *ic_pvector_get(struct ic_pvector *, unsigned int);
unsigned int ic_pvector_length(struct ic_pvector *);
int /*<<< orphan*/ ic_type_param_set(struct ic_type_param *,
                                     struct ic_decl_type *);
int /*<<< orphan*/ puts(char *);
struct ic_decl_type *
ic_analyse_type_decl_instantiate_generic(struct ic_kludge *kludge,
                                         struct ic_decl_type *tdecl,
                                         struct ic_pvector *type_args) {
  struct ic_decl_type *new_decl_type = 0;
  unsigned int len = 0;
  unsigned int i = 0;
  struct ic_type_param *type_param = 0;
  struct ic_type_ref *type_arg = 0;
  struct ic_decl_type *type_arg_decl = 0;
  if (!kludge) {
    puts("ic_analyse_type_decl_instantiate_generic: kludge was null");
    return 0;
  }
  if (!tdecl) {
    puts("ic_analyse_type_decl_instantiate_generic: tdecl was null");
    return 0;
  }
  if (!type_args) {
    puts("ic_analyse_type_decl_instantiate_generic: type_args was null");
    return 0;
  }
  if (ic_decl_type_is_instantiated(tdecl)) {
    return tdecl;
  }
  new_decl_type = ic_decl_type_deep_copy(tdecl);
  if (!new_decl_type) {
    puts("ic_analyse_type_decl_instantiate_generic: call to "
         "ic_decl_type_deep_copy failed");
    return 0;
  }
  len = ic_decl_type_type_params_length(new_decl_type);
  if (len != ic_pvector_length(type_args)) {
    puts("ic_analyse_type_decl_instantiate_generic: error: number of provided "
         "type arguments does not match number of expected type params");
    return 0;
  }
  for (i = 0; i < len; ++i) {
    type_param = ic_decl_type_type_params_get(new_decl_type, i);
    if (!type_param) {
      puts("ic_analyse_type_decl_instantiate_generic: call to "
           "ic_decl_type_type_params_get failed");
      return 0;
    }
    type_arg = ic_pvector_get(type_args, i);
    if (!type_arg) {
      puts("ic_analyse_type_decl_instantiate_generic: call to ic_pvector_get "
           "failed");
      return 0;
    }
    type_arg_decl = ic_analyse_resolve_type_ref(
        kludge, "ic_analyse_type_decl_instantiate_generic",
        "seriously kill these messages", 0, type_arg);
    if (!type_arg_decl) {
      puts("ic_analyse_type_decl_instantiate_generic: call to "
           "ic_analyse_resolve_type_ref failed");
      return 0;
    }
    if (!ic_type_param_set(type_param, type_arg_decl)) {
      puts("ic_analyse_type_decl_instantiate_generic: call to "
           "ic_type_param_set failed");
      return 0;
    }
  }
  if (!ic_decl_type_mark_instantiated(new_decl_type)) {
    puts("ic_analyse_type_decl_instantiate_generic: call to "
         "ic_decl_type_mark_instantiated failed");
    return 0;
  }
  if (!ic_kludge_add_tdecl(kludge, new_decl_type)) {
    puts("ic_analyse_type_decl_instantiate_generic: call to "
         "ic_kludge_add_tdecl failed");
    return 0;
  }
  if (!ic_analyse_decl_type(kludge, new_decl_type)) {
    puts("ic_analyse_type_decl_instantiate_generic: call to "
         "ic_analyse_decl_type failed");
    return 0;
  }
  return new_decl_type;
}


x86 assembly (clang, -O0):
<ic_analyse_type_decl_instantiate_generic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1226 <ic_analyse_type_decl_instantiate_generic+0x66>
lea    0xdec(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
cmpq   $0x0,-0x18(%rbp)
jne    124a <ic_analyse_type_decl_instantiate_generic+0x8a>
lea    0xe02(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
cmpq   $0x0,-0x20(%rbp)
jne    126e <ic_analyse_type_decl_instantiate_generic+0xae>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x18(%rbp),%rdi
call   10d0 <ic_decl_type_is_instantiated@plt>
cmp    $0x0,%rax
je     128e <ic_analyse_type_decl_instantiate_generic+0xce>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x18(%rbp),%rdi
call   10a0 <ic_decl_type_deep_copy@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12bf <ic_analyse_type_decl_instantiate_generic+0xff>
lea    0xe03(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x28(%rbp),%rdi
call   1090 <ic_decl_type_type_params_length@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
call   10c0 <ic_pvector_length@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
je     1300 <ic_analyse_type_decl_instantiate_generic+0x140>
lea    0xe12(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    1402 <ic_analyse_type_decl_instantiate_generic+0x242>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1070 <ic_decl_type_type_params_get@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1347 <ic_analyse_type_decl_instantiate_generic+0x187>
lea    0xe4c(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   10b0 <ic_pvector_get@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    137b <ic_analyse_type_decl_instantiate_generic+0x1bb>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%r8
lea    0xe95(%rip),%rsi
lea    0xeb7(%rip),%rdx
xor    %ecx,%ecx
call   1030 <ic_analyse_resolve_type_ref@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13c0 <ic_analyse_type_decl_instantiate_generic+0x200>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1080 <ic_type_param_set@plt>
cmp    $0x0,%eax
jne    13ef <ic_analyse_type_decl_instantiate_generic+0x22f>
lea    0xede(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
jmp    13f4 <ic_analyse_type_decl_instantiate_generic+0x234>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1307 <ic_analyse_type_decl_instantiate_generic+0x147>
mov    -0x28(%rbp),%rdi
call   1060 <ic_decl_type_mark_instantiated@plt>
cmp    $0x0,%eax
jne    142d <ic_analyse_type_decl_instantiate_generic+0x26d>
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10e0 <ic_kludge_add_tdecl@plt>
cmp    $0x0,%eax
jne    145c <ic_analyse_type_decl_instantiate_generic+0x29c>
lea    0xf14(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <ic_analyse_decl_type@plt>
cmp    $0x0,%eax
jne    148b <ic_analyse_type_decl_instantiate_generic+0x2cb>
lea    0xf32(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1493 <ic_analyse_type_decl_instantiate_generic+0x2d3>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_analyse_type_decl_instantiate_generic>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     12e6 <ic_analyse_type_decl_instantiate_generic+0x126>
mov    %rsi,%rbx
test   %rsi,%rsi
je     12ef <ic_analyse_type_decl_instantiate_generic+0x12f>
mov    %rdx,%r15
test   %rdx,%rdx
je     12f8 <ic_analyse_type_decl_instantiate_generic+0x138>
mov    %rdi,%r14
mov    %rbx,%rdi
call   10d0 <ic_decl_type_is_instantiated@plt>
test   %rax,%rax
jne    1309 <ic_analyse_type_decl_instantiate_generic+0x149>
mov    %rbx,%rdi
call   10a0 <ic_decl_type_deep_copy@plt>
test   %rax,%rax
je     131b <ic_analyse_type_decl_instantiate_generic+0x15b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <ic_decl_type_type_params_length@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   10c0 <ic_pvector_length@plt>
cmp    %eax,%ebp
jne    1324 <ic_analyse_type_decl_instantiate_generic+0x164>
test   %ebp,%ebp
je     12af <ic_analyse_type_decl_instantiate_generic+0xef>
xor    %r13d,%r13d
lea    0xf45(%rip),%r12
mov    %ebp,0x4(%rsp)
mov    %rbx,%rdi
mov    %r13d,%esi
call   1070 <ic_decl_type_type_params_get@plt>
test   %rax,%rax
je     12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r13d,%esi
call   10b0 <ic_pvector_get@plt>
test   %rax,%rax
je     1336 <ic_analyse_type_decl_instantiate_generic+0x176>
mov    %r14,%rdi
lea    0xfaa(%rip),%rsi
lea    0xfcc(%rip),%rdx
xor    %ecx,%ecx
mov    %rax,%r8
call   1030 <ic_analyse_resolve_type_ref@plt>
test   %rax,%rax
je     133f <ic_analyse_type_decl_instantiate_generic+0x17f>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1080 <ic_type_param_set@plt>
test   %eax,%eax
je     1348 <ic_analyse_type_decl_instantiate_generic+0x188>
add    $0x1,%r13d
mov    0x4(%rsp),%ebp
cmp    %r13d,%ebp
jne    1240 <ic_analyse_type_decl_instantiate_generic+0x80>
mov    %rbx,%rdi
call   1060 <ic_decl_type_mark_instantiated@plt>
test   %eax,%eax
je     132d <ic_analyse_type_decl_instantiate_generic+0x16d>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10e0 <ic_kludge_add_tdecl@plt>
test   %eax,%eax
je     1351 <ic_analyse_type_decl_instantiate_generic+0x191>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <ic_analyse_decl_type@plt>
test   %eax,%eax
jne    1309 <ic_analyse_type_decl_instantiate_generic+0x149>
lea    0x10c7(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xd13(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xd44(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xd74(%rip),%r12
mov    %r12,%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd8e(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xdd5(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xfd2(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xe9a(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xf20(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0xf6c(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>
lea    0x1006(%rip),%r12
jmp    12ff <ic_analyse_type_decl_instantiate_generic+0x13f>

LLVM IR (-O0):
%struct.ic_kludge = type { i32 }
%struct.ic_decl_type = type { i32 }
%struct.ic_pvector = type { i32 }
%struct.ic_type_param = type { i32 }
%struct.ic_type_ref = type { i32 }
@.str = [58 x i8] c"ic_analyse_type_decl_instantiate_generic: kludge was null\00"
@.str.1 = [57 x i8] c"ic_analyse_type_decl_instantiate_generic: tdecl was null\00"
@.str.2 = [61 x i8] c"ic_analyse_type_decl_instantiate_generic: type_args was null\00"
@.str.3 = [80 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_deep_copy failed\00"
@.str.4 = [129 x i8] c"ic_analyse_type_decl_instantiate_generic: error: number of provided type arguments does not match number of expected type params\00"
@.str.5 = [86 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_type_params_get failed\00"
@.str.6 = [72 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_pvector_get failed\00"
@.str.7 = [41 x i8] c"ic_analyse_type_decl_instantiate_generic\00"
@.str.8 = [30 x i8] c"seriously kill these messages\00"
@.str.9 = [85 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_analyse_resolve_type_ref failed\00"
@.str.10 = [75 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_type_param_set failed\00"
@.str.11 = [88 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_mark_instantiated failed\00"
@.str.12 = [77 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_kludge_add_tdecl failed\00"
@.str.13 = [78 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_analyse_decl_type failed\00"
define %struct.ic_decl_type* @ic_analyse_type_decl_instantiate_generic(%struct.ic_kludge* %0, %struct.ic_decl_type* %1, %struct.ic_pvector* %2) {
%4 = alloca %struct.ic_decl_type*
%5 = alloca %struct.ic_kludge*
%6 = alloca %struct.ic_decl_type*
%7 = alloca %struct.ic_pvector*
%8 = alloca %struct.ic_decl_type*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.ic_type_param*
%12 = alloca %struct.ic_type_ref*
%13 = alloca %struct.ic_decl_type*
store %struct.ic_kludge* %0, %struct.ic_kludge** %5
store %struct.ic_decl_type* %1, %struct.ic_decl_type** %6
store %struct.ic_pvector* %2, %struct.ic_pvector** %7
store %struct.ic_decl_type* null, %struct.ic_decl_type** %8
store i32 0, i32* %9
store i32 0, i32* %10
store %struct.ic_type_param* null, %struct.ic_type_param** %11
store %struct.ic_type_ref* null, %struct.ic_type_ref** %12
store %struct.ic_decl_type* null, %struct.ic_decl_type** %13
%14 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%15 = icmp ne %struct.ic_kludge* %14, null
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
18: ; preds = %3
%19 = load %struct.ic_decl_type*, %struct.ic_decl_type** %6
%20 = icmp ne %struct.ic_decl_type* %19, null
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
23: ; preds = %18
%24 = load %struct.ic_pvector*, %struct.ic_pvector** %7
%25 = icmp ne %struct.ic_pvector* %24, null
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
28: ; preds = %23
%29 = load %struct.ic_decl_type*, %struct.ic_decl_type** %6
%30 = call i64 @ic_decl_type_is_instantiated(%struct.ic_decl_type* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load %struct.ic_decl_type*, %struct.ic_decl_type** %6
store %struct.ic_decl_type* %33, %struct.ic_decl_type** %4
br label %112
34: ; preds = %28
%35 = load %struct.ic_decl_type*, %struct.ic_decl_type** %6
%36 = call %struct.ic_decl_type* @ic_decl_type_deep_copy(%struct.ic_decl_type* %35)
store %struct.ic_decl_type* %36, %struct.ic_decl_type** %8
%37 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%38 = icmp ne %struct.ic_decl_type* %37, null
br i1 %38, label %41, label %39
39: ; preds = %34
%40 = call i32 @puts(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
41: ; preds = %34
%42 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%43 = call i32 @ic_decl_type_type_params_length(%struct.ic_decl_type* %42)
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = load %struct.ic_pvector*, %struct.ic_pvector** %7
%46 = call i32 @ic_pvector_length(%struct.ic_pvector* %45)
%47 = icmp ne i32 %44, %46
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 @puts(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.4, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
50: ; preds = %41
store i32 0, i32* %10
br label %51
51: ; preds = %87, %50
%52 = load i32, i32* %10
%53 = load i32, i32* %9
%54 = icmp ult i32 %52, %53
br i1 %54, label %55, label %90
55: ; preds = %51
%56 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%57 = load i32, i32* %10
%58 = call %struct.ic_type_param* @ic_decl_type_type_params_get(%struct.ic_decl_type* %56, i32 %57)
store %struct.ic_type_param* %58, %struct.ic_type_param** %11
%59 = load %struct.ic_type_param*, %struct.ic_type_param** %11
%60 = icmp ne %struct.ic_type_param* %59, null
br i1 %60, label %63, label %61
61: ; preds = %55
%62 = call i32 @puts(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
63: ; preds = %55
%64 = load %struct.ic_pvector*, %struct.ic_pvector** %7
%65 = load i32, i32* %10
%66 = call %struct.ic_type_ref* @ic_pvector_get(%struct.ic_pvector* %64, i32 %65)
store %struct.ic_type_ref* %66, %struct.ic_type_ref** %12
%67 = load %struct.ic_type_ref*, %struct.ic_type_ref** %12
%68 = icmp ne %struct.ic_type_ref* %67, null
br i1 %68, label %71, label %69
69: ; preds = %63
%70 = call i32 @puts(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.6, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
71: ; preds = %63
%72 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%73 = load %struct.ic_type_ref*, %struct.ic_type_ref** %12
%74 = call %struct.ic_decl_type* @ic_analyse_resolve_type_ref(%struct.ic_kludge* %72, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 0, %struct.ic_type_ref* %73)
store %struct.ic_decl_type* %74, %struct.ic_decl_type** %13
%75 = load %struct.ic_decl_type*, %struct.ic_decl_type** %13
%76 = icmp ne %struct.ic_decl_type* %75, null
br i1 %76, label %79, label %77
77: ; preds = %71
%78 = call i32 @puts(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.9, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
79: ; preds = %71
%80 = load %struct.ic_type_param*, %struct.ic_type_param** %11
%81 = load %struct.ic_decl_type*, %struct.ic_decl_type** %13
%82 = call i32 @ic_type_param_set(%struct.ic_type_param* %80, %struct.ic_decl_type* %81)
%83 = icmp ne i32 %82, 0
br i1 %83, label %86, label %84
84: ; preds = %79
%85 = call i32 @puts(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.10, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
86: ; preds = %79
br label %87
87: ; preds = %86
%88 = load i32, i32* %10
%89 = add i32 %88, 1
store i32 %89, i32* %10
br label %51
90: ; preds = %51
%91 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%92 = call i32 @ic_decl_type_mark_instantiated(%struct.ic_decl_type* %91)
%93 = icmp ne i32 %92, 0
br i1 %93, label %96, label %94
94: ; preds = %90
%95 = call i32 @puts(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.11, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
96: ; preds = %90
%97 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%98 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%99 = call i32 @ic_kludge_add_tdecl(%struct.ic_kludge* %97, %struct.ic_decl_type* %98)
%100 = icmp ne i32 %99, 0
br i1 %100, label %103, label %101
101: ; preds = %96
%102 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.12, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
103: ; preds = %96
%104 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%105 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
%106 = call i32 @ic_analyse_decl_type(%struct.ic_kludge* %104, %struct.ic_decl_type* %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %110, label %108
108: ; preds = %103
%109 = call i32 @puts(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.13, i64 0, i64 0))
store %struct.ic_decl_type* null, %struct.ic_decl_type** %4
br label %112
110: ; preds = %103
%111 = load %struct.ic_decl_type*, %struct.ic_decl_type** %8
store %struct.ic_decl_type* %111, %struct.ic_decl_type** %4
br label %112
112: ; preds = %110, %108, %101, %94, %84, %77, %69, %61, %48, %39, %32, %26, %21, %16
%113 = load %struct.ic_decl_type*, %struct.ic_decl_type** %4
ret %struct.ic_decl_type* %113
}

LLVM IR (-O2):
%struct.ic_kludge = type { i32 }
%struct.ic_decl_type = type { i32 }
%struct.ic_pvector = type { i32 }
%struct.ic_type_param = type { i32 }
%struct.ic_type_ref = type { i32 }
@.str = [58 x i8] c"ic_analyse_type_decl_instantiate_generic: kludge was null\00"
@.str.1 = [57 x i8] c"ic_analyse_type_decl_instantiate_generic: tdecl was null\00"
@.str.2 = [61 x i8] c"ic_analyse_type_decl_instantiate_generic: type_args was null\00"
@.str.3 = [80 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_deep_copy failed\00"
@.str.4 = [129 x i8] c"ic_analyse_type_decl_instantiate_generic: error: number of provided type arguments does not match number of expected type params\00"
@.str.5 = [86 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_type_params_get failed\00"
@.str.6 = [72 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_pvector_get failed\00"
@.str.7 = [41 x i8] c"ic_analyse_type_decl_instantiate_generic\00"
@.str.8 = [30 x i8] c"seriously kill these messages\00"
@.str.9 = [85 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_analyse_resolve_type_ref failed\00"
@.str.10 = [75 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_type_param_set failed\00"
@.str.11 = [88 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_decl_type_mark_instantiated failed\00"
@.str.12 = [77 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_kludge_add_tdecl failed\00"
@.str.13 = [78 x i8] c"ic_analyse_type_decl_instantiate_generic: call to ic_analyse_decl_type failed\00"
define %struct.ic_decl_type* @ic_analyse_type_decl_instantiate_generic(%struct.ic_kludge* %0, %struct.ic_decl_type* %1, %struct.ic_pvector* %2) {
%4 = icmp eq %struct.ic_kludge* %0, null
br i1 %4, label %46, label %5
5: ; preds = %3
%6 = icmp eq %struct.ic_decl_type* %1, null
br i1 %6, label %46, label %7
7: ; preds = %5
%8 = icmp eq %struct.ic_pvector* %2, null
br i1 %8, label %46, label %9
9: ; preds = %7
%10 = tail call i64 @ic_decl_type_is_instantiated(%struct.ic_decl_type* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %49
12: ; preds = %9
%13 = tail call %struct.ic_decl_type* @ic_decl_type_deep_copy(%struct.ic_decl_type* %1)
%14 = icmp eq %struct.ic_decl_type* %13, null
br i1 %14, label %46, label %15
15: ; preds = %12
%16 = tail call i32 @ic_decl_type_type_params_length(%struct.ic_decl_type* %13)
%17 = tail call i32 @ic_pvector_length(%struct.ic_pvector* %2)
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %46
19: ; preds = %15
%20 = icmp eq i32 %16, 0
br i1 %20, label %37, label %23
21: ; preds = %33
%22 = icmp eq i32 %36, %16
br i1 %22, label %37, label %23
23: ; preds = %19, %21
%24 = phi i32 [ %36, %21 ], [ 0, %19 ]
%25 = tail call %struct.ic_type_param* @ic_decl_type_type_params_get(%struct.ic_decl_type* %13, i32 %24)
%26 = icmp eq %struct.ic_type_param* %25, null
br i1 %26, label %46, label %27
27: ; preds = %23
%28 = tail call %struct.ic_type_ref* @ic_pvector_get(%struct.ic_pvector* %2, i32 %24)
%29 = icmp eq %struct.ic_type_ref* %28, null
br i1 %29, label %46, label %30
30: ; preds = %27
%31 = tail call %struct.ic_decl_type* @ic_analyse_resolve_type_ref(%struct.ic_kludge* %0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 0, %struct.ic_type_ref* %28)
%32 = icmp eq %struct.ic_decl_type* %31, null
br i1 %32, label %46, label %33
33: ; preds = %30
%34 = tail call i32 @ic_type_param_set(%struct.ic_type_param* %25, %struct.ic_decl_type* %31)
%35 = icmp eq i32 %34, 0
%36 = add nuw i32 %24, 1
br i1 %35, label %46, label %21
37: ; preds = %21, %19
%38 = tail call i32 @ic_decl_type_mark_instantiated(%struct.ic_decl_type* %13)
%39 = icmp eq i32 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %37
%41 = tail call i32 @ic_kludge_add_tdecl(%struct.ic_kludge* %0, %struct.ic_decl_type* %13)
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = tail call i32 @ic_analyse_decl_type(%struct.ic_kludge* %0, %struct.ic_decl_type* %13)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %33, %30, %27, %23, %43, %40, %37, %15, %12, %7, %5, %3
%47 = phi i8* [ getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([129 x i8], [129 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([88 x i8], [88 x i8]* @.str.11, i64 0, i64 0), %37 ], [ getelementptr inbounds ([77 x i8], [77 x i8]* @.str.12, i64 0, i64 0), %40 ], [ getelementptr inbounds ([78 x i8], [78 x i8]* @.str.13, i64 0, i64 0), %43 ], [ getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0), %23 ], [ getelementptr inbounds ([72 x i8], [72 x i8]* @.str.6, i64 0, i64 0), %27 ], [ getelementptr inbounds ([85 x i8], [85 x i8]* @.str.9, i64 0, i64 0), %30 ], [ getelementptr inbounds ([75 x i8], [75 x i8]* @.str.10, i64 0, i64 0), %33 ]
%48 = tail call i32 @puts(i8* dereferenceable(1) %47)
br label %49
49: ; preds = %46, %43, %9
%50 = phi %struct.ic_decl_type* [ %1, %9 ], [ %13, %43 ], [ null, %46 ]
ret %struct.ic_decl_type* %50
}