#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 */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *qfits_getcomment(const char *line) {
  static char comment[81];
  int i;
  int from, to;
  int inq;
  if (line == NULL) {
    return NULL;
  }
  if (!strncmp(line, "END ", 4))
    return NULL;
  if (!strncmp(line, "HISTORY ", 8))
    return NULL;
  if (!strncmp(line, "COMMENT ", 8))
    return NULL;
  if (!strncmp(line, "        ", 8))
    return NULL;
  memset(comment, 0, 81);
  i = 0;
  while (line[i] != '=' && i < 80)
    i++;
  if (i >= 80) {
    return NULL;
  }
  i++;
  inq = 0;
  while (i < 80) {
    if (line[i] == '\'')
      inq = !inq;
    if (line[i] == '/')
      if (!inq)
        break;
    i++;
  }
  if (i >= 80) {
    return NULL;
  }
  i++;
  while (line[i] == ' ')
    i++;
  from = i;
  to = 79;
  while (line[to] == ' ')
    to--;
  if (to < from) {
    return NULL;
  }
  strncpy(comment, line + from, to - from + 1);
  comment[to - from + 1] = (char)0;
  return comment;
}


x86 assembly (clang, -O0):
<qfits_getcomment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <qfits_getcomment+0x24>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    117f <qfits_getcomment+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11aa <qfits_getcomment+0x7a>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11d5 <qfits_getcomment+0xa5>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1200 <qfits_getcomment+0xd0>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
lea    0x2e49(%rip),%rdi
xor    %esi,%esi
mov    $0x51,%edx
call   1050 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x3d,%ecx
mov    %al,-0x21(%rbp)
je     123e <qfits_getcomment+0x10e>
cmpl   $0x50,-0x14(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    124e <qfits_getcomment+0x11e>
jmp    125c <qfits_getcomment+0x12c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121a <qfits_getcomment+0xea>
cmpl   $0x50,-0x14(%rbp)
jl     1273 <qfits_getcomment+0x143>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    12ea <qfits_getcomment+0x1ba>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
jne    12b3 <qfits_getcomment+0x183>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    12dc <qfits_getcomment+0x1ac>
cmpl   $0x0,-0x20(%rbp)
jne    12d7 <qfits_getcomment+0x1a7>
jmp    12ea <qfits_getcomment+0x1ba>
jmp    12dc <qfits_getcomment+0x1ac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1283 <qfits_getcomment+0x153>
cmpl   $0x50,-0x14(%rbp)
jl     1301 <qfits_getcomment+0x1d1>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    132d <qfits_getcomment+0x1fd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    130a <qfits_getcomment+0x1da>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x4f,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    135d <qfits_getcomment+0x22d>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    133a <qfits_getcomment+0x20a>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1376 <qfits_getcomment+0x246>
movq   $0x0,-0x8(%rbp)
jmp    13b8 <qfits_getcomment+0x288>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
sub    -0x18(%rbp),%edx
add    $0x1,%edx
lea    0x2cbf(%rip),%rdi
call   1030 <strncpy@plt>
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ca7(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2c9c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qfits_getcomment>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1254 <qfits_getcomment+0x124>
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1254 <qfits_getcomment+0x124>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1254 <qfits_getcomment+0x124>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1254 <qfits_getcomment+0x124>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1254 <qfits_getcomment+0x124>
lea    0x2e9c(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x51,%edx
call   1050 <memset@plt>
mov    $0x52,%ebp
mov    $0xffffffffffffffff,%rax
nop
add    $0xffffffff,%ebp
cmpb   $0x3d,0x1(%rbx,%rax,1)
lea    0x1(%rax),%rax
je     11e4 <qfits_getcomment+0xb4>
cmp    $0x50,%rax
jb     11d0 <qfits_getcomment+0xa0>
cmp    $0x4f,%eax
ja     1254 <qfits_getcomment+0x124>
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
cmp    $0x4f,%rax
je     1254 <qfits_getcomment+0x124>
movzbl 0x1(%rbx,%rax,1),%edx
xor    %esi,%esi
test   %ecx,%ecx
sete   %sil
cmp    $0x27,%dl
cmove  %esi,%ecx
add    $0xffffffff,%ebp
add    $0x1,%rax
cmp    $0x2f,%dl
jne    11f0 <qfits_getcomment+0xc0>
test   %ecx,%ecx
jne    11f0 <qfits_getcomment+0xc0>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
cmpb   $0x20,0x1(%rbx,%rax,1)
lea    0x1(%rax),%rax
je     1220 <qfits_getcomment+0xf0>
mov    %eax,%ecx
mov    $0x4f,%edx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
cmpb   $0x20,(%rbx,%rdx,1)
lea    -0x1(%rdx),%rdx
je     1240 <qfits_getcomment+0x110>
add    $0x1,%edx
cmp    %eax,%edx
jge    125f <qfits_getcomment+0x12f>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
add    %rcx,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rax,%r14,1)
jmp    1257 <qfits_getcomment+0x127>

LLVM IR (-O0):
@qfits_getcomment.comment = internal global [81 x i8] zeroinitializer
@.str = [5 x i8] c"END \00"
@.str.1 = [9 x i8] c"HISTORY \00"
@.str.2 = [9 x i8] c"COMMENT \00"
@.str.3 = [9 x i8] c" \00"
define i8* @qfits_getcomment(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %140
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strncmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
store i8* null, i8** %2
br label %140
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 @strncmp(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16
store i8* null, i8** %2
br label %140
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i32 @strncmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21
store i8* null, i8** %2
br label %140
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = call i32 @strncmp(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %26
store i8* null, i8** %2
br label %140
31: ; preds = %26
%32 = call i32 @memset(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), i32 0, i32 81)
store i32 0, i32* %4
br label %33
33: ; preds = %46, %31
%34 = load i8*, i8** %3
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 61
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32, i32* %4
%43 = icmp slt i32 %42, 80
br label %44
44: ; preds = %41, %33
%45 = phi i1 [ false, %33 ], [ %43, %41 ]
br i1 %45, label %46, label %49
46: ; preds = %44
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %33
49: ; preds = %44
%50 = load i32, i32* %4
%51 = icmp sge i32 %50, 80
br i1 %51, label %52, label %53
52: ; preds = %49
store i8* null, i8** %2
br label %140
53: ; preds = %49
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
store i32 0, i32* %7
br label %56
56: ; preds = %85, %53
%57 = load i32, i32* %4
%58 = icmp slt i32 %57, 80
br i1 %58, label %59, label %88
59: ; preds = %56
%60 = load i8*, i8** %3
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 39
br i1 %66, label %67, label %72
67: ; preds = %59
%68 = load i32, i32* %7
%69 = icmp ne i32 %68, 0
%70 = xor i1 %69, true
%71 = zext i1 %70 to i32
store i32 %71, i32* %7
br label %72
72: ; preds = %67, %59
%73 = load i8*, i8** %3
%74 = load i32, i32* %4
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 47
br i1 %79, label %80, label %85
80: ; preds = %72
%81 = load i32, i32* %7
%82 = icmp ne i32 %81, 0
br i1 %82, label %84, label %83
83: ; preds = %80
br label %88
84: ; preds = %80
br label %85
85: ; preds = %84, %72
%86 = load i32, i32* %4
%87 = add nsw i32 %86, 1
store i32 %87, i32* %4
br label %56
88: ; preds = %83, %56
%89 = load i32, i32* %4
%90 = icmp sge i32 %89, 80
br i1 %90, label %91, label %92
91: ; preds = %88
store i8* null, i8** %2
br label %140
92: ; preds = %88
%93 = load i32, i32* %4
%94 = add nsw i32 %93, 1
store i32 %94, i32* %4
br label %95
95: ; preds = %103, %92
%96 = load i8*, i8** %3
%97 = load i32, i32* %4
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp eq i32 %101, 32
br i1 %102, label %103, label %106
103: ; preds = %95
%104 = load i32, i32* %4
%105 = add nsw i32 %104, 1
store i32 %105, i32* %4
br label %95
106: ; preds = %95
%107 = load i32, i32* %4
store i32 %107, i32* %5
store i32 79, i32* %6
br label %108
108: ; preds = %116, %106
%109 = load i8*, i8** %3
%110 = load i32, i32* %6
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 32
br i1 %115, label %116, label %119
116: ; preds = %108
%117 = load i32, i32* %6
%118 = add nsw i32 %117, -1
store i32 %118, i32* %6
br label %108
119: ; preds = %108
%120 = load i32, i32* %6
%121 = load i32, i32* %5
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %124
123: ; preds = %119
store i8* null, i8** %2
br label %140
124: ; preds = %119
%125 = load i8*, i8** %3
%126 = load i32, i32* %5
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %125, i64 %127
%129 = load i32, i32* %6
%130 = load i32, i32* %5
%131 = sub nsw i32 %129, %130
%132 = add nsw i32 %131, 1
%133 = call i32 @strncpy(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), i8* %128, i32 %132)
%134 = load i32, i32* %6
%135 = load i32, i32* %5
%136 = sub nsw i32 %134, %135
%137 = add nsw i32 %136, 1
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 %138
store i8 0, i8* %139
store i8* getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), i8** %2
br label %140
140: ; preds = %124, %123, %91, %52, %30, %25, %20, %15, %10
%141 = load i8*, i8** %2
ret i8* %141
}

LLVM IR (-O2):
@qfits_getcomment.comment = internal global [81 x i8] zeroinitializer
@.str = [5 x i8] c"END \00"
@.str.1 = [9 x i8] c"HISTORY \00"
@.str.2 = [9 x i8] c"COMMENT \00"
@.str.3 = [9 x i8] c" \00"
define i8* @qfits_getcomment(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %70, label %3
3: ; preds = %1
%4 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = icmp eq i32 %4, 0
br i1 %5, label %70, label %6
6: ; preds = %3
%7 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%8 = icmp eq i32 %7, 0
br i1 %8, label %70, label %9
9: ; preds = %6
%10 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %70, label %12
12: ; preds = %9
%13 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%14 = icmp eq i32 %13, 0
br i1 %14, label %70, label %15
15: ; preds = %12
%16 = tail call i32 @memset(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), i32 0, i32 81)
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ %24, %17 ], [ 0, %15 ]
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 61
%22 = icmp ult i64 %18, 80
%23 = select i1 %21, i1 %22, i1 false
%24 = add nuw nsw i64 %18, 1
br i1 %23, label %17, label %25
25: ; preds = %17
%26 = trunc i64 %18 to i32
%27 = icmp ugt i32 %26, 79
br i1 %27, label %70, label %28
28: ; preds = %25, %33
%29 = phi i64 [ %31, %33 ], [ %18, %25 ]
%30 = phi i32 [ %39, %33 ], [ 0, %25 ]
%31 = add nuw nsw i64 %29, 1
%32 = icmp eq i64 %29, 79
br i1 %32, label %70, label %33
33: ; preds = %28
%34 = getelementptr inbounds i8, i8* %0, i64 %31
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 39
%37 = icmp eq i32 %30, 0
%38 = zext i1 %37 to i32
%39 = select i1 %36, i32 %38, i32 %30
%40 = icmp ne i8 %35, 47
%41 = icmp ne i32 %39, 0
%42 = select i1 %40, i1 true, i1 %41
br i1 %42, label %28, label %43
43: ; preds = %33
%44 = add nuw nsw i64 %29, 2
br label %45
45: ; preds = %45, %43
%46 = phi i64 [ %50, %45 ], [ %44, %43 ]
%47 = getelementptr inbounds i8, i8* %0, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 32
%50 = add nuw i64 %46, 1
br i1 %49, label %45, label %51
51: ; preds = %45
%52 = trunc i64 %46 to i32
%53 = and i64 %46, 4294967295
br label %54
54: ; preds = %54, %51
%55 = phi i64 [ %59, %54 ], [ 79, %51 ]
%56 = getelementptr inbounds i8, i8* %0, i64 %55
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, 32
%59 = add i64 %55, -1
br i1 %58, label %54, label %60
60: ; preds = %54
%61 = trunc i64 %55 to i32
%62 = icmp slt i32 %61, %52
br i1 %62, label %70, label %63
63: ; preds = %60
%64 = getelementptr inbounds i8, i8* %0, i64 %53
%65 = sub nsw i32 %61, %52
%66 = add nsw i32 %65, 1
%67 = tail call i32 @strncpy(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), i8* %64, i32 %66)
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds [81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 %68
store i8 0, i8* %69
br label %70
70: ; preds = %28, %60, %25, %12, %9, %6, %3, %1, %63
%71 = phi i8* [ getelementptr inbounds ([81 x i8], [81 x i8]* @qfits_getcomment.comment, i64 0, i64 0), %63 ], [ null, %1 ], [ null, %3 ], [ null, %6 ], [ null, %9 ], [ null, %12 ], [ null, %25 ], [ null, %60 ], [ null, %28 ]
ret i8* %71
}