#! /usr/bin/python
import sys, os
outfile, bf, tc, outname = open("out.c","w"), open(sys.argv[1],"r").read(), 1, "a.out" if len(sys.argv)<3 else sys.argv[2]
outfile.write("#include <stdio.h>\nvoid main(){\n\tchar array[30000];\n char *ptr = array;\n\tint i = 0;\n\tfor(i=0;i<30000;i++)\n\t\tarray[i]=0;")
for char in list(bf):
if char in list("+-<>.,[]"): outfile.write("\n"+tc*"\t"+{"+":"++*ptr;", "-":"--*ptr;", "<":"--ptr;", ">":"++ptr;", ".":"putchar(*ptr);", ",":"*ptr = getchar()", "[":"while(*ptr){","]":"}"}[char])
if char in list("]["): tc= tc+1 if char=="[" else tc-1
outfile.write("\n}")
outfile.close()
os.system("gcc out.c -o "+outname)