#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*/);
int /*<<< orphan*/ fixtoken_test(char *, char *);
int /*<<< orphan*/ slog_csoup_format(char *);
int /*<<< orphan*/ slog_csoup_puts(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int fixtoken_run(void) {
  char buf[256];
  slog_csoup_puts(
      0, (8 | 0),
      slog_csoup_format("Press Ctrl-D or 'quit' command to quit.\n"));
  while (1) {
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("IN> "));
    if (fgets(buf, 256, stdin) == NULL) {
      break;
    }
    buf[strlen(buf) - 1] = 0;
    if (!strcmp(buf, "quit") || !strcmp(buf, "exit")) {
      break;
    }
    fixtoken_test(buf, " ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<fixtoken_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    0xe8e(%rip),%rdi
call   1080 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
lea    0xe9d(%rip),%rdi
call   1080 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
lea    -0x100(%rbp),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11c8 <fixtoken_run+0x68>
jmp    1236 <fixtoken_run+0xd6>
lea    -0x100(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x100(%rbp,%rax,1)
lea    -0x100(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1219 <fixtoken_run+0xb9>
lea    -0x100(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    121e <fixtoken_run+0xbe>
jmp    1236 <fixtoken_run+0xd6>
lea    -0x100(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1030 <fixtoken_test@plt>
jmp    1185 <fixtoken_run+0x25>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixtoken_run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe98(%rip),%rdi
call   1070 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
lea    0xea7(%rip),%rdi
call   1070 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
mov    0x2e4c(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1233 <fixtoken_run+0xe3>
mov    $0x74697571,%ebp
mov    $0x74697865,%r13d
lea    0xe65(%rip),%r14
lea    0xe5b(%rip),%r15
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    (%rsp),%eax
xor    %ebp,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     1233 <fixtoken_run+0xe3>
mov    (%rsp),%eax
xor    %r13d,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     1233 <fixtoken_run+0xe3>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fixtoken_test@plt>
mov    %r15,%rdi
call   1070 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <fixtoken_run+0x80>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Press Ctrl-D or 'quit' command to quit.\0A\00"
@.str.1 = [5 x i8] c"IN> \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"exit\00"
@.str.4 = [2 x i8] c" \00"
define i32 @fixtoken_run() {
%1 = alloca [256 x i8]
%2 = call i32 @slog_csoup_format(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %2)
br label %4
4: ; preds = %0, %26
%5 = call i32 @slog_csoup_format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %7, i32 256, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %4
br label %29
12: ; preds = %4
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %16
store i8 0, i8* %17
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %12
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21, %12
br label %29
26: ; preds = %21
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%28 = call i32 @fixtoken_test(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %4
29: ; preds = %25, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Press Ctrl-D or 'quit' command to quit.\0A\00"
@.str.1 = [5 x i8] c"IN> \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"exit\00"
@.str.4 = [2 x i8] c" \00"
define i32 @fixtoken_run() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @slog_csoup_format(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %3)
%5 = call i32 @slog_csoup_format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %5)
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %2, i32 256, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %27, label %10
10: ; preds = %0, %20
%11 = call i32 @strlen(i8* %2)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i32 @bcmp(i8* dereferenceable(5) %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%16 = icmp eq i32 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %10
%18 = call i32 @bcmp(i8* dereferenceable(5) %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 5)
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call i32 @fixtoken_test(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @slog_csoup_format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %22)
%24 = load i32, i32* @stdin
%25 = call i32* @fgets(i8* %2, i32 256, i32 %24)
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %10
27: ; preds = %20, %17, %10, %0
ret i32 0
}