// Code generated by cmd/cgo; DO NOT EDIT.

//line /tmp/TestPointerChecks3981455612/src/ptrtest/cgo1.go:1:1
package main

/*
typedef struct s1 { int *p; } s1; void f1(s1 *ps) {}

typedef struct s2 { int *p; } s2; void f2(s2 *ps) {}

struct s3 { int i; int *p; }; void f3(int *p) {}

struct s4 { int i; int *p; }; void f4(int **p) {}

struct s5 { int *p1; int *p2; }; void f5(int **p) {}

void f6(void **p) {}

void f7(void **p) {}

void f8(void **p) {}

void f9(void **p) {}

void f10(void* p) {}

typedef void* PV11; void f11(PV11 p) {}

void f12(char** parg) {}

void f13(char*** parg) {}

#include <stdlib.h>
		    char **f14a() { return malloc(sizeof(char*)); }
		    void f14b(char **p) {}

#include <stdlib.h>
		    struct s15 { char *a[10]; };
		    struct s15 *f15() { return malloc(sizeof(struct s15)); }
		    void f15b(struct s15 *p) {}

#include <stdlib.h>
		    struct s16 { char *a[10]; };
		    struct s16 *f16() { return malloc(sizeof(struct s16)); }
		    void f16b(struct s16 *p) {}

#include <stdlib.h>
		    struct s17 { char *a[32769]; };
		    struct s17 *f17() { return malloc(sizeof(struct s17)); }
		    void f17b(struct s17 *p) {}

#include <stdlib.h>
		    struct s18 { char *a[32769]; };
		    struct s18 *f18() { return malloc(sizeof(struct s18)); }
		    void f18b(struct s18 *p) {}
		    void f18c(void *p) {}

#include <stdlib.h>
		    struct s19a { char *a[32769]; };
		    struct s19b { struct s19a f; };
		    struct s19b *f19() { return malloc(sizeof(struct s19b)); }
		    void f19b(struct s19b *p) {}

#include <stdlib.h>
		    struct s20a { char *a[32769]; };
		    struct s20b { struct s20a f; };
		    struct s20b *f20() { return malloc(sizeof(struct s20b)); }
		    void f20b(struct s20b *p) {}
		    void f20c(void *p) {}



#include <stddef.h>
		    typedef struct { const char *p; ptrdiff_t n; } gostring23;
		    gostring23 f23(gostring23 s) { return s; }

void f24(void *p) {}

#include <stddef.h>
		     typedef struct { const char *p; ptrdiff_t n; } gostring25;
		     extern gostring25 GoStr25();
		     void f25() { GoStr25(); }
#include <stdlib.h>
		    void f26(void* p) {}

#include <stdlib.h>
		    void f27(void* p) {}

typedef struct s28 { int *p; } s28; void f28(s28 *ps) {}

typedef union { char **p; unsigned long i; } u29; void f29(u29 *pu) {}

typedef union { unsigned long i; } u39; void f39(u39 *pu) {}

void f30() {}

#define US31 10

void f32(char** p) {}

void f33(void* p) {}

void f34(void* p, int r, void* s) {}

void f35(char **pc) {}

void f36(void *p) {}

// Nothing to declare.

// Nothing to declare.

struct S40i { int i; int* p; }; void f40(struct S40i* p) {}

*/
import _ "unsafe"

import "os"
import "unsafe"
import "strings"
import "runtime"
import "sync"
import "time"
import "bytes"
import "reflect"

func ptr1() {
func() { _cgoBase0 := /*line :125:6*/&_Ctype_s1 /*line :125:11*/{new(_Ctype_int /*line :125:21*/)}; _cgo0 := _cgoBase0; _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f1(_cgo0); }()
}

