#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*/ addcase(int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ match(char *);
int /*<<< orphan*/ number(int *);
int /*<<< orphan*/ quoted_char(int *);
scalar_t__ readswitch();
docase() {
  int val;
  val = 0;
  if (readswitch()) {
    if (!number(&val))
      if (!quoted_char(&val))
        error("bad case label");
    addcase(val);
    if (!match(":"))
      error("missing colon");
  } else
    error("no active switch");
}


x86 assembly (clang, -O0):
<docase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <readswitch@plt>
cmp    $0x0,%rax
je     11e3 <docase+0x83>
lea    -0x8(%rbp),%rdi
call   1050 <number@plt>
cmp    $0x0,%eax
jne    11b5 <docase+0x55>
lea    -0x8(%rbp),%rdi
call   1030 <quoted_char@plt>
cmp    $0x0,%eax
jne    11b0 <docase+0x50>
lea    0xe55(%rip),%rdi
call   1080 <error@plt>
jmp    11b5 <docase+0x55>
mov    -0x8(%rbp),%edi
call   1060 <addcase@plt>
lea    0xe4b(%rip),%rdi
call   1070 <match@plt>
cmp    $0x0,%eax
jne    11de <docase+0x7e>
lea    0xe38(%rip),%rdi
call   1080 <error@plt>
jmp    11ef <docase+0x8f>
lea    0xe35(%rip),%rdi
call   1080 <error@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<docase>:
push   %rax
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1040 <readswitch@plt>
test   %rax,%rax
je     11b8 <docase+0x58>
lea    0x4(%rsp),%rdi
call   1050 <number@plt>
test   %eax,%eax
jne    119d <docase+0x3d>
lea    0x4(%rsp),%rdi
call   1030 <quoted_char@plt>
test   %eax,%eax
jne    119d <docase+0x3d>
lea    0xe68(%rip),%rdi
call   1080 <error@plt>
mov    0x4(%rsp),%edi
call   1060 <addcase@plt>
lea    0xe62(%rip),%rdi
call   1070 <match@plt>
test   %eax,%eax
je     11c1 <docase+0x61>
pop    %rcx
ret
lea    0xe60(%rip),%rdi
jmp    11c8 <docase+0x68>
lea    0xe49(%rip),%rdi
call   1080 <error@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"bad case label\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [14 x i8] c"missing colon\00"
@.str.3 = [17 x i8] c"no active switch\00"
define i32 @docase() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = call i64 (...) @readswitch()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %0
%6 = call i32 @number(i32* %2)
%7 = icmp ne i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = call i32 @quoted_char(i32* %2)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
br label %14
14: ; preds = %13, %5
%15 = load i32, i32* %2
%16 = call i32 @addcase(i32 %15)
%17 = call i32 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
br label %24
22: ; preds = %0
%23 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [15 x i8] c"bad case label\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [14 x i8] c"missing colon\00"
@.str.3 = [17 x i8] c"no active switch\00"
define i32 @docase() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i64 (...) @readswitch()
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %0
%6 = call i32 @number(i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = call i32 @quoted_char(i32* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %8, %11, %5
%14 = load i32, i32* %1
%15 = call i32 @addcase(i32 %14)
%16 = call i32 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %22
20: ; preds = %0
%21 = tail call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %13, %18, %20
ret i32 undef
}