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

/* Variables and functions */
int /*<<< orphan*/ docommand(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fatal(char *, int /*<<< orphan*/ *);
scalar_t__ readline(int /*<<< orphan*/ *, char *, int);
int ingestfile(FILE *str) {
  char line[500];
  while (readline(str, line, sizeof(line)) >= 0) {
    if (line[0] == '!') {
      docommand(str, line);
    } else {
      fatal("Command string required before register data", NULL);
    }
  }
}


x86 assembly (clang, -O0):
<ingestfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    $0x1f4,%edx
call   1030 <readline@plt>
cmp    $0x0,%rax
jl     1198 <ingestfile+0x68>
movsbl -0x210(%rbp),%eax
cmp    $0x21,%eax
jne    1183 <ingestfile+0x53>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1050 <docommand@plt>
jmp    1193 <ingestfile+0x63>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fatal@plt>
jmp    113f <ingestfile+0xf>
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ingestfile>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0x1f4,%edx
call   1030 <readline@plt>
test   %rax,%rax
js     1192 <ingestfile+0x62>
mov    %rsp,%r14
lea    0xea5(%rip),%r15
jmp    117f <ingestfile+0x4f>
nopl   (%rax)
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <fatal@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f4,%edx
call   1030 <readline@plt>
test   %rax,%rax
js     1192 <ingestfile+0x62>
cmpb   $0x21,(%rsp)
jne    1160 <ingestfile+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <docommand@plt>
jmp    116a <ingestfile+0x3a>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Command string required before register data\00"
define i32 @ingestfile(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [500 x i8]
store i32* %0, i32** %3
br label %5
5: ; preds = %21, %1
%6 = load i32*, i32** %3
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%8 = call i64 @readline(i32* %6, i8* %7, i32 500)
%9 = icmp sge i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 33
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32*, i32** %3
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%18 = call i32 @docommand(i32* %16, i8* %17)
br label %21
19: ; preds = %10
%20 = call i32 @fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32* null)
br label %21
21: ; preds = %19, %15
br label %5
22: ; preds = %5
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [45 x i8] c"Command string required before register data\00"
define i32 @ingestfile(i32* %0) {
%2 = alloca [500 x i8]
%3 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%4 = call i64 @readline(i32* %0, i8* %3, i32 500)
%5 = icmp sgt i64 %4, -1
br i1 %5, label %6, label %16
6: ; preds = %1, %13
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 33
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @docommand(i32* %0, i8* %3)
br label %13
11: ; preds = %6
%12 = call i32 @fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32* null)
br label %13
13: ; preds = %11, %9
%14 = call i64 @readline(i32* %0, i8* %3, i32 500)
%15 = icmp sgt i64 %14, -1
br i1 %15, label %6, label %16
16: ; preds = %13, %1
ret i32 undef
}