#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strtok(char *, char *);
void process_mb(FILE *in) {
  char buf[512];
  FILE *aux_out = NULL;
  while (fgets(buf, sizeof(buf), in) != NULL) {
    char *p;
    for (p = buf; *p == ' ' || *p == '\t' || *p == '%'; ++p)
      ;
    if (p[0] == '@' && p[1] == 'o') {
      if (aux_out) {
        fclose(aux_out);
        aux_out = NULL;
      }
      p = strtok(p, " \t\r\n");
      p = strtok(NULL, " \t\r\n");
      if (p && (aux_out = fopen(p, "w")) == NULL) {
        fprintf(stderr, "Could not open %s for output\n", p);
        exit(-1);
      }
    } else if (aux_out) {
      fputs(buf, aux_out);
    }
  }
  if (aux_out)
    fclose(aux_out);
}


x86 assembly (clang, -O0):
<process_mb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x218(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1337 <process_mb+0x1c7>
lea    -0x210(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x220(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x221(%rbp)
je     1203 <process_mb+0x93>
mov    -0x220(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x221(%rbp)
je     1203 <process_mb+0x93>
mov    -0x220(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
sete   %al
mov    %al,-0x221(%rbp)
mov    -0x221(%rbp),%al
test   $0x1,%al
jne    1216 <process_mb+0xa6>
jmp    1232 <process_mb+0xc2>
jmp    121b <process_mb+0xab>
mov    -0x220(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x220(%rbp)
jmp    11b7 <process_mb+0x47>
mov    -0x220(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    130c <process_mb+0x19c>
mov    -0x220(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    130c <process_mb+0x19c>
cmpq   $0x0,-0x218(%rbp)
je     127e <process_mb+0x10e>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x218(%rbp)
mov    -0x220(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x220(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd5d(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x220(%rbp)
je     1307 <process_mb+0x197>
mov    -0x220(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
jne    1307 <process_mb+0x197>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
mov    -0x220(%rbp),%rdx
lea    0xd0f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    1332 <process_mb+0x1c2>
cmpq   $0x0,-0x218(%rbp)
je     132d <process_mb+0x1bd>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rsi
call   1040 <fputs@plt>
jmp    1332 <process_mb+0x1c2>
jmp    118a <process_mb+0x1a>
cmpq   $0x0,-0x218(%rbp)
je     1351 <process_mb+0x1e1>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_mb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%r14
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1294 <process_mb+0x124>
xor    %ebx,%ebx
lea    0xe57(%rip),%r15
lea    0xe55(%rip),%r12
jmp    11ed <process_mb+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %rbx,%rbx
je     1280 <process_mb+0x110>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r13,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1287 <process_mb+0x117>
mov    %r13,%rbp
jmp    1208 <process_mb+0x98>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x25,%al
jne    1220 <process_mb+0xb0>
add    $0x1,%rbp
movzbl 0x0(%rbp),%eax
cmp    $0x24,%al
jg     1200 <process_mb+0x90>
cmp    $0x9,%al
je     1204 <process_mb+0x94>
cmp    $0x20,%al
je     1204 <process_mb+0x94>
jmp    11c0 <process_mb+0x50>
nopw   0x0(%rax,%rax,1)
cmp    $0x40,%al
jne    11c0 <process_mb+0x50>
cmpb   $0x6f,0x1(%rbp)
jne    11c0 <process_mb+0x50>
test   %rbx,%rbx
je     1237 <process_mb+0xc7>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    $0x0,%ebx
test   %rax,%rax
je     11d4 <process_mb+0x64>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d4 <process_mb+0x64>
jmp    12a6 <process_mb+0x136>
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
jmp    11d4 <process_mb+0x64>
test   %rbx,%rbx
je     1294 <process_mb+0x124>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    %rbp,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Could not open %s for output\0A\00"
define void @process_mb(i32* %0) {
%2 = alloca i32*
%3 = alloca [512 x i8]
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %2
store i32* null, i32** %4
br label %6
6: ; preds = %76, %1
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = call i32* @fgets(i8* %7, i32 512, i32* %8)
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %77
11: ; preds = %6
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
store i8* %12, i8** %5
br label %13
13: ; preds = %31, %11
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 9
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 37
br label %28
28: ; preds = %23, %18, %13
%29 = phi i1 [ true, %18 ], [ true, %13 ], [ %27, %23 ]
br i1 %29, label %30, label %34
30: ; preds = %28
br label %31
31: ; preds = %30
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %13
34: ; preds = %28
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 64
br i1 %39, label %40, label %68
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 111
br i1 %45, label %46, label %68
46: ; preds = %40
%47 = load i32*, i32** %4
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32*, i32** %4
%51 = call i32 @fclose(i32* %50)
store i32* null, i32** %4
br label %52
52: ; preds = %49, %46
%53 = load i8*, i8** %5
%54 = call i8* @strtok(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %54, i8** %5
%55 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %55, i8** %5
%56 = load i8*, i8** %5
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %67
58: ; preds = %52
%59 = load i8*, i8** %5
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %60, i32** %4
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %5
%65 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %58, %52
br label %76
68: ; preds = %40, %34
%69 = load i32*, i32** %4
%70 = icmp ne i32* %69, null
br i1 %70, label %71, label %75
71: ; preds = %68
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%73 = load i32*, i32** %4
%74 = call i32 @fputs(i8* %72, i32* %73)
br label %75
75: ; preds = %71, %68
br label %76
76: ; preds = %75, %67
br label %6
77: ; preds = %6
%78 = load i32*, i32** %4
%79 = icmp ne i32* %78, null
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = load i32*, i32** %4
%82 = call i32 @fclose(i32* %81)
br label %83
83: ; preds = %80, %77
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Could not open %s for output\0A\00"
define void @process_mb(i32* nocapture %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = call i32* @fgets(i8* %3, i32 512, i32* %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %44, label %6
6: ; preds = %1, %36
%7 = phi i32* [ %37, %36 ], [ null, %1 ]
br label %8
8: ; preds = %6, %11
%9 = phi i8* [ %12, %11 ], [ %3, %6 ]
%10 = load i8, i8* %9
switch i8 %10, label %32 [
i8 32, label %11
i8 9, label %11
i8 37, label %11
i8 64, label %13
]
11: ; preds = %8, %8, %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 111
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = icmp eq i32* %7, null
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = call i32 @fclose(i32* %7)
br label %21
21: ; preds = %19, %17
%22 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %36, label %25
25: ; preds = %21
%26 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %8, %13
%33 = icmp eq i32* %7, null
br i1 %33, label %36, label %34
34: ; preds = %32
%35 = call i32 @fputs(i8* %3, i32* %7)
br label %36
36: ; preds = %32, %34, %21, %25
%37 = phi i32* [ %26, %25 ], [ null, %21 ], [ %7, %34 ], [ null, %32 ]
%38 = call i32* @fgets(i8* %3, i32 512, i32* %0)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %6
40: ; preds = %36
%41 = icmp eq i32* %37, null
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = call i32 @fclose(i32* %37)
br label %44
44: ; preds = %1, %42, %40
ret void
}