#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();
void docase(void) {
  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,-0x4(%rbp)
mov    $0x0,%al
call   1040 <readswitch@plt>
cmp    $0x0,%rax
je     11e3 <docase+0x83>
lea    -0x4(%rbp),%rdi
call   1050 <number@plt>
cmp    $0x0,%eax
jne    11b5 <docase+0x55>
lea    -0x4(%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    -0x4(%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>
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     11c5 <docase+0x65>
pop    %rax
ret
lea    0xe60(%rip),%rdi
pop    %rax
jmp    1080 <error@plt>
lea    0xe45(%rip),%rdi
call   1080 <error@plt>
pop    %rax
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 void @docase() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @readswitch()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %0
%5 = call i32 @number(i32* %1)
%6 = icmp ne i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = call i32 @quoted_char(i32* %1)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
br label %13
13: ; preds = %12, %4
%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 ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
br label %23
21: ; preds = %0
%22 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %20
ret void
}

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 void @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 void
}