#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();
void InputString(char m[]) {
  int i = 0;
  char c = getchar();
  while (c != '\0' && c != '\n') {
    m[i] = c;
    i++;
    c = getchar();
  }
  m[i] = '\0';
}


x86 assembly (clang, -O0):
<InputString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xe(%rbp)
je     114c <InputString+0x3c>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    115c <InputString+0x4c>
jmp    1182 <InputString+0x72>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0xd(%rbp)
jmp    112d <InputString+0x1d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InputString>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
test   %al,%al
je     1139 <InputString+0x29>
cmp    $0xa,%al
je     1139 <InputString+0x29>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
jmp    1120 <InputString+0x10>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @InputString(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i64 [ %7, %5 ], [ 0, %1 ]
%4 = tail call signext i8 (...) @getchar()
switch i8 %4, label %5 [
i8 10, label %8
i8 0, label %8
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 %4, i8* %6
%7 = add nuw i64 %3, 1
br label %2
8: ; preds = %2, %2
%9 = and i64 %3, 4294967295
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
ret void
}