#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*/ isdelim(int);
int read_char(int /*<<< orphan*/ *);
void read_token(FILE *rfile, char *token, int *delim) {
  int n;
  *token = '\0';
  while ((n = read_char(rfile)) == ' ')
    ;
  while (!isdelim(n) && !(n == ' ')) {
    *(token++) = n;
    n = read_char(rfile);
  }
  *token = '\0';
  *delim = n;
  if (*delim == '{')
    *delim = '[';
  if (*delim == '}')
    *delim = ']';
}


x86 assembly (clang, -O0):
<read_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <read_char@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x20,%eax
jne    1155 <read_token+0x35>
jmp    113b <read_token+0x1b>
jmp    115a <read_token+0x3a>
mov    -0x1c(%rbp),%edi
call   1040 <isdelim@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
jne    117e <read_token+0x5e>
cmpl   $0x20,-0x1c(%rbp)
sete   %al
xor    $0xff,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    118e <read_token+0x6e>
jmp    11b5 <read_token+0x95>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <read_char@plt>
mov    %eax,-0x1c(%rbp)
jmp    115a <read_token+0x3a>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x7b,(%rax)
jne    11dc <read_token+0xbc>
mov    -0x18(%rbp),%rax
movl   $0x5b,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x7d,(%rax)
jne    11f3 <read_token+0xd3>
mov    -0x18(%rbp),%rax
movl   $0x5d,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_token>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movb   $0x0,(%rsi)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <read_char@plt>
cmp    $0x20,%eax
je     1140 <read_token+0x20>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isdelim@plt>
cs nopw 0x0(%rax,%rax,1)
test   %eax,%eax
jne    1181 <read_token+0x61>
mov    %bpl,(%rbx)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <read_char@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isdelim@plt>
cmp    $0x20,%ebp
jne    1160 <read_token+0x40>
movb   $0x0,(%rbx)
cmp    $0x7b,%ebp
mov    $0x5b,%eax
cmovne %ebp,%eax
cmp    $0x7d,%eax
mov    $0x5d,%ecx
cmovne %eax,%ecx
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @read_token(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %5
store i8 0, i8* %8
br label %9
9: ; preds = %13, %3
%10 = load i32*, i32** %4
%11 = call i32 @read_char(i32* %10)
store i32 %11, i32* %7
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %14
13: ; preds = %9
br label %9
14: ; preds = %9
br label %15
15: ; preds = %25, %14
%16 = load i32, i32* %7
%17 = call i32 @isdelim(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 32
%22 = xor i1 %21, true
br label %23
23: ; preds = %19, %15
%24 = phi i1 [ false, %15 ], [ %22, %19 ]
br i1 %24, label %25, label %32
25: ; preds = %23
%26 = load i32, i32* %7
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
store i8 %27, i8* %28
%30 = load i32*, i32** %4
%31 = call i32 @read_char(i32* %30)
store i32 %31, i32* %7
br label %15
32: ; preds = %23
%33 = load i8*, i8** %5
store i8 0, i8* %33
%34 = load i32, i32* %7
%35 = load i32*, i32** %6
store i32 %34, i32* %35
%36 = load i32*, i32** %6
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 123
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = load i32*, i32** %6
store i32 91, i32* %40
br label %41
41: ; preds = %39, %32
%42 = load i32*, i32** %6
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 125
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32*, i32** %6
store i32 93, i32* %46
br label %47
47: ; preds = %45, %41
ret void
}

LLVM IR (-O2):
define void @read_token(i32* %0, i8* nocapture writeonly %1, i32* nocapture writeonly %2) {
store i8 0, i8* %1
br label %4
4: ; preds = %4, %3
%5 = tail call i32 @read_char(i32* %0)
%6 = icmp eq i32 %5, 32
br i1 %6, label %4, label %7
7: ; preds = %4
%8 = tail call i32 @isdelim(i32 %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %7, %10
%11 = phi i32 [ %15, %10 ], [ %5, %7 ]
%12 = phi i8* [ %14, %10 ], [ %1, %7 ]
%13 = trunc i32 %11 to i8
%14 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %13, i8* %12
%15 = tail call i32 @read_char(i32* %0)
%16 = tail call i32 @isdelim(i32 %15)
%17 = icmp eq i32 %16, 0
%18 = icmp ne i32 %15, 32
%19 = and i1 %18, %17
br i1 %19, label %10, label %20
20: ; preds = %10, %7
%21 = phi i8* [ %1, %7 ], [ %14, %10 ]
%22 = phi i32 [ %5, %7 ], [ %15, %10 ]
store i8 0, i8* %21
%23 = icmp eq i32 %22, 123
%24 = select i1 %23, i32 91, i32 %22
%25 = icmp eq i32 %24, 125
%26 = select i1 %25, i32 93, i32 %24
store i32 %26, i32* %2
ret void
}