#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strncmp(char *, char *, int);
void section(FILE *in, char *buf) {
  FILE *out;
  char name[128], *f, *t;
  for (t = name, f = buf + 9; *f == ' ' || *f == '\t'; f++)
    ;
  while (*f && !isspace(*f))
    *t++ = *f++;
  *t = '\0';
  strcat(name, ".tex");
  printf("cvs add %s\n", name);
  out = fopen(name, "wt");
  fputs("\n", out);
  fputs(buf, out);
  while (fgets(buf, 510, in) && strncmp(buf, "@section", 8))
    fputs(buf, out);
  fclose(out);
}


x86 assembly (clang, -O0):
<section>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0xb1(%rbp)
je     11e1 <section+0x61>
mov    -0xa8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    11f4 <section+0x74>
jmp    1210 <section+0x90>
jmp    11f9 <section+0x79>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    11b0 <section+0x30>
jmp    1215 <section+0x95>
mov    -0xa8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xb2(%rbp)
je     124d <section+0xcd>
mov    -0xa8(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xb2(%rbp)
mov    -0xb2(%rbp),%al
test   $0x1,%al
jne    1260 <section+0xe0>
jmp    1293 <section+0x113>
mov    -0xa8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xa8(%rbp)
mov    (%rax),%cl
mov    -0xb0(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xb0(%rbp)
mov    %cl,(%rax)
jmp    1215 <section+0x95>
mov    -0xb0(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xa0(%rbp),%rdi
lea    0xd55(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd47(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xd2a(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1fe,%esi
call   1080 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xb3(%rbp)
je     1340 <section+0x1c0>
mov    -0x10(%rbp),%rdi
lea    0xceb(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xb3(%rbp)
mov    -0xb3(%rbp),%al
test   $0x1,%al
jne    1353 <section+0x1d3>
jmp    1365 <section+0x1e5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
jmp    12f7 <section+0x177>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r13
mov    %rdi,%r14
lea    0x9(%rsi),%rbx
jmp    11b4 <section+0x24>
nopl   0x0(%rax)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x9,%al
je     11b0 <section+0x20>
cmp    $0x20,%al
je     11b0 <section+0x20>
test   %al,%al
jne    11c8 <section+0x38>
mov    %rsp,%rax
jmp    11f7 <section+0x67>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1070 <isspace@plt>
test   %eax,%eax
jne    11f3 <section+0x63>
movzbl (%rbx,%r15,1),%eax
mov    %al,(%rsp,%r15,1)
movzbl 0x1(%rbx,%r15,1),%eax
add    $0x1,%r15
test   %al,%al
jne    11d0 <section+0x40>
lea    (%rsp,%r15,1),%rax
movb   $0x0,(%rax)
lea    0xdff(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   10b0 <strcat@plt>
lea    0xdf2(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
lea    0xdef(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
mov    $0xa,%edi
mov    %rax,%rsi
call   1080 <fputc@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <fputs@plt>
mov    %r13,%rdi
mov    $0x1fe,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12a5 <section+0x115>
lea    0xdb3(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12a5 <section+0x115>
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <fputs@plt>
mov    %r13,%rdi
mov    $0x1fe,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    1270 <section+0xe0>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c".tex\00"
@.str.1 = [12 x i8] c"cvs add %s\0A\00"
@.str.2 = [3 x i8] c"wt\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"@section\00"
define void @section(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [128 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
store i8* %9, i8** %8
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 9
store i8* %11, i8** %7
br label %12
12: ; preds = %25, %2
%13 = load i8*, i8** %7
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8*, i8** %7
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 9
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ true, %12 ], [ %21, %17 ]
br i1 %23, label %24, label %28
24: ; preds = %22
br label %25
25: ; preds = %24
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
br label %12
28: ; preds = %22
br label %29
29: ; preds = %42, %28
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = load i8*, i8** %7
%36 = load i8, i8* %35
%37 = call i32 @isspace(i8 signext %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
br label %40
40: ; preds = %34, %29
%41 = phi i1 [ false, %29 ], [ %39, %34 ]
br i1 %41, label %42, label %48
42: ; preds = %40
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %7
%45 = load i8, i8* %43
%46 = load i8*, i8** %8
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %8
store i8 %45, i8* %46
br label %29
48: ; preds = %40
%49 = load i8*, i8** %8
store i8 0, i8* %49
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%53 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %55, i32** %5
%56 = load i32*, i32** %5
%57 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %56)
%58 = load i8*, i8** %4
%59 = load i32*, i32** %5
%60 = call i32 @fputs(i8* %58, i32* %59)
br label %61
61: ; preds = %72, %48
%62 = load i8*, i8** %4
%63 = load i32*, i32** %3
%64 = call i64 @fgets(i8* %62, i32 510, i32* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i8*, i8** %4
%68 = call i64 @strncmp(i8* %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%69 = icmp ne i64 %68, 0
br label %70
70: ; preds = %66, %61
%71 = phi i1 [ false, %61 ], [ %69, %66 ]
br i1 %71, label %72, label %76
72: ; preds = %70
%73 = load i8*, i8** %4
%74 = load i32*, i32** %5
%75 = call i32 @fputs(i8* %73, i32* %74)
br label %61
76: ; preds = %70
%77 = load i32*, i32** %5
%78 = call i32 @fclose(i32* %77)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".tex\00"
@.str.1 = [12 x i8] c"cvs add %s\0A\00"
@.str.2 = [3 x i8] c"wt\00"
@.str.4 = [9 x i8] c"@section\00"
define void @section(i32* nocapture %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8, i8* %1, i64 9
br label %6
6: ; preds = %9, %2
%7 = phi i8* [ %5, %2 ], [ %10, %9 ]
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 32, label %9
i8 9, label %9
i8 0, label %23
]
9: ; preds = %6, %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
11: ; preds = %6, %17
%12 = phi i8* [ %20, %17 ], [ %4, %6 ]
%13 = phi i8* [ %18, %17 ], [ %7, %6 ]
%14 = phi i8 [ %21, %17 ], [ %8, %6 ]
%15 = tail call i32 @isspace(i8 signext %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = load i8, i8* %13
%20 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %19, i8* %12
%21 = load i8, i8* %18
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %11
23: ; preds = %6, %11, %17
%24 = phi i8* [ %20, %17 ], [ %12, %11 ], [ %4, %6 ]
store i8 0, i8* %24
%25 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%27 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @fputc(i32 10, i32* %27)
%29 = call i32 @fputs(i8* %1, i32* %27)
%30 = call i64 @fgets(i8* %1, i32 510, i32* %0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %23, %35
%33 = call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = call i32 @fputs(i8* %1, i32* %27)
%37 = call i64 @fgets(i8* %1, i32 510, i32* %0)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %32
39: ; preds = %32, %35, %23
%40 = call i32 @fclose(i32* %27)
ret void
}