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

/* Variables and functions */
int EINVAL;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parse_com(char *);
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  char line_buff[50];
  FILE *pf;
  if (argc < 2) {
    return -EINVAL;
  }
  pf = fopen(argv[1], "r");
  while (fgets(line_buff, sizeof(line_buff), pf)) {
    parse_com(line_buff);
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1173 <main+0x33>
xor    %eax,%eax
mov    0x2e77(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    $0x32,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11bf <main+0x7f>
lea    -0x50(%rbp),%rdi
call   1030 <parse_com@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    118b <main+0x4b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
cmp    $0x1,%edi
jg     115c <main+0x1c>
mov    0x2e8c(%rip),%rax
xor    %r14d,%r14d
sub    (%rax),%r14d
jmp    11b7 <main+0x77>
mov    0x8(%rsi),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x32,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11b7 <main+0x77>
mov    %rsp,%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <parse_com@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbp,%rdi
mov    $0x32,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1190 <main+0x50>
mov    %r14d,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [50 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @EINVAL
%12 = sub nsw i32 0, %11
store i32 %12, i32* %3
br label %28
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %7
br label %18
18: ; preds = %23, %13
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %7
%21 = call i64 @fgets(i8* %19, i32 50, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%25 = call i32 @parse_com(i8* %24)
%26 = call i32 @sleep(i32 1)
br label %18
27: ; preds = %18
store i32 0, i32* %3
br label %28
28: ; preds = %27, %10
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@EINVAL = global i32 0
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @EINVAL
%8 = sub nsw i32 0, %7
br label %20
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i64 @fgets(i8* %4, i32 50, i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %9, %15
%16 = call i32 @parse_com(i8* %4)
%17 = call i32 @sleep(i32 1)
%18 = call i64 @fgets(i8* %4, i32 50, i32* %12)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %15
20: ; preds = %15, %9, %6
%21 = phi i32 [ %8, %6 ], [ 0, %9 ], [ 0, %15 ]
ret i32 %21
}