; ModuleID = 'LFortran'
source_filename = "LFortran"
target datalayout = "..."

%xx.base_class = type <{ i32 (...)**, %xx.base* }>
%xx.base = type { i32 }
%string_descriptor = type <{ i8*, i64 }>

@_Name_base = private unnamed_addr constant [5 x i8] c"base\00", align 1
@_Type_Info_base = linkonce_odr unnamed_addr constant { i8*, i8*, i8* } { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @_Name_base, i32 0, i32 0), i8* inttoptr (i64 4 to i8*), i8* null }, align 8
@_VTable_base = linkonce_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_Type_Info_base to i8*), i8* bitcast (void (i8*, i8*)* @_copy_xx_base to i8*), i8* bitcast (void (i8**)* @_allocate_struct_xx_base to i8*), i8* bitcast (void (%xx.base_class*)* @__module_xx_show_x to i8*)] }, align 8
@0 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@serialization_info = private unnamed_addr constant [3 x i8] c"I4\00", align 1
@1 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1
@"ERROR STOP" = private unnamed_addr constant [11 x i8] c"ERROR STOP\00", align 1
@2 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@3 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1

define void @__module_xx_show_x(%xx.base_class* %this) {
.entry:
  %0 = getelementptr %xx.base_class, %xx.base_class* %this, i32 0, i32 1
  %1 = load %xx.base*, %xx.base** %0, align 8
  %2 = getelementptr %xx.base, %xx.base* %1, i32 0, i32 0
  store i32 12, i32* %2, align 4
  br label %return

return:                                           ; preds = %.entry
  br label %FINALIZE_SYMTABLE_show_x

FINALIZE_SYMTABLE_show_x:                         ; preds = %return
  ret void
}

define i32 @main(i32 %0, i8** %1) {
.entry:
  %2 = call i8* @_lfortran_get_default_allocator()
  %3 = alloca %xx.base_class, align 8
  call void @_lpython_call_initial_functions(i32 %0, i8** %1)
  %b = alloca %xx.base, align 8
  %4 = getelementptr %xx.base, %xx.base* %b, i32 0, i32 0
  %5 = getelementptr %xx.base, %xx.base* %b, i32 0, i32 0
  store i32 10, i32* %5, align 4
  %6 = getelementptr %xx.base_class, %xx.base_class* %3, i32 0, i32 0
  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_VTable_base, i32 0, i32 0, i32 2) to i32 (...)**), i32 (...)*** %6, align 8
  %7 = getelementptr %xx.base_class, %xx.base_class* %3, i32 0, i32 1
  store %xx.base* %b, %xx.base** %7, align 8
  call void @__module_xx_show_x(%xx.base_class* %3)
  %8 = alloca i64, align 8
  %9 = getelementptr %xx.base, %xx.base* %b, i32 0, i32 0
  %10 = load i32, i32* %9, align 4
  %11 = alloca i32, align 4
  store i32 %10, i32* %11, align 4
  %12 = call i8* (i8*, i8*, i64, i8*, i64*, i32, i32, i32, i32, i32, ...) @_lcompilers_string_format_fortran(i8* %2, i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info, i32 0, i32 0), i64* %8, i32 0, i32 0, i32 0, i32 0, i32 0, i32* %11)
  %13 = load i64, i64* %8, align 8
  %stringFormat_desc = alloca %string_descriptor, align 8
  %14 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0
  store i8* %12, i8** %14, align 8
  %15 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1
  store i64 %13, i64* %15, align 8
  %16 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0
  %17 = load i8*, i8** %16, align 8
  %18 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1
  %19 = load i64, i64* %18, align 8
  %20 = trunc i64 %19 to i32
  call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %17, i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1)
  %21 = icmp eq i8* %12, null
  br i1 %21, label %free_done, label %free_nonnull

free_nonnull:                                     ; preds = %.entry
  call void @_lfortran_free_alloc(i8* %2, i8* %12)
  br label %free_done

free_done:                                        ; preds = %free_nonnull, %.entry
  %22 = getelementptr %xx.base, %xx.base* %b, i32 0, i32 0
  %23 = load i32, i32* %22, align 4
  %24 = icmp ne i32 %23, 12
  br i1 %24, label %then, label %else

then:                                             ; preds = %free_done
  call void (i8*, ...) @_lcompilers_print_error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @"ERROR STOP", i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0))
  call void @_lfortran_internal_alloc_finalize()
  call void @exit(i32 1)
  br label %ifcont

else:                                             ; preds = %free_done
  br label %ifcont

ifcont:                                           ; preds = %else, %then
  br label %return

return:                                           ; preds = %ifcont
  br label %FINALIZE_SYMTABLE_main

FINALIZE_SYMTABLE_main:                           ; preds = %return
  call void @_lfortran_internal_alloc_finalize()
  ret i32 0
}

declare void @_lpython_call_initial_functions(i32, i8**)

define linkonce_odr void @_copy_xx_base(i8* %0, i8* %1) {
entry:
  %2 = bitcast i8* %0 to %xx.base*
  %3 = bitcast i8* %1 to %xx.base*
  %4 = getelementptr %xx.base, %xx.base* %2, i32 0, i32 0
  %5 = load i32, i32* %4, align 4
  %6 = getelementptr %xx.base, %xx.base* %3, i32 0, i32 0
  br i1 true, label %then, label %else

then:                                             ; preds = %entry
  store i32 %5, i32* %6, align 4
  br label %ifcont

else:                                             ; preds = %entry
  br label %ifcont

ifcont:                                           ; preds = %else, %then
  ret void
}

define linkonce_odr void @_allocate_struct_xx_base(i8** %0) {
entry:
  %1 = call i8* @_lfortran_get_default_allocator()
  %2 = call i8* @_lfortran_malloc_alloc(i8* %1, i64 16)
  call void @llvm.memset.p0i8.i32(i8* %2, i8 0, i32 16, i1 false)
  store i8* %2, i8** %0, align 8
  %3 = load i8*, i8** %0, align 8
  %4 = bitcast i8* %3 to %xx.base_class*
  %5 = bitcast %xx.base_class* %4 to i32 (...)***
  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_VTable_base, i32 0, i32 0, i32 2) to i32 (...)**), i32 (...)*** %5, align 8
  %6 = getelementptr %xx.base_class, %xx.base_class* %4, i32 0, i32 1
  %7 = call i8* @_lfortran_get_default_allocator()
  %8 = call i8* @_lfortran_malloc_alloc(i8* %7, i64 4)
  call void @llvm.memset.p0i8.i32(i8* %8, i8 0, i32 4, i1 false)
  %9 = bitcast i8* %8 to %xx.base*
  store %xx.base* %9, %xx.base** %6, align 8
  %10 = getelementptr %xx.base, %xx.base* %9, i32 0, i32 0
  ret void
}

declare i8* @_lfortran_malloc_alloc(i8*, i64)

declare i8* @_lfortran_get_default_allocator()

; Function Attrs: argmemonly nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) #0

declare i8* @_lcompilers_string_format_fortran(i8*, i8*, i64, i8*, i64*, i32, i32, i32, i32, i32, ...)

declare void @_lfortran_printf(i8*, i8*, i32, i8*, i32)

declare void @_lfortran_free_alloc(i8*, i8*)

declare void @_lcompilers_print_error(i8*, ...)

declare void @_lfortran_internal_alloc_finalize()

declare void @exit(i32)

attributes #0 = { argmemonly nounwind willreturn writeonly }
