#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ process_command(char *);
int /*<<< orphan*/ prompt();
int /*<<< orphan*/ stdin;
char *trim(char *);
void interact() {
  int i;
  char buf[512];
  char *cmd;
  while (1) {
    prompt();
    for (i = 0; i < 512; i++)
      buf[i] = '\0';
    fgets(buf, 512, stdin);
    cmd = trim(buf);
    if (process_command(cmd))
      return;
  }
}


x86 assembly (clang, -O0):
<interact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    $0x0,%al
call   1040 <prompt@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x200,-0x4(%rbp)
jge    1180 <interact+0x40>
movslq -0x4(%rbp),%rax
movb   $0x0,-0x210(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <interact+0x19>
lea    -0x210(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1060 <fgets@plt>
lea    -0x210(%rbp),%rdi
call   1050 <trim@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
call   1030 <process_command@plt>
cmp    $0x0,%rax
je     11cc <interact+0x8c>
add    $0x220,%rsp
pop    %rbp
ret
jmp    114b <interact+0xb>

x86 assembly (clang, -O2):
<interact>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%rbx
mov    0x2e84(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <prompt@plt>
mov    $0x200,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rax,%rdi
call   1030 <process_command@plt>
test   %rax,%rax
je     1170 <interact+0x20>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define void @interact() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca i8*
br label %4
4: ; preds = %0, %26
%5 = call i32 (...) @prompt()
store i32 0, i32* %1
br label %6
6: ; preds = %13, %4
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 512
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %6
16: ; preds = %6
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 512, i32 %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%21 = call i8* @trim(i8* %20)
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = call i64 @process_command(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %16
ret void
26: ; preds = %16
br label %4
}

LLVM IR (-O2):
@stdin = global i32 0
define void @interact() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %4, %0
%5 = call i32 (...) @prompt()
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 512, i32 %6)
%8 = call i8* @trim(i8* %3)
%9 = call i64 @process_command(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %4
ret void
}