#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
void read_comm(FILE *f, char comm[17]) {
  size_t read = 0;
  int c;
  while (c = fgetc(f), c != EOF && c != '\n' && read < 17 - 1) {
    comm[read++] = c;
  }
  comm[read] = '\0';
}


x86 assembly (clang, -O0):
<read_comm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
mov    0x2ea8(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x1d(%rbp)
je     1165 <read_comm+0x55>
xor    %eax,%eax
cmpl   $0xa,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     1165 <read_comm+0x55>
cmpq   $0x10,-0x18(%rbp)
setb   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1175 <read_comm+0x65>
jmp    1195 <read_comm+0x85>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x18(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    1128 <read_comm+0x18>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_comm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <fgetc@plt>
xor    %r13d,%r13d
cmp    $0xa,%eax
je     1164 <read_comm+0x54>
mov    0x2eb5(%rip),%r12
cmp    (%r12),%eax
je     1164 <read_comm+0x54>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r13
mov    %al,(%r14,%rbx,1)
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%eax
je     1164 <read_comm+0x54>
cmp    (%r12),%eax
je     1164 <read_comm+0x54>
cmp    $0xf,%rbx
mov    %r13,%rbx
jb     1140 <read_comm+0x30>
movb   $0x0,(%r14,%r13,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define void @read_comm(i32* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %3, %4
%6 = icmp ne i32 %3, 10
%7 = and i1 %6, %5
br i1 %7, label %8, label %21
8: ; preds = %2, %8
%9 = phi i32 [ %14, %8 ], [ %3, %2 ]
%10 = phi i64 [ %12, %8 ], [ 0, %2 ]
%11 = trunc i32 %9 to i8
%12 = add nuw nsw i64 %10, 1
%13 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 %11, i8* %13
%14 = tail call i32 @fgetc(i32* %0)
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
%17 = icmp ne i32 %14, 10
%18 = and i1 %17, %16
%19 = icmp ult i64 %10, 15
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %8, label %21
21: ; preds = %8, %2
%22 = phi i64 [ 0, %2 ], [ %12, %8 ]
%23 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 0, i8* %23
ret void
}