#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ isdelim(int);
int read_char(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void read_delim(FILE *rfile, int *delim) {
  int n;
  while ((n = read_char(rfile)) == ' ')
    ;
  if (!isdelim(n)) {
    fprintf(stderr, "#Input error: delimiter expected (not %c).\n", n);
    exit(1);
  }
  *delim = n;
  if (*delim == '{')
    *delim = '[';
  if (*delim == '}')
    *delim = ']';
}


x86 assembly (clang, -O0):
<read_delim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <read_char@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x20,%eax
jne    116a <read_delim+0x2a>
jmp    1150 <read_delim+0x10>
mov    -0x14(%rbp),%edi
call   1060 <isdelim@plt>
cmp    $0x0,%eax
jne    119d <read_delim+0x5d>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe72(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x7b,(%rax)
jne    11bd <read_delim+0x7d>
mov    -0x10(%rbp),%rax
movl   $0x5b,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x7d,(%rax)
jne    11d4 <read_delim+0x94>
mov    -0x10(%rbp),%rax
movl   $0x5d,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_delim>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <read_char@plt>
cmp    $0x20,%eax
je     1150 <read_delim+0x10>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <isdelim@plt>
test   %eax,%eax
je     1188 <read_delim+0x48>
cmp    $0x7b,%ebp
mov    $0x5b,%eax
cmovne %ebp,%eax
cmp    $0x7d,%eax
mov    $0x5d,%ecx
cmovne %eax,%ecx
mov    %ecx,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
mov    %ebp,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"#Input error: delimiter expected (not %c).\0A\00"
define void @read_delim(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %10, %2
%7 = load i32*, i32** %3
%8 = call i32 @read_char(i32* %7)
store i32 %8, i32* %5
%9 = icmp eq i32 %8, 32
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
%12 = load i32, i32* %5
%13 = call i32 @isdelim(i32 %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i32, i32* %5
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %11
%21 = load i32, i32* %5
%22 = load i32*, i32** %4
store i32 %21, i32* %22
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 123
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i32*, i32** %4
store i32 91, i32* %27
br label %28
28: ; preds = %26, %20
%29 = load i32*, i32** %4
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 125
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32*, i32** %4
store i32 93, i32* %33
br label %34
34: ; preds = %32, %28
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"#Input error: delimiter expected (not %c).\0A\00"
define void @read_delim(i32* %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @read_char(i32* %0)
%5 = icmp eq i32 %4, 32
br i1 %5, label %3, label %6
6: ; preds = %3
%7 = tail call i32 @isdelim(i32 %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %4)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = icmp eq i32 %4, 123
%15 = select i1 %14, i32 91, i32 %4
%16 = icmp eq i32 %15, 125
%17 = select i1 %16, i32 93, i32 %15
store i32 %17, i32* %1
ret void
}