#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*/ Func_a();
int /*<<< orphan*/ Func_b();
int /*<<< orphan*/ Func_c();
int /*<<< orphan*/ Func_d();
void example_2(char ch) {
  int actr = 0;
  int bctr = 0;
  int cctr = 0;
  int dctr = 0;
  if (ch == 'a') {
    actr++;
    Func_a();
  }
  if (ch == 'b') {
    bctr++;
    Func_b();
  }
  if (ch == 'c') {
    cctr++;
    Func_c();
  }
  if (ch == 'd') {
    dctr++;
    Func_d();
  }
}


x86 assembly (clang, -O0):
<example_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jne    1187 <example_2+0x47>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <Func_a@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x62,%eax
jne    11a4 <example_2+0x64>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <Func_b@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x63,%eax
jne    11c1 <example_2+0x81>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <Func_c@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x64,%eax
jne    11de <example_2+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <Func_d@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example_2>:
add    $0x9f,%dil
cmp    $0x3,%dil
ja     1165 <example_2+0x25>
movzbl %dil,%eax
lea    0xeab(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
jmp    1060 <Func_a@plt>
ret
xor    %eax,%eax
jmp    1040 <Func_b@plt>
xor    %eax,%eax
jmp    1050 <Func_c@plt>
xor    %eax,%eax
jmp    1030 <Func_d@plt>

LLVM IR (-O0):
define void @example_2(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 97
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = call i32 (...) @Func_a()
br label %14
14: ; preds = %10, %1
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 98
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = call i32 (...) @Func_b()
br label %22
22: ; preds = %18, %14
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 99
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = call i32 (...) @Func_c()
br label %30
30: ; preds = %26, %22
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 100
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
%37 = call i32 (...) @Func_d()
br label %38
38: ; preds = %34, %30
ret void
}

LLVM IR (-O2):
define void @example_2(i8 signext %0) {
switch i8 %0, label %10 [
i8 97, label %2
i8 98, label %4
i8 99, label %6
i8 100, label %8
]
2: ; preds = %1
%3 = tail call i32 (...) @Func_a()
br label %10
4: ; preds = %1
%5 = tail call i32 (...) @Func_b()
br label %10
6: ; preds = %1
%7 = tail call i32 (...) @Func_c()
br label %10
8: ; preds = %1
%9 = tail call i32 (...) @Func_d()
br label %10
10: ; preds = %6, %4, %2, %1, %8
ret void
}