#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *copyString(char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ isEmptySpace(char *);
scalar_t__ lineHasLongOpt(char *, char **);
scalar_t__ lineHasShortOpt(char *, char *);
int optType(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ same(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char *);
void printOptions(FILE *fp, char *smallOpts, char **longOpts) {
  bool inDescription = false;
  char *lastLine = NULL;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  while ((read = getline(&line, &len, fp)) != -1) {
    if (lastLine && same(lastLine, "NAME\n")) {
      printf("%s", line);
    }
    if (!lastLine) {
      lastLine = copyString(line);
      continue;
    }
    if (inDescription) {
      if (isEmptySpace(line)) {
        inDescription = false;
        printf("\n");
      } else {
        printf("%s", line);
      }
    } else {
      char linecp[strlen(lastLine) + 1];
      strcpy(linecp, lastLine);
      char *token = strtok(linecp, " \t\n");
      const int type = optType(token);
      if (type != 2 && (lineHasLongOpt(lastLine, longOpts) ||
                        lineHasShortOpt(lastLine, smallOpts))) {
        printf(lastLine);
        if (!isEmptySpace(line)) {
          inDescription = true;
          printf(line);
        }
      }
    }
    free(lastLine);
    lastLine = copyString(line);
  }
  free(line);
  free(lastLine);
}


x86 assembly (clang, -O0):
<printOptions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     1399 <printOptions+0x1d9>
cmpq   $0x0,-0x28(%rbp)
je     1247 <printOptions+0x87>
mov    -0x28(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   10a0 <same@plt>
cmp    $0x0,%rax
je     1247 <printOptions+0x87>
mov    -0x30(%rbp),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
jne    1264 <printOptions+0xa4>
mov    -0x30(%rbp),%rdi
call   1040 <copyString@plt>
mov    %rax,-0x28(%rbp)
jmp    11f3 <printOptions+0x33>
cmpl   $0x0,-0x1c(%rbp)
je     12b2 <printOptions+0xf2>
mov    -0x30(%rbp),%rdi
call   1090 <isEmptySpace@plt>
cmp    $0x0,%rax
je     129b <printOptions+0xdb>
movl   $0x0,-0x1c(%rbp)
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12ad <printOptions+0xed>
mov    -0x30(%rbp),%rsi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    137e <printOptions+0x1be>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x68(%rbp),%rdi
lea    0xd14(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1080 <optType@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x2,-0x5c(%rbp)
je     1377 <printOptions+0x1b7>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10e0 <lineHasLongOpt@plt>
cmp    $0x0,%rax
jne    1342 <printOptions+0x182>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10b0 <lineHasShortOpt@plt>
cmp    $0x0,%rax
je     1377 <printOptions+0x1b7>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1090 <isEmptySpace@plt>
cmp    $0x0,%rax
jne    1372 <printOptions+0x1b2>
movl   $0x1,-0x1c(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1377 <printOptions+0x1b7>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <copyString@plt>
mov    %rax,-0x28(%rbp)
jmp    11f3 <printOptions+0x33>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printOptions>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    %rbx,%rdx
call   10e0 <getline@plt>
cmp    $0xffffffff,%eax
je     136b <printOptions+0x19b>
mov    %r15,-0x48(%rbp)
mov    %r14,-0x50(%rbp)
lea    -0x30(%rbp),%r12
lea    -0x38(%rbp),%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
nopl   0x0(%rax)
test   %r14,%r14
jne    1259 <printOptions+0x89>
mov    -0x30(%rbp),%rdi
call   1050 <copyString@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10e0 <getline@plt>
cmp    $0xffffffff,%eax
jne    1230 <printOptions+0x60>
jmp    136e <printOptions+0x19e>
mov    %r14,%rdi
lea    0xd9d(%rip),%rsi
call   10b0 <same@plt>
test   %rax,%rax
je     127f <printOptions+0xaf>
mov    -0x30(%rbp),%rsi
lea    0xd8e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r15d,%r15d
je     12a8 <printOptions+0xd8>
mov    -0x30(%rbp),%rdi
call   10a0 <isEmptySpace@plt>
test   %rax,%rax
je     1346 <printOptions+0x176>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %r15d,%r15d
jmp    135e <printOptions+0x18e>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %rsp,-0x40(%rbp)
add    $0x1,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strcpy@plt>
mov    %r15,%rdi
lea    0xd2c(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,%rdi
call   1090 <optType@plt>
xor    %r15d,%r15d
cmp    $0x2,%eax
je     1340 <printOptions+0x170>
mov    %r14,%rdi
mov    -0x50(%rbp),%rsi
call   10f0 <lineHasLongOpt@plt>
test   %rax,%rax
jne    1314 <printOptions+0x144>
mov    %r14,%rdi
mov    -0x48(%rbp),%rsi
call   10c0 <lineHasShortOpt@plt>
test   %rax,%rax
je     1340 <printOptions+0x170>
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <isEmptySpace@plt>
test   %rax,%rax
jne    1340 <printOptions+0x170>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%r15d
mov    -0x40(%rbp),%rsp
jmp    135e <printOptions+0x18e>
mov    -0x30(%rbp),%rsi
lea    0xcb5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%r15d
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1235 <printOptions+0x65>
xor    %r14d,%r14d
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"NAME\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c" \09\0A\00"
define void @printOptions(i32* %0, i8* %1, i8** %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8** %2, i8*** %6
store i32 0, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i64 0, i64* %10
br label %16
16: ; preds = %85, %33, %3
%17 = load i32*, i32** %4
%18 = call i32 @getline(i8** %9, i64* %10, i32* %17)
store i32 %18, i32* %11
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %90
20: ; preds = %16
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i8*, i8** %8
%25 = call i64 @same(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %23, %20
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i8*, i8** %9
%35 = call i8* @copyString(i8* %34)
store i8* %35, i8** %8
br label %16
36: ; preds = %30
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i8*, i8** %9
%41 = call i64 @isEmptySpace(i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
store i32 0, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %48
45: ; preds = %39
%46 = load i8*, i8** %9
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %43
br label %85
49: ; preds = %36
%50 = load i8*, i8** %8
%51 = call i32 @strlen(i8* %50)
%52 = add nsw i32 %51, 1
%53 = zext i32 %52 to i64
%54 = call i8* @llvm.stacksave()
store i8* %54, i8** %12
%55 = alloca i8, i64 %53
store i64 %53, i64* %13
%56 = load i8*, i8** %8
%57 = call i32 @strcpy(i8* %55, i8* %56)
%58 = call i8* @strtok(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %58, i8** %14
%59 = load i8*, i8** %14
%60 = call i32 @optType(i8* %59)
store i32 %60, i32* %15
%61 = load i32, i32* %15
%62 = icmp ne i32 %61, 2
br i1 %62, label %63, label %83
63: ; preds = %49
%64 = load i8*, i8** %8
%65 = load i8**, i8*** %6
%66 = call i64 @lineHasLongOpt(i8* %64, i8** %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %73, label %68
68: ; preds = %63
%69 = load i8*, i8** %8
%70 = load i8*, i8** %5
%71 = call i64 @lineHasShortOpt(i8* %69, i8* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %83
73: ; preds = %68, %63
%74 = load i8*, i8** %8
%75 = call i32 (i8*, ...) @printf(i8* %74)
%76 = load i8*, i8** %9
%77 = call i64 @isEmptySpace(i8* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %73
store i32 1, i32* %7
%80 = load i8*, i8** %9
%81 = call i32 (i8*, ...) @printf(i8* %80)
br label %82
82: ; preds = %79, %73
br label %83
83: ; preds = %82, %68, %49
%84 = load i8*, i8** %12
br label %85
85: ; preds = %83, %48
%86 = load i8*, i8** %8
%87 = call i32 @free(i8* %86)
%88 = load i8*, i8** %9
%89 = call i8* @copyString(i8* %88)
store i8* %89, i8** %8
br label %16
90: ; preds = %16
%91 = load i8*, i8** %9
%92 = call i32 @free(i8* %91)
%93 = load i8*, i8** %8
%94 = call i32 @free(i8* %93)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"NAME\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c" \09\0A\00"
define void @printOptions(i32* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%8 = call i32 @getline(i8** %4, i64* %5, i32* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %71, label %10
10: ; preds = %3, %64
%11 = phi i32 [ %65, %64 ], [ 0, %3 ]
%12 = phi i8* [ %68, %64 ], [ null, %3 ]
br label %13
13: ; preds = %10, %22
%14 = phi i8* [ %12, %10 ], [ %24, %22 ]
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = call i64 @same(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %27
22: ; preds = %13
%23 = load i8*, i8** %4
%24 = call i8* @copyString(i8* %23)
%25 = call i32 @getline(i8** %4, i64* %5, i32* %0)
%26 = icmp eq i32 %25, -1
br i1 %26, label %71, label %13
27: ; preds = %16, %19
%28 = icmp eq i32 %11, 0
br i1 %28, label %38, label %29
29: ; preds = %27
%30 = load i8*, i8** %4
%31 = call i64 @isEmptySpace(i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = call i32 @putchar(i32 10)
br label %64
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %64
38: ; preds = %27
%39 = call i32 @strlen(i8* %14)
%40 = add nsw i32 %39, 1
%41 = zext i32 %40 to i64
%42 = call i8* @llvm.stacksave()
%43 = alloca i8, i64 %41
%44 = call i32 @strcpy(i8* %43, i8* %14)
%45 = call i8* @strtok(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @optType(i8* %45)
%47 = icmp eq i32 %46, 2
br i1 %47, label %62, label %48
48: ; preds = %38
%49 = call i64 @lineHasLongOpt(i8* %14, i8** %2)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = call i64 @lineHasShortOpt(i8* %14, i8* %1)
%53 = icmp eq i64 %52, 0
br i1 %53, label %62, label %54
54: ; preds = %51, %48
%55 = call i32 (i8*, ...) @printf(i8* %14)
%56 = load i8*, i8** %4
%57 = call i64 @isEmptySpace(i8* %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i8*, i8** %4
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %60)
br label %62
62: ; preds = %54, %59, %51, %38
%63 = phi i32 [ 0, %54 ], [ 1, %59 ], [ 0, %51 ], [ 0, %38 ]
br label %64
64: ; preds = %33, %35, %62
%65 = phi i32 [ 0, %33 ], [ 1, %35 ], [ %63, %62 ]
%66 = call i32 @free(i8* %14)
%67 = load i8*, i8** %4
%68 = call i8* @copyString(i8* %67)
%69 = call i32 @getline(i8** %4, i64* %5, i32* %0)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %10
71: ; preds = %64, %22, %3
%72 = phi i8* [ null, %3 ], [ %24, %22 ], [ %68, %64 ]
%73 = load i8*, i8** %4
%74 = call i32 @free(i8* %73)
%75 = call i32 @free(i8* %72)
ret void
}