; ModuleID = 'c.C'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-unknown-freebsd8.1"

%0 = type { i8*, i8* }
%1 = type { i8*, i8*, i32, i8* }
%class.E = type { i8 }

@_ZTVN10__cxxabiv119__pointer_type_infoE = external global i8* ; <i8**> [#uses=1]
@_ZTSP1E = weak_odr constant [4 x i8] c"P1E\00"   ; <[4 x i8]*> [#uses=1]
@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* ; <i8**> [#uses=1]
@_ZTS1E = weak_odr constant [3 x i8] c"1E\00"     ; <[3 x i8]*> [#uses=1]
@_ZTI1E = weak_odr constant %0 { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv117__class_type_infoE, i32 2) to i8*), i8* getelementptr inbounds ([3 x i8]* @_ZTS1E, i32 0, i32 0) } ; <%0*> [#uses=1]
@_ZTIP1E = weak_odr constant %1 { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv119__pointer_type_infoE, i32 2) to i8*), i8* getelementptr inbounds ([4 x i8]* @_ZTSP1E, i32 0, i32 0), i32 0, i8* bitcast (%0* @_ZTI1E to i8*) } ; <%1*> [#uses=1]
@.str = private constant [14 x i8] c"caught e=%p!\0A\00" ; <[14 x i8]*> [#uses=1]
@str = internal constant [5 x i8] c"done\00"      ; <[5 x i8]*> [#uses=1]

define i32 @main() {
entry:
; call void @mytrace(i32 20)
  %exception = tail call i8* @__cxa_allocate_exception(i32 4) nounwind ; <i8*> [#uses=3]
; call void @mytrace(i32 22)
  %call = invoke noalias i8* @_Znwj(i32 1)
          to label %invoke.cont unwind label %lpad ; <i8*> [#uses=1]

invoke.cont:                                      ; preds = %entry
; call void @mytrace(i32 27)
  %0 = bitcast i8* %exception to %class.E**       ; <%class.E**> [#uses=1]
; call void @mytrace(i32 29)
  %1 = bitcast i8* %call to %class.E*             ; <%class.E*> [#uses=1]
; call void @mytrace(i32 31)
  store %class.E* %1, %class.E** %0
; call void @mytrace(i32 33)
  invoke void @__cxa_throw(i8* %exception, i8* bitcast (%1* @_ZTIP1E to i8*), i8* null)
          to label %unreachable unwind label %lpad1

lpad:                                             ; preds = %entry
; call void @mytrace(i32 38)
  %exn = tail call i8* @llvm.eh.exception() nounwind ; <i8*> [#uses=3]
; call void @mytrace(i32 40)
  %eh.selector = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (%1* @_ZTIP1E to i8*), i8* null) nounwind ; <i32> [#uses=1]
; call void @mytrace(i32 42)
  %2 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%1* @_ZTIP1E to i8*)) nounwind ; <i32> [#uses=1]
; call void @mytrace(i32 44)
  tail call void @__cxa_free_exception(i8* %exception) nounwind
; call void @mytrace(i32 46)
  %not. = icmp eq i32 %eh.selector, %2            ; <i1> [#uses=1]
; call void @mytrace(i32 48)
  br i1 %not., label %try.cont, label %eh.resume

eh.resume:                                        ; preds = %lpad
; call void @mytrace(i32 52)
  tail call void @_Unwind_Resume_or_Rethrow(i8* %exn) noreturn
; call void @mytrace(i32 54)
  unreachable

lpad1:                                            ; preds = %invoke.cont
; call void @mytrace(i32 58)
  %exn2 = tail call i8* @llvm.eh.exception() nounwind ; <i8*> [#uses=3]
; call void @mytrace(i32 60)
  %eh.selector3 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn2, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (%1* @_ZTIP1E to i8*), i8* null) nounwind ; <i32> [#uses=1]
; call void @mytrace(i32 62)
  %3 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%1* @_ZTIP1E to i8*)) nounwind ; <i32> [#uses=1]
; call void @mytrace(i32 64)
  %4 = icmp eq i32 %eh.selector3, %3              ; <i1> [#uses=1]
; call void @mytrace(i32 66)
  br i1 %4, label %try.cont, label %eh.resume5

eh.resume5:                                       ; preds = %lpad1
; call void @mytrace(i32 70)
  tail call void @_Unwind_Resume_or_Rethrow(i8* %exn2) noreturn
; call void @mytrace(i32 72)
  unreachable

try.cont:                                         ; preds = %lpad, %lpad1
  %exn.slot.0 = phi i8* [ %exn2, %lpad1 ], [ %exn, %lpad ] ; <i8*> [#uses=1]
; call void @mytrace(i32 77)
  %5 = tail call i8* @__cxa_begin_catch(i8* %exn.slot.0) nounwind ; <i8*> [#uses=1]
; call void @mytrace(i32 79)
  %call15 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0), i8* %5) ; <i32> [#uses=0]
; call void @mytrace(i32 81)
  tail call void @__cxa_end_catch() nounwind
; call void @mytrace(i32 83)
  %puts = tail call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @str, i32 0, i32 0)) ; <i32> [#uses=0]
; call void @mytrace(i32 85)
  ret i32 0

unreachable:                                      ; preds = %invoke.cont
; call void @mytrace(i32 89)
  unreachable
}

declare i8* @__cxa_allocate_exception(i32)

declare void @__cxa_free_exception(i8*)

declare noalias i8* @_Znwj(i32)

declare i8* @llvm.eh.exception() nounwind readonly

declare i32 @__gxx_personality_v0(...)

declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind

declare i32 @llvm.eh.typeid.for(i8*) nounwind

declare void @_Unwind_Resume_or_Rethrow(i8*)

declare void @__cxa_throw(i8*, i8*, i8*)

declare i8* @__cxa_begin_catch(i8*)

declare void @__cxa_end_catch()

declare i32 @printf(i8* nocapture, ...) nounwind

declare i32 @puts(i8* nocapture) nounwind

@.str_trace = private constant [14 x i8] c"TRACE num=%i\0A\00" ; <[14 x i8]*> [#uses=1]
declare i32 @printf(i8* nocapture, ...) nounwind

define void @mytrace(i32 %i) nounwind {
entry:
  %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str_trace, i32 0, i32 0), i32 %i) nounwind ; <i32> [#uses=0]
  ret void
}