func ptr2() {
p := & /*line :129:7*/_Ctype_s2 /*line :129:11*/{new( /*line :129:16*/_Ctype_int /*line :129:21*/)}; func() { _cgo0 := /*line :129:30*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f2(_cgo0); }()
}

func ok1() {
p := & /*line :133:7*/_Ctype_struct_s3 /*line :133:18*/{i: 0, p: new( /*line :133:32*/_Ctype_int /*line :133:37*/)}; ( /*line :133:41*/_Cfunc_f3 /*line :133:44*/)(&p.i)
}

func ptrfield() {
p := & /*line :137:7*/_Ctype_struct_s4 /*line :137:18*/{i: 0, p: new( /*line :137:32*/_Ctype_int /*line :137:37*/)}; func() { _cgoBase0 := /*line :137:46*/&p.p; _cgo0 := _cgoBase0; _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f4(_cgo0); }()
}

func ptrfieldok() {
p := & /*line :141:7*/_Ctype_struct_s5 /*line :141:18*/{p1: nil, p2: new( /*line :141:36*/_Ctype_int /*line :141:41*/)}; func() { _cgoBase0 := /*line :141:50*/&p.p1; _cgo0 := _cgoBase0; _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f5(_cgo0); }()
}

func sliceok1() {
s := []unsafe.Pointer{nil}; func() { _cgoIndex0 := &/*line :145:35*/s; _cgo0 := /*line :145:34*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f6(_cgo0); }()
}

func sliceptr1() {
i := 0; s := []unsafe.Pointer{unsafe.Pointer(&i)}; func() { _cgoIndex0 := &/*line :149:58*/s; _cgo0 := /*line :149:57*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f7(_cgo0); }()
}

func sliceptr2() {
i := 0; s := []unsafe.Pointer{nil, unsafe.Pointer(&i)}; func() { _cgoIndex0 := &/*line :153:63*/s; _cgo0 := /*line :153:62*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f8(_cgo0); }()
}
type S9 struct { p *int; s []unsafe.Pointer }
func sliceok2() {
i := 0; p := &S9{p:&i, s:[]unsafe.Pointer{nil}}; func() { _cgoIndex0 := &/*line :157:56*/p.s; _cgo0 := /*line :157:55*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f9(_cgo0); }()
}
type S10 struct { p *int; a [4]byte }
func sliceok3() {
i := 0; p := &S10{p:&i}; s := p.a[:]; func() { _cgoIndex0 := &/*line :161:61*/s; _cgo0 := /*line :161:45*/unsafe.Pointer(&(*_cgoIndex0)[0]); _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f10(_cgo0); }()
}
type S11 struct { p *int; a [4]byte }
func sliceok4() {
i := 0; p := &S11{p:&i}; func() { _cgoIndex0 := &/*line :165:55*/p.a; _cgo0 := _Ctype_PV11 /*line :165:38*/(unsafe.Pointer(&(*_cgoIndex0)[0])); _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f11(_cgo0); }()
}
var hello12 = [...] /*line :167:20*/_Ctype_char /*line :167:26*/{'h', 'e', 'l', 'l', 'o'}
func varok() {
parg := [1]* /*line :169:13*/_Ctype_char /*line :169:19*/{&hello12[0]}; func() { _cgoIndex0 := &/*line :169:41*/parg; _cgo0 := /*line :169:40*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f12(_cgo0); }()
}
var hello13 = [...]* /*line :171:21*/_Ctype_char /*line :171:27*/{new( /*line :171:32*/_Ctype_char /*line :171:38*/)}
func var1() {
parg := [1]** /*line :173:14*/_Ctype_char /*line :173:20*/{&hello13[0]}; func() { _cgoIndex0 := &/*line :173:42*/parg; _cgo0 := /*line :173:41*/&(*_cgoIndex0)[0]; _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f13(_cgo0); }()
}

func barrier() {
p := ( /*line :177:6*/_Cfunc_f14a /*line :177:11*/)(); *p = new( /*line :177:25*/_Ctype_char /*line :177:31*/); func() { _cgo0 := /*line :177:41*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f14b(_cgo0); }()
}

func barrierstruct() {
p := ( /*line :181:6*/_Cfunc_f15 /*line :181:10*/)(); p.a = [10]* /*line :181:26*/_Ctype_char /*line :181:32*/{new( /*line :181:37*/_Ctype_char /*line :181:43*/)}; func() { _cgo0 := /*line :181:54*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f15b(_cgo0); }()
}

func barrierslice() {
p := ( /*line :185:6*/_Cfunc_f16 /*line :185:10*/)(); copy(p.a[:], []* /*line :185:31*/_Ctype_char /*line :185:37*/{new( /*line :185:42*/_Ctype_char /*line :185:48*/)}); func() { _cgo0 := /*line :185:60*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f16b(_cgo0); }()
}

func barriergcprogarray() {
p := ( /*line :189:6*/_Cfunc_f17 /*line :189:10*/)(); p.a = [32769]* /*line :189:29*/_Ctype_char /*line :189:35*/{new( /*line :189:40*/_Ctype_char /*line :189:46*/)}; func() { _cgo0 := /*line :189:57*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f17b(_cgo0); }()
}

func barriergcprogarrayheap() {
p := ( /*line :193:6*/_Cfunc_f18 /*line :193:10*/)(); n := &[32769]* /*line :193:29*/_Ctype_char /*line :193:35*/{new( /*line :193:40*/_Ctype_char /*line :193:46*/)}; p.a = *n; func() { _cgo0 := /*line :193:67*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f18b(_cgo0); }(); n[0] = nil; func() { _cgo0 := /*line :193:90*/unsafe.Pointer(n); _cgoCheckPointer(_cgo0, nil); _Cfunc_f18c(_cgo0); }()
}

func barriergcprogstruct() {
p := ( /*line :197:6*/_Cfunc_f19 /*line :197:10*/)(); p.f =  /*line :197:21*/_Ctype_struct_s19a /*line :197:34*/{[32769]* /*line :197:43*/_Ctype_char /*line :197:49*/{new( /*line :197:54*/_Ctype_char /*line :197:60*/)}}; func() { _cgo0 := /*line :197:72*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f19b(_cgo0); }()
}

func barriergcprogstructheap() {
p := ( /*line :201:6*/_Cfunc_f20 /*line :201:10*/)(); n := & /*line :201:21*/_Ctype_struct_s20a /*line :201:34*/{[32769]* /*line :201:43*/_Ctype_char /*line :201:49*/{new( /*line :201:54*/_Ctype_char /*line :201:60*/)}}; p.f = *n; func() { _cgo0 := /*line :201:82*/p; _cgoCheckPointer(_cgo0, nil); _Cfunc_f20b(_cgo0); }(); n.a[0] = nil; func() { _cgo0 := /*line :201:107*/unsafe.Pointer(n); _cgoCheckPointer(_cgo0, nil); _Cfunc_f20c(_cgo0); }()
}

func passstring() {
s := "a"; r := ( /*line :205:16*/_Cfunc_f23 /*line :205:20*/)(*(* /*line :205:25*/_Ctype_gostring23 /*line :205:37*/)(unsafe.Pointer(&s))); if *(*string)(unsafe.Pointer(&r)) != s { panic(r) }
}
type S24 struct { a [1]string }
func passstringslice() {
s := S24{a:[1]string{strings.Repeat("a", 2)}}; func() { _cgoIndex0 := &/*line :209:70*/s.a; _cgo0 := /*line :209:54*/unsafe.Pointer(&(*_cgoIndex0)[0]); _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f24(_cgo0); }()
}
type S26 struct { p *int; a [8*8]byte; u uintptr }
func ptrdata1() {
i := 0; p := &S26{u:uintptr(unsafe.Pointer(&i))}; q := (*S26)(( /*line :213:63*/_Cfunc__CMalloc /*line :213:70*/)( /*line :213:72*/_Ctype_size_t /*line :213:80*/(unsafe.Sizeof(*p)))); *q = *p; func() { _cgo0 := /*line :213:118*/unsafe.Pointer(q); _cgoCheckPointer(_cgo0, nil); _Cfunc_f26(_cgo0); }()
}
type S27 struct { p *int; a [32769*8]byte; q *int; u uintptr }
func ptrdata2() {
i := 0; p := S27{u:uintptr(unsafe.Pointer(&i))}; q := (*S27)(( /*line :217:62*/_Cfunc__CMalloc /*line :217:69*/)( /*line :217:71*/_Ctype_size_t /*line :217:79*/(unsafe.Sizeof(p)))); *q = p; func() { _cgo0 := /*line :217:115*/unsafe.Pointer(q); _cgoCheckPointer(_cgo0, nil); _Cfunc_f27(_cgo0); }()
}

func defer1() {
p := & /*line :221:7*/_Ctype_s28 /*line :221:12*/{}; defer func() func() { _cgo0 := /*line :221:28*/p; return func() { _cgoCheckPointer(_cgo0, nil); _Cfunc_f28(_cgo0); }}()(); p.p = new( /*line :221:42*/_Ctype_int /*line :221:47*/)
}

func union1() {
var b  /*line :225:7*/_Ctype_char /*line :225:13*/; p := &b; func() { _cgoBase0 := /*line :225:54*/&p; _cgo0 := /*line :225:30*/(*_Ctype_u29 /*line :225:37*/)(unsafe.Pointer(_cgoBase0)); _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f29(_cgo0); }()
}

func union2() {
var b  /*line :229:7*/_Ctype_char /*line :229:13*/; p := &b; ( /*line :229:24*/_Cfunc_f39 /*line :229:28*/)((* /*line :229:32*/_Ctype_u39 /*line :229:37*/)(unsafe.Pointer(&p)))
}

func preemptduringcall() {
var wg sync.WaitGroup; wg.Add(100); for i := 0; i < 100; i++ { go func(i int) { for j := 0; j < 100; j++ { ( /*line :233:108*/_Cfunc_f30 /*line :233:112*/)(); runtime.GOMAXPROCS(i) }; wg.Done() }(i) }; wg.Wait()
}

func deadline() {
r, _, _ := os.Pipe(); r.SetDeadline(time.Now().Add(( /*line :237:52*/_Ciconst_US31 /*line :237:57*/) * time.Microsecond))
}

func chanrecv() {
c := make(chan []* /*line :241:19*/_Ctype_char /*line :241:25*/, 2); c <- make([]* /*line :241:44*/_Ctype_char /*line :241:50*/, 1); go func() { time.Sleep(10 * time.Second); panic("received twice from chan") }(); func() { _cgoIndex0 := /*line :241:144*/(<-c); _cgo0 := /*line :241:143*/&_cgoIndex0[0]; _cgoCheckPointer(_cgo0, _cgoIndex0); _Cfunc_f32(_cgo0); }();
}
type S33 struct { p *int; a [8]byte; u uintptr }
func structfield() {
s := &S33{p: new(int)}; func() { _cgoBase0 := /*line :245:46*/&s.a; _cgo0 := /*line :245:31*/unsafe.Pointer(_cgoBase0); _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f33(_cgo0); }()
}
type S34 struct { a [8]byte; p *int; b int64; }
func structfield2() {
s := &S34{p: new(int)}; func() { _cgoBase0 := /*line :249:46*/&s.a; _cgo0 := /*line :249:31*/unsafe.Pointer(_cgoBase0); var _cgo1 _Ctype_int = /*line :249:53*/32; _cgoBase2 := /*line :249:72*/&s.b; _cgo2 := /*line :249:57*/unsafe.Pointer(_cgoBase2); _cgoCheckPointer(_cgoBase0, 0 == 0); _cgoCheckPointer(_cgoBase2, 0 == 0); _Cfunc_f34(_cgo0, _cgo1, _cgo2); }()
}
type S35a struct { s []* /*line :251:25*/_Ctype_char /*line :251:31*/ }; type S35b struct { ps *S35a }
func defer2() {
p := &S35b{&S35a{[]* /*line :253:21*/_Ctype_char /*line :253:27*/{nil}}}; defer func() func() { _cgoIndex0 := &/*line :253:49*/p.ps.s; _cgo0 := /*line :253:48*/&(*_cgoIndex0)[0]; return func() { _cgoCheckPointer(_cgo0, *_cgoIndex0); _Cfunc_f35(_cgo0); }}()(); p.ps = nil
}

func buffer() {
var b bytes.Buffer; b.WriteString("a"); func() { _cgoIndex0 := /*line :257:63*/b.Bytes(); _cgo0 := /*line :257:47*/unsafe.Pointer(&_cgoIndex0[0]); _cgoCheckPointer(_cgo0, _cgoIndex0); _Cfunc_f36(_cgo0); }()
}
func open37() { os.Open(os.Args[0]) }; var G37 [][]byte
func finalizer() {
for i := 0; i < 10000; i++ { G37 = append(G37, make([]byte, 4096)); if i % 100 == 0 { G37 = nil; open37() } }
}
type MyInt38 int; func (i MyInt38) Get() int { return int(i) }; type Getter38 interface { Get() int }
func structof() {
t := reflect.StructOf([]reflect.StructField{{Name: "MyInt38", Type: reflect.TypeOf(MyInt38(0)), Anonymous: true}}); v := reflect.New(t).Elem(); v.Interface().(Getter38).Get()
}
type S40 struct { p *int; a  /*line :267:29*/_Ctype_struct_S40i /*line :267:42*/ }
func structfieldcast() {
s := &S40{p: new(int)}; func() { _cgoBase0 := /*line :269:48*/&s.a; _cgo0 := /*line :269:31*/(*_Ctype_struct_S40i /*line :269:46*/)(_cgoBase0); _cgoCheckPointer(_cgoBase0, 0 == 0); _Cfunc_f40(_cgo0); }()
}
var funcs = map[string]func() {
	"ptr1": ptr1,
	"ptr2": ptr2,
	"ok1": ok1,
	"ptrfield": ptrfield,
	"ptrfieldok": ptrfieldok,
	"sliceok1": sliceok1,
	"sliceptr1": sliceptr1,
	"sliceptr2": sliceptr2,
	"sliceok2": sliceok2,
	"sliceok3": sliceok3,
	"sliceok4": sliceok4,
	"varok": varok,
	"var1": var1,
	"barrier": barrier,
	"barrierstruct": barrierstruct,
	"barrierslice": barrierslice,
	"barriergcprogarray": barriergcprogarray,
	"barriergcprogarrayheap": barriergcprogarrayheap,
	"barriergcprogstruct": barriergcprogstruct,
	"barriergcprogstructheap": barriergcprogstructheap,
	"export1": export1,
	"exportok": exportok,
	"passstring": passstring,
	"passstringslice": passstringslice,
	"retstring": retstring,
	"ptrdata1": ptrdata1,
	"ptrdata2": ptrdata2,
	"defer1": defer1,
	"union1": union1,
	"union2": union2,
	"preemptduringcall": preemptduringcall,
	"deadline": deadline,
	"chanrecv": chanrecv,
	"structfield": structfield,
	"structfield2": structfield2,
	"defer2": defer2,
	"buffer": buffer,
	"finalizer": finalizer,
	"structof": structof,
	"structfieldcast": structfieldcast,
}


func main() {
	for _, arg := range os.Args[1:] {
		f := funcs[arg]
		if f == nil {
			panic("missing func "+arg)
		}
		f()
	}
}

