#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 getchar();
void read_message(int *array, int *c) {
  while ((array[*c] = getchar()) != '\n') {
    *c += 1;
    if (*c == 81) {
      break;
    }
  }
  *c -= 1;
}


x86 assembly (clang, -O0):
<read_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
movslq (%rdx),%rdx
mov    %eax,(%rcx,%rdx,4)
cmp    $0xa,%eax
je     1160 <read_message+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x51,(%rax)
jne    115b <read_message+0x4b>
jmp    1160 <read_message+0x50>
jmp    1120 <read_message+0x10>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_message>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
movslq (%rbx),%rcx
mov    %eax,(%r14,%rcx,4)
mov    (%rbx),%ecx
cmp    $0xa,%eax
je     1146 <read_message+0x36>
add    $0x1,%ecx
mov    %ecx,(%rbx)
cmp    $0x51,%ecx
jne    1120 <read_message+0x10>
mov    $0x50,%ecx
jmp    1149 <read_message+0x39>
add    $0xffffffff,%ecx
mov    %ecx,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @read_message(i32* nocapture writeonly %0, i32* nocapture %1) {
br label %3
3: ; preds = %12, %2
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* %1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
store i32 %4, i32* %7
%8 = icmp eq i32 %4, 10
%9 = load i32, i32* %1
br i1 %8, label %10, label %12
10: ; preds = %3
%11 = add i32 %9, -1
br label %15
12: ; preds = %3
%13 = add nsw i32 %9, 1
store i32 %13, i32* %1
%14 = icmp eq i32 %13, 81
br i1 %14, label %15, label %3
15: ; preds = %12, %10
%16 = phi i32 [ %11, %10 ], [ 80, %12 ]
store i32 %16, i32* %1
ret void
}