#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*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_lexeme(int /*<<< orphan*/ *);
int get_token_name(char *);
int get_token_value(char *);
int /*<<< orphan*/ printf(char *, char *, int, int);
int main() {
  char *tk_stream = "<10,20><30,40><50,60>";
  FILE *in = fopen("test.c", "rb");
  char *token = get_lexeme(in);
  printf("\n\nGet Token: '%s', token_name: %d, token_value: %d\n\n", token,
         get_token_name(token), get_token_value(token));
  token = get_lexeme(in);
  printf("\n\nGet Token: '%s', token_name: %d, token_value: %d\n\n", token,
         get_token_name(token), get_token_value(token));
  free(token);
  token = get_lexeme(in);
  printf("\n\nGet Token: '%s', token_name: %d, token_value: %d\n\n", token,
         get_token_name(token), get_token_value(token));
  token = get_lexeme(in);
  printf("\n\nGet Token: '%s', token_name: %d, token_value: %d\n\n", token,
         get_token_name(token), get_token_value(token));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <get_lexeme@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <get_token_name@plt>
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <get_token_value@plt>
mov    -0x60(%rbp),%rsi
mov    -0x54(%rbp),%edx
mov    %eax,%ecx
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <get_lexeme@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <get_token_name@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <get_token_value@plt>
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1080 <get_lexeme@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <get_token_name@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <get_token_value@plt>
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <get_lexeme@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <get_token_name@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <get_token_value@plt>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe92(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1080 <get_lexeme@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <get_token_name@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <get_token_value@plt>
lea    0xe69(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r15,%rdi
call   1080 <get_lexeme@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <get_token_name@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <get_token_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1080 <get_lexeme@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <get_token_name@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <get_token_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r15,%rdi
call   1080 <get_lexeme@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <get_token_name@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <get_token_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"<10,20><30,40><50,60>\00"
@.str.1 = [7 x i8] c"test.c\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [53 x i8] c"\0A\0AGet Token: '%s', token_name: %d, token_value: %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = call i8* @get_lexeme(i32* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @get_token_name(i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @get_token_value(i8* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %10, i32 %12)
%14 = load i32*, i32** %3
%15 = call i8* @get_lexeme(i32* %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i32 @get_token_name(i8* %17)
%19 = load i8*, i8** %4
%20 = call i32 @get_token_value(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %16, i32 %18, i32 %20)
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
%24 = load i32*, i32** %3
%25 = call i8* @get_lexeme(i32* %24)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = load i8*, i8** %4
%28 = call i32 @get_token_name(i8* %27)
%29 = load i8*, i8** %4
%30 = call i32 @get_token_value(i8* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %26, i32 %28, i32 %30)
%32 = load i32*, i32** %3
%33 = call i8* @get_lexeme(i32* %32)
store i8* %33, i8** %4
%34 = load i8*, i8** %4
%35 = load i8*, i8** %4
%36 = call i32 @get_token_name(i8* %35)
%37 = load i8*, i8** %4
%38 = call i32 @get_token_value(i8* %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %34, i32 %36, i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"test.c\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [53 x i8] c"\0A\0AGet Token: '%s', token_name: %d, token_value: %d\0A\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i8* @get_lexeme(i32* %1)
%3 = tail call i32 @get_token_name(i8* %2)
%4 = tail call i32 @get_token_value(i8* %2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %3, i32 %4)
%6 = tail call i8* @get_lexeme(i32* %1)
%7 = tail call i32 @get_token_name(i8* %6)
%8 = tail call i32 @get_token_value(i8* %6)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 %7, i32 %8)
%10 = tail call i32 @free(i8* %6)
%11 = tail call i8* @get_lexeme(i32* %1)
%12 = tail call i32 @get_token_name(i8* %11)
%13 = tail call i32 @get_token_value(i8* %11)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %11, i32 %12, i32 %13)
%15 = tail call i8* @get_lexeme(i32* %1)
%16 = tail call i32 @get_token_name(i8* %15)
%17 = tail call i32 @get_token_value(i8* %15)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %15, i32 %16, i32 %17)
ret i32 0
}