// AUTO-GENERATED by autogen.sh; DO NOT EDIT

#include "runtime.h"
#include "arch.h"
#include "malloc.h"
#include "go-string.h"
#define charntorune(pv, str, len) __go_get_rune(str, len, pv)

#line 13 "../../../gcc-5.1.0/libgo/runtime/string.goc"
const String runtime_emptystring; 
#line 15 "../../../gcc-5.1.0/libgo/runtime/string.goc"
intgo 
runtime_findnull ( const byte *s ) 
{ 
if ( s == nil ) 
return 0; 
return __builtin_strlen ( ( const char* ) s ) ; 
} 
#line 23 "../../../gcc-5.1.0/libgo/runtime/string.goc"
intgo 
runtime_findnullw ( const uint16 *s ) 
{ 
intgo l; 
#line 28 "../../../gcc-5.1.0/libgo/runtime/string.goc"
if ( s == nil ) 
return 0; 
for ( l=0; s[l]!=0; l++ ) 
; 
return l; 
} 
#line 35 "../../../gcc-5.1.0/libgo/runtime/string.goc"
static String 
gostringsize ( intgo l , byte** pmem ) 
{ 
String s; 
byte *mem; 
#line 41 "../../../gcc-5.1.0/libgo/runtime/string.goc"
if ( l == 0 ) { 
*pmem = nil; 
return runtime_emptystring; 
} 
mem = runtime_mallocgc ( l , 0 , FlagNoScan|FlagNoZero ) ; 
s.str = mem; 
s.len = l; 
*pmem = mem; 
return s; 
} 
#line 52 "../../../gcc-5.1.0/libgo/runtime/string.goc"
String 
runtime_gostring ( const byte *str ) 
{ 
intgo l; 
String s; 
byte *mem; 
#line 59 "../../../gcc-5.1.0/libgo/runtime/string.goc"
l = runtime_findnull ( str ) ; 
s = gostringsize ( l , &mem ) ; 
runtime_memmove ( mem , str , l ) ; 
return s; 
} 
#line 65 "../../../gcc-5.1.0/libgo/runtime/string.goc"
String 
runtime_gostringnocopy ( const byte *str ) 
{ 
String s; 
#line 70 "../../../gcc-5.1.0/libgo/runtime/string.goc"
s.str = str; 
s.len = runtime_findnull ( str ) ; 
return s; 
} 
String runtime_cstringToGo(byte* str) __asm__ (GOSYM_PREFIX "runtime.cstringToGo");
String runtime_cstringToGo(byte* str)
{
  String s;
#line 75 "../../../gcc-5.1.0/libgo/runtime/string.goc"

	s = runtime_gostringnocopy(str);
return s;
}

#line 79 "../../../gcc-5.1.0/libgo/runtime/string.goc"
enum 
{ 
Runeself = 0x80 , 
} ; 
intgo runtime_stringiter(String s, intgo k) __asm__ (GOSYM_PREFIX "runtime.stringiter");
intgo runtime_stringiter(String s, intgo k)
{
  intgo retk;
#line 84 "../../../gcc-5.1.0/libgo/runtime/string.goc"

	int32 l;

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		goto out;
	}

	l = s.str[k];
	if(l < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + charntorune(&l, s.str+k, s.len-k);

out:
return retk;
}
struct runtime_stringiter2_ret {
  intgo retk;
  int32 retv;
};
struct runtime_stringiter2_ret runtime_stringiter2(String s, intgo k) __asm__ (GOSYM_PREFIX "runtime.stringiter2");
struct runtime_stringiter2_ret runtime_stringiter2(String s, intgo k)
{
  intgo retk;
  int32 retv;
#line 105 "../../../gcc-5.1.0/libgo/runtime/string.goc"

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		retv = 0;
		goto out;
	}

	retv = s.str[k];
	if(retv < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + charntorune(&retv, s.str+k, s.len-k);

out:
  {
    struct runtime_stringiter2_ret __ret;
    __ret.retk = retk;
    __ret.retv = retv;
    return __ret;
  }
}
