#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 EOF;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int c;
  int number_sentences;
  int sentence_count = 0;
  int inside_double_quote = 0;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s number_sentences\n", argv[0]);
    exit(1);
  }
  number_sentences = atoi(argv[1]);
  while ((c = fgetc(stdin)) != EOF) {
    putchar(c);
    if (c == '.' || c == '?' || c == '!') {
      if (++sentence_count == number_sentences) {
        if (inside_double_quote) {
          while ((c = fgetc(stdin)) != EOF) {
            putchar(c);
            if (c == '"')
              break;
          }
        }
        break;
      }
    }
    if (c == '"') {
      inside_double_quote = 1 - inside_double_quote;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a4 <main+0x54>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%eax
je     1280 <main+0x130>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0x2e,-0x14(%rbp)
je     11fa <main+0xaa>
cmpl   $0x3f,-0x14(%rbp)
je     11fa <main+0xaa>
cmpl   $0x21,-0x14(%rbp)
jne    1266 <main+0x116>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    -0x18(%rbp),%eax
jne    1261 <main+0x111>
cmpl   $0x0,-0x20(%rbp)
je     125c <main+0x10c>
jmp    121b <main+0xcb>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dad(%rip),%rcx
cmp    (%rcx),%eax
je     1257 <main+0x107>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0x22,-0x14(%rbp)
jne    1252 <main+0x102>
jmp    1257 <main+0x107>
jmp    121b <main+0xcb>
jmp    125c <main+0x10c>
jmp    1280 <main+0x130>
jmp    1266 <main+0x116>
cmpl   $0x22,-0x14(%rbp)
jne    127b <main+0x12b>
mov    $0x1,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11b4 <main+0x64>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1224 <main+0xd4>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
mov    0x2e71(%rip),%r14
mov    (%r14),%edi
call   1040 <fgetc@plt>
mov    0x2e5a(%rip),%r15
cmp    (%r15),%eax
jne    119c <main+0x4c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11cc <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%eax
sub    %ebx,%eax
cmp    $0x22,%ebp
cmove  %eax,%ebx
mov    (%r14),%edi
call   1040 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     118b <main+0x3b>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0x3f,%ebp
ja     11b0 <main+0x60>
mov    %ebp,%eax
movabs $0x8000400200000000,%rcx
bt     %rax,%rcx
jae    11b0 <main+0x60>
add    $0x1,%r13d
cmp    %r12d,%r13d
jne    11b0 <main+0x60>
test   %ebx,%ebx
je     118b <main+0x3b>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
call   1040 <fgetc@plt>
cmp    (%r15),%eax
je     118b <main+0x3b>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <putchar@plt>
cmp    $0x22,%ebx
jne    1200 <main+0xb0>
jmp    118b <main+0x3b>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdc9(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s number_sentences\0A\00"
@stdin = global i32 0
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = load i32, i32* @stdin
%14 = tail call i32 @fgetc(i32 %13)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %44, label %17
17: ; preds = %9, %35
%18 = phi i32 [ %41, %35 ], [ %14, %9 ]
%19 = phi i32 [ %39, %35 ], [ 0, %9 ]
%20 = phi i32 [ %36, %35 ], [ 0, %9 ]
%21 = tail call i32 @putchar(i32 %18)
switch i32 %18, label %35 [
i32 63, label %22
i32 46, label %22
i32 33, label %22
]
22: ; preds = %17, %17, %17
%23 = add nsw i32 %20, 1
%24 = icmp eq i32 %23, %12
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = icmp eq i32 %19, 0
br i1 %26, label %44, label %27
27: ; preds = %25, %32
%28 = load i32, i32* @stdin
%29 = tail call i32 @fgetc(i32 %28)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %44, label %32
32: ; preds = %27
%33 = tail call i32 @putchar(i32 %29)
%34 = icmp eq i32 %29, 34
br i1 %34, label %44, label %27
35: ; preds = %17, %22
%36 = phi i32 [ %23, %22 ], [ %20, %17 ]
%37 = icmp eq i32 %18, 34
%38 = sub nsw i32 1, %19
%39 = select i1 %37, i32 %38, i32 %19
%40 = load i32, i32* @stdin
%41 = tail call i32 @fgetc(i32 %40)
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %17
44: ; preds = %35, %32, %27, %9, %25
ret i32 0
}