#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 */
char getchar();
int lirePhrase(char phrase[]) {
  char delimiter = '"';
  char lastChar;
  int charCount = 0;
  while (getchar() != delimiter)
    ;
  while ((lastChar = getchar()) != delimiter) {
    phrase[charCount] = lastChar;
    charCount++;
  }
  while (getchar() != '\n')
    ;
  phrase[charCount] = '\0';
  return charCount;
}


x86 assembly (clang, -O0):
<lirePhrase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x22,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
movsbl %al,%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     1142 <lirePhrase+0x32>
jmp    1127 <lirePhrase+0x17>
jmp    1147 <lirePhrase+0x37>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0xa(%rbp)
movsbl %al,%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     117c <lirePhrase+0x6c>
mov    -0xa(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1147 <lirePhrase+0x37>
jmp    1181 <lirePhrase+0x71>
mov    $0x0,%al
call   1030 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1199 <lirePhrase+0x89>
jmp    1181 <lirePhrase+0x71>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lirePhrase>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x22,%al
jne    1120 <lirePhrase+0x10>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x22,%al
je     1160 <lirePhrase+0x50>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x22,%al
jne    1140 <lirePhrase+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1160 <lirePhrase+0x50>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @lirePhrase(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %2
store i8 34, i8* %3
store i32 0, i32* %5
br label %6
6: ; preds = %12, %1
%7 = call signext i8 (...) @getchar()
%8 = sext i8 %7 to i32
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %6
br label %6
13: ; preds = %6
br label %14
14: ; preds = %20, %13
%15 = call signext i8 (...) @getchar()
store i8 %15, i8* %4
%16 = sext i8 %15 to i32
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %28
20: ; preds = %14
%21 = load i8, i8* %4
%22 = load i8*, i8** %2
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %14
28: ; preds = %14
br label %29
29: ; preds = %33, %28
%30 = call signext i8 (...) @getchar()
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %34
33: ; preds = %29
br label %29
34: ; preds = %29
%35 = load i8*, i8** %2
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 0, i8* %38
%39 = load i32, i32* %5
ret i32 %39
}

LLVM IR (-O2):
define i32 @lirePhrase(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 34
br i1 %4, label %5, label %2
5: ; preds = %2
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 34
br i1 %7, label %10, label %12
8: ; preds = %12
%9 = trunc i64 %16 to i32
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 0, %5 ], [ %9, %8 ]
br label %19
12: ; preds = %5, %12
%13 = phi i64 [ %16, %12 ], [ 0, %5 ]
%14 = phi i8 [ %17, %12 ], [ %6, %5 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 %14, i8* %15
%16 = add nuw i64 %13, 1
%17 = tail call signext i8 (...) @getchar()
%18 = icmp eq i8 %17, 34
br i1 %18, label %8, label %12
19: ; preds = %10, %19
%20 = tail call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %19
22: ; preds = %19
%23 = zext i32 %11 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %24
ret i32 %11
}