#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
void getSentence(char str[]) {
  int str_len, i, sentence_len;
  sentence_len = str_len = 100001 - 1;
  printf("\nEnter a sentence (ending with \'.\' or \'!\' or \'?\')\n");
  fgets(str, str_len, stdin);
  for (i = 0; i < str_len; ++i)
    if ((str[i] == '.') || (str[i] == '!') || (str[i] == '\?')) {
      sentence_len = i;
      break;
    }
  for (i = sentence_len + 1; i < str_len; ++i)
    str[i] = '\0';
}


x86 assembly (clang, -O0):
<getSentence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x186a0,-0xc(%rbp)
movl   $0x186a0,-0x14(%rbp)
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cb <getSentence+0xab>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     11ad <getSentence+0x8d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x21,%eax
je     11ad <getSentence+0x8d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    11b8 <getSentence+0x98>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11cb <getSentence+0xab>
jmp    11bd <getSentence+0x9d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <getSentence+0x42>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fa <getSentence+0xda>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d4 <getSentence+0xb4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSentence>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1050 <fgets@plt>
mov    $0x7,%eax
movabs $0x8000400200000000,%rcx
movzbl -0x7(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     117a <getSentence+0x4a>
bt     %rdx,%rcx
jb     1212 <getSentence+0xe2>
movzbl -0x6(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     118f <getSentence+0x5f>
bt     %rdx,%rcx
jb     121f <getSentence+0xef>
movzbl -0x5(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     11a4 <getSentence+0x74>
bt     %rdx,%rcx
jb     122c <getSentence+0xfc>
movzbl -0x4(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     11b9 <getSentence+0x89>
bt     %rdx,%rcx
jb     1239 <getSentence+0x109>
movzbl -0x3(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     11ca <getSentence+0x9a>
bt     %rdx,%rcx
jb     1246 <getSentence+0x116>
movzbl -0x2(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     11db <getSentence+0xab>
bt     %rdx,%rcx
jb     1253 <getSentence+0x123>
movzbl -0x1(%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     11f0 <getSentence+0xc0>
bt     %rdx,%rcx
jb     127c <getSentence+0x14c>
movzbl (%rbx,%rax,1),%edx
cmp    $0x3f,%rdx
ja     1200 <getSentence+0xd0>
bt     %rdx,%rcx
jb     1257 <getSentence+0x127>
add    $0x8,%rax
cmp    $0x186a7,%rax
jne    1165 <getSentence+0x35>
pop    %rbx
ret
add    $0xfffffffffffffff9,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>
add    $0xfffffffffffffffa,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>
add    $0xfffffffffffffffb,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>
add    $0xfffffffffffffffc,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>
add    $0xfffffffffffffffd,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>
add    $0xfffffffffffffffe,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
mov    %eax,%ecx
lea    (%rcx,%rbx,1),%rdi
add    $0x1,%rdi
mov    $0x1869e,%edx
sub    %eax,%edx
add    $0x1,%rdx
xor    %esi,%esi
call   1040 <memset@plt>
pop    %rbx
ret
add    $0xffffffffffffffff,%rax
cmp    $0x1869e,%eax
ja     1210 <getSentence+0xe0>
jmp    125e <getSentence+0x12e>

LLVM IR (-O0):
@.str = [51 x i8] c"\0AEnter a sentence (ending with '.' or '!' or '?')\0A\00"
@stdin = global i32 0
define void @getSentence(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 100000, i32* %3
store i32 100000, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = load i32, i32* %3
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %7, i32 %8, i32 %9)
store i32 0, i32* %4
br label %11
11: ; preds = %42, %1
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %45
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 46
br i1 %22, label %39, label %23
23: ; preds = %15
%24 = load i8*, i8** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 33
br i1 %30, label %39, label %31
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 63
br i1 %38, label %39, label %41
39: ; preds = %31, %23, %15
%40 = load i32, i32* %4
store i32 %40, i32* %5
br label %45
41: ; preds = %31
br label %42
42: ; preds = %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %11
45: ; preds = %39, %11
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %48
48: ; preds = %57, %45
%49 = load i32, i32* %4
%50 = load i32, i32* %3
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8*, i8** %2
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
br label %57
57: ; preds = %52
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %48
60: ; preds = %48
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [50 x i8] c"\0AEnter a sentence (ending with '.' or '!' or '?')\00"
define void @getSentence(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* %0, i32 100000, i32 %3)
br label %5
5: ; preds = %37, %1
%6 = phi i64 [ 0, %1 ], [ %38, %37 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
9: ; preds = %5
%10 = or i64 %6, 1
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
13: ; preds = %9
%14 = or i64 %6, 2
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
switch i8 %16, label %17 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
17: ; preds = %13
%18 = or i64 %6, 3
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
switch i8 %20, label %21 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
21: ; preds = %17
%22 = or i64 %6, 4
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
switch i8 %24, label %25 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
25: ; preds = %21
%26 = or i64 %6, 5
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
switch i8 %28, label %29 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
29: ; preds = %25
%30 = or i64 %6, 6
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
switch i8 %32, label %33 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
33: ; preds = %29
%34 = or i64 %6, 7
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = load i8, i8* %35
switch i8 %36, label %37 [
i8 46, label %40
i8 33, label %40
i8 63, label %40
]
37: ; preds = %33
%38 = add nuw nsw i64 %6, 8
%39 = icmp eq i64 %38, 100000
br i1 %39, label %51, label %5
40: ; preds = %33, %33, %33, %29, %29, %29, %25, %25, %25, %21, %21, %21, %17, %17, %17, %13, %13, %13, %9, %9, %9, %5, %5, %5
%41 = phi i64 [ %6, %5 ], [ %6, %5 ], [ %6, %5 ], [ %10, %9 ], [ %10, %9 ], [ %10, %9 ], [ %14, %13 ], [ %14, %13 ], [ %14, %13 ], [ %18, %17 ], [ %18, %17 ], [ %18, %17 ], [ %22, %21 ], [ %22, %21 ], [ %22, %21 ], [ %26, %25 ], [ %26, %25 ], [ %26, %25 ], [ %30, %29 ], [ %30, %29 ], [ %30, %29 ], [ %34, %33 ], [ %34, %33 ], [ %34, %33 ]
%42 = trunc i64 %41 to i32
%43 = icmp ult i32 %42, 99999
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = and i64 %41, 4294967295
%46 = add nuw nsw i64 %45, 1
%47 = getelementptr i8, i8* %0, i64 %46
%48 = sub nsw i64 99998, %41
%49 = and i64 %48, 4294967295
%50 = add nuw nsw i64 %49, 1
br label %51
51: ; preds = %37, %44, %40
ret void
}