#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 /*<<< orphan*/ free(char *);
char *getaline_filehandle(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tokenize(char *);
void run_tokenizer(FILE *handle) {
  char *buff = 0;
  do {
    if (buff != 0) {
      free(buff);
      buff = 0;
    }
    printf("prompt> ");
    buff = getaline_filehandle(handle);
    tokenize(buff);
  } while (strcmp(buff, "quit") != 0);
  free(buff);
}


x86 assembly (clang, -O0):
<run_tokenizer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1180 <run_tokenizer+0x30>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <getaline_filehandle@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <tokenize@plt>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1164 <run_tokenizer+0x14>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_tokenizer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
xor    %ebx,%ebx
lea    0xe9c(%rip),%r14
lea    0xe9e(%rip),%r15
jmp    119b <run_tokenizer+0x4b>
nopl   (%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1070 <getaline_filehandle@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <tokenize@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11aa <run_tokenizer+0x5a>
test   %rbx,%rbx
je     1170 <run_tokenizer+0x20>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1170 <run_tokenizer+0x20>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"prompt> \00"
@.str.1 = [5 x i8] c"quit\00"
define void @run_tokenizer(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
store i8* null, i8** %3
br label %4
4: ; preds = %16, %1
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i8*, i8** %3
%9 = call i32 @free(i8* %8)
store i8* null, i8** %3
br label %10
10: ; preds = %7, %4
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %2
%13 = call i8* @getaline_filehandle(i32* %12)
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 @tokenize(i8* %14)
br label %16
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = call i32 @free(i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"prompt> \00"
@.str.1 = [5 x i8] c"quit\00"
define void @run_tokenizer(i32* %0) {
br label %2
2: ; preds = %7, %1
%3 = phi i8* [ null, %1 ], [ %9, %7 ]
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @free(i8* %3)
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @getaline_filehandle(i32* %0)
%10 = tail call i32 @tokenize(i8* %9)
%11 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %2
13: ; preds = %7
%14 = tail call i32 @free(i8* %9)
ret void
}