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

/* Variables and functions */
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char toupper(char);
char *line_strip(char *line) {
  char *rc;
  rc = line;
  if (strncmp(line, ">>", 2) == 0) {
    rc = line + 2;
    if (*rc == '?') {
      int i;
      char buffer[8];
      strncpy(buffer, rc + 1, 7);
      for (i = 0; i < 7; i++)
        buffer[i] = toupper(buffer[i]);
      if (strncmp(buffer, "SECTION", 7) == 0) {
        rc = rc + 7;
        while ((*rc != '\n') && (*rc != '\0'))
          rc++;
      }
    }
  } else if (strncmp(line, "+>", 2) == 0)
    rc = line + 2;
  return rc;
}


x86 assembly (clang, -O0):
<line_strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    124c <line_strip+0x11c>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1247 <line_strip+0x117>
lea    -0x1c(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    11cc <line_strip+0x9c>
movslq -0x14(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <toupper@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1c(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <line_strip+0x6c>
lea    -0x1c(%rbp),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1242 <line_strip+0x112>
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1d(%rbp)
je     121c <line_strip+0xec>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    122c <line_strip+0xfc>
jmp    123d <line_strip+0x10d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f7 <line_strip+0xc7>
jmp    1242 <line_strip+0x112>
jmp    1247 <line_strip+0x117>
jmp    127c <line_strip+0x14c>
mov    -0x8(%rbp),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1277 <line_strip+0x147>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    127c <line_strip+0x14c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_strip>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xebd(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1177 <line_strip+0x47>
lea    0xeb2(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1040 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%r14,%rcx,2),%rbx
jmp    1217 <line_strip+0xe7>
lea    0x2(%r14),%rbx
cmpb   $0x3f,0x2(%r14)
jne    1217 <line_strip+0xe7>
lea    0x3(%r14),%rsi
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0x7,%edx
call   1030 <strncpy@plt>
movsbl 0x8(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0x8(%rsp)
movsbl 0x9(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0x9(%rsp)
movsbl 0xa(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0xa(%rsp)
movsbl 0xb(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0xb(%rsp)
movsbl 0xc(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0xc(%rsp)
movsbl 0xd(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0xd(%rsp)
movsbl 0xe(%rsp),%edi
call   1050 <toupper@plt>
mov    %al,0xe(%rsp)
lea    0xdfe(%rip),%rsi
mov    %r15,%rdi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1224 <line_strip+0xf4>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0x9,%r14
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     1217 <line_strip+0xe7>
cmp    $0xa,%al
je     1217 <line_strip+0xe7>
add    $0x1,%rbx
jmp    1230 <line_strip+0x100>

LLVM IR (-O0):
@.str = [3 x i8] c">>\00"
@.str.1 = [8 x i8] c"SECTION\00"
@.str.2 = [3 x i8] c"+>\00"
define i8* @line_strip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [8 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %2
%8 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %62
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 2
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 63
br i1 %16, label %17, label %61
17: ; preds = %10
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i32 @strncpy(i8* %18, i8* %20, i32 7)
store i32 0, i32* %4
br label %22
22: ; preds = %34, %17
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 7
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call signext i8 @toupper(i8 signext %29)
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %32
store i8 %30, i8* %33
br label %34
34: ; preds = %25
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %22
37: ; preds = %22
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %60
41: ; preds = %37
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 7
store i8* %43, i8** %3
br label %44
44: ; preds = %56, %41
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 10
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = load i8*, i8** %3
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br label %54
54: ; preds = %49, %44
%55 = phi i1 [ false, %44 ], [ %53, %49 ]
br i1 %55, label %56, label %59
56: ; preds = %54
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %3
br label %44
59: ; preds = %54
br label %60
60: ; preds = %59, %37
br label %61
61: ; preds = %60, %10
br label %70
62: ; preds = %1
%63 = load i8*, i8** %2
%64 = call i64 @strncmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i8*, i8** %2
%68 = getelementptr inbounds i8, i8* %67, i64 2
store i8* %68, i8** %3
br label %69
69: ; preds = %66, %62
br label %70
70: ; preds = %69, %61
%71 = load i8*, i8** %3
ret i8* %71
}

LLVM IR (-O2):
@.str = [3 x i8] c">>\00"
@.str.1 = [8 x i8] c"SECTION\00"
@.str.2 = [3 x i8] c"+>\00"
define i8* @line_strip(i8* %0) {
%2 = alloca [8 x i8]
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %44
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 2
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 63
br i1 %8, label %9, label %49
9: ; preds = %5
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds i8, i8* %0, i64 3
%12 = call i32 @strncpy(i8* %10, i8* %11, i32 7)
%13 = load i8, i8* %10
%14 = call signext i8 @toupper(i8 signext %13)
store i8 %14, i8* %10
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
%16 = load i8, i8* %15
%17 = call signext i8 @toupper(i8 signext %16)
store i8 %17, i8* %15
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%19 = load i8, i8* %18
%20 = call signext i8 @toupper(i8 signext %19)
store i8 %20, i8* %18
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%22 = load i8, i8* %21
%23 = call signext i8 @toupper(i8 signext %22)
store i8 %23, i8* %21
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%25 = load i8, i8* %24
%26 = call signext i8 @toupper(i8 signext %25)
store i8 %26, i8* %24
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
%28 = load i8, i8* %27
%29 = call signext i8 @toupper(i8 signext %28)
store i8 %29, i8* %27
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
%31 = load i8, i8* %30
%32 = call signext i8 @toupper(i8 signext %31)
store i8 %32, i8* %30
%33 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %9
%36 = getelementptr inbounds i8, i8* %0, i64 9
br label %37
37: ; preds = %40, %35
%38 = phi i8* [ %36, %35 ], [ %41, %40 ]
%39 = load i8, i8* %38
switch i8 %39, label %40 [
i8 10, label %42
i8 0, label %42
]
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %38, i64 1
br label %37
42: ; preds = %37, %37, %9
%43 = phi i8* [ %6, %9 ], [ %38, %37 ], [ %38, %37 ]
br label %49
44: ; preds = %1
%45 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%46 = icmp eq i64 %45, 0
%47 = select i1 %46, i64 2, i64 0
%48 = getelementptr i8, i8* %0, i64 %47
br label %49
49: ; preds = %44, %5, %42
%50 = phi i8* [ %43, %42 ], [ %6, %5 ], [ %48, %44 ]
ret i8* %50
}