Convert Brainfuck to a Non-Golfing Language
K, 143 129 113 bytes

1!"}int a[99];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();if(*p&lt;0)*p=0;";"putchar(*p);";"while(*p){";"}";"")"&gt;&lt;+-,.[]"?x}'


This is an extremely straightforward approach which generates C source code by emitting a preamble, a C snippet for each BF command and then a postscript. Non-BF characters are translated into empty strings in the concatenated output.

The translation into C is as follows:


preamble: int a[99];int*p=a;main(){
&gt;: p++;
&lt;: p--;
+: *p++;
-: *p--;
,: *p=getchar();if(*p&lt;0)*p=0;
.: putchar(*p);
[: while(*p){
]: }
postscript: }


I suspect that there is room for improvement here by using more mangled abuses of C or compressing the C fragments.

The K part of the program by itself would look like the following, where c is the C translations of each BF instruction and p is the preamble/postscript:

1!p,,/{c"&gt;&lt;+-,.[]"?x}'


Using the venerable BF string reverser program &gt;,[&gt;,]&lt;[.&lt;] as my test case I generate code which looks like the following after a bit of whitespace for readability:

int a[99];
int*p=a;

main(){
    p++;
    *p=getchar();if(*p&lt;0)*p=0;
    while(*p){
        p++;
        *p=getchar();if(*p&lt;0)*p=0;
    }
    p--;
    while(*p){
        putchar(*p);
        p--;
    }
}


edit:

A few tweaks. Firstly, more compliant tape declaration as suggested by alexander-brett. The int part can be left off:

int a[99]; -> a[1&lt;&lt;15]; (-1 byte)

Also, it seems that EOF behavior in BF can return 0, -1 or cause no change as a result of ,. EOF=-1 seems to be what other solutions are going with, so for the sake of uniformity I will do the same:

*p=getchar();if(*p&lt;0)*p=0; -> *p=getchar(); (-13 bytes)

Note that this means my string reverser program will choke if you simply cat it a file ending in EOF(!), but as above it seems to be fair.

The new complete 129 byte solution:

1!"}a[1&lt;&lt;15];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();";"putchar(*p);";"while(*p){";"}";"")"&gt;&lt;+-,.[]"?x}'


edit 2, much, much later:

I randomly stumbled upon this old answer and, being older and wiser, realized there are several ways to make this shorter:


exploit the fact that it's completely syntactically valid C to include semicolons after every fragment instead of just those who need them, and thus remove them from the lookup table entries.
use the k5/k6 or oK dialects, which have overloads for \ and / which split a string apart on a character or join a list of strings with a character, respectively, to use a more compact representation of the lookup table and accomplish the above.
take advantage of the fact that find (dyadic ?) in the above dialects naturally conforms to a listy right argument, and thus does not need an explicit lambda + each


The one downside is that in these dialects there is no "rotate" primitive, so we have to add the "}" suffix in a less elegant manner. The overall structure of our solution:

1!     p, ,/{c"&gt;&lt;+-,.[]"?x}'   / old
,[;"}"]p,";"/c"&gt;&lt;+-,.[]"?      / new


The complete (and now totally points-free!) solution:

,[;"}"]"a[1&lt;&lt;15];int*p=a;main(){",";"/("|"\"p++|p--|*p++|*p--|*p=getchar()|putchar(*p)|while(*p){|}|")"&gt;&lt;+-,.[]"?


Which shaves us down to 113 bytes.