#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*/ baz(char *, ...);
unsigned int foo(char x) {
  baz("x %c\n", x);
  switch (x) {
  default:
    baz("case default\n");
    if (x == 'D' || x == 'I')
      baz("This should never be reached.\n");
    return 0;
  case 'D':
    baz("case 'D'\n");
    return 0;
  case 'I':
    baz("case 'I'\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <baz@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x44,%eax
je     1198 <foo+0x88>
jmp    1145 <foo+0x35>
mov    -0xc(%rbp),%eax
sub    $0x49,%eax
je     11b2 <foo+0xa2>
jmp    1156 <foo+0x46>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <baz@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x44,%eax
je     117e <foo+0x6e>
movsbl -0x5(%rbp),%eax
cmp    $0x49,%eax
jne    118c <foo+0x7c>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <baz@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <foo+0xb7>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <baz@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <foo+0xb7>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <baz@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <baz@plt>
cmp    $0x44,%ebx
je     1136 <foo+0x26>
cmp    $0x49,%ebx
jne    113f <foo+0x2f>
lea    0xf09(%rip),%rdi
jmp    115e <foo+0x4e>
lea    0xef6(%rip),%rdi
jmp    115e <foo+0x4e>
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <baz@plt>
lea    0xec0(%rip),%rdi
cmp    $0x44,%bl
je     115e <foo+0x4e>
cmp    $0x49,%bl
jne    1165 <foo+0x55>
xor    %eax,%eax
call   1030 <baz@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"x %c\0A\00"
@.str.1 = [14 x i8] c"case default\0A\00"
@.str.2 = [31 x i8] c"This should never be reached.\0A\00"
@.str.3 = [10 x i8] c"case 'D'\0A\00"
@.str.4 = [10 x i8] c"case 'I'\0A\00"
define i32 @foo(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
switch i32 %8, label %9 [
i32 68, label %21
i32 73, label %23
]
9: ; preds = %1
%10 = call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 68
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 73
br i1 %17, label %18, label %20
18: ; preds = %14, %9
%19 = call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
store i32 0, i32* %2
br label %25
21: ; preds = %1
%22 = call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %25
23: ; preds = %1
%24 = call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %25
25: ; preds = %23, %21, %20
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"x %c\0A\00"
@.str.1 = [14 x i8] c"case default\0A\00"
@.str.2 = [31 x i8] c"This should never be reached.\0A\00"
@.str.3 = [10 x i8] c"case 'D'\0A\00"
@.str.4 = [10 x i8] c"case 'I'\0A\00"
define i32 @foo(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = tail call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %2)
switch i32 %2, label %4 [
i32 68, label %7
i32 73, label %6
]
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @baz(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
switch i8 %0, label %10 [
i8 73, label %7
i8 68, label %7
]
6: ; preds = %1
br label %7
7: ; preds = %1, %4, %4, %6
%8 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %1 ]
%9 = tail call i32 (i8*, ...) @baz(i8* %8)
br label %10
10: ; preds = %7, %4
ret i32 0
}