#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 */
#define B1200 134
#define B1800 133
#define B2400 132
#define B300 131
#define B4800 130
#define B600 129
#define B9600 128
int /*<<< orphan*/ printf(char *);
void showbaud(int thespeed) {
  printf("The baud rate is");
  switch (thespeed) {
  case B300:
    printf("300\n");
    break;
  case B600:
    printf("600\n");
    break;
  case B1200:
    printf("1200\n");
    break;
  case B1800:
    printf("1800\n");
    break;
  case B2400:
    printf("2400\n");
    break;
  case B4800:
    printf("4800\n");
    break;
  case B9600:
    printf("9600\n");
    break;
  default:
    printf("Fast\n");
    break;
  }
}


x86 assembly (clang, -O0):
<showbaud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xefa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11c7 <showbaud+0xb7>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xee3(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <showbaud+0xc3>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showbaud>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
add    $0xffffff80,%ebx
cmp    $0x6,%ebx
ja     114e <showbaud+0x2e>
movslq %ebx,%rax
lea    0xef3(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xed9(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"The baud rate is\00"
@.str.1 = [5 x i8] c"300\0A\00"
@.str.2 = [5 x i8] c"600\0A\00"
@.str.3 = [6 x i8] c"1200\0A\00"
@.str.4 = [6 x i8] c"1800\0A\00"
@.str.5 = [6 x i8] c"2400\0A\00"
@.str.6 = [6 x i8] c"4800\0A\00"
@.str.7 = [6 x i8] c"9600\0A\00"
@.str.8 = [6 x i8] c"Fast\0A\00"
define void @showbaud(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %19 [
i32 131, label %5
i32 129, label %7
i32 134, label %9
i32 133, label %11
i32 132, label %13
i32 130, label %15
i32 128, label %17
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %21
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %21
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %21
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %21
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %21
17: ; preds = %1
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %21
19: ; preds = %1
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"The baud rate is\00"
@str = [5 x i8] c"9600\00"
@str.9 = [5 x i8] c"4800\00"
@str.10 = [5 x i8] c"2400\00"
@str.11 = [5 x i8] c"1800\00"
@str.12 = [5 x i8] c"1200\00"
@str.13 = [4 x i8] c"600\00"
@str.14 = [4 x i8] c"300\00"
@str.15 = [5 x i8] c"Fast\00"
@reltable.showbaud = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @str.13 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.9 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @str.14 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.10 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.11 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.12 to i64), i64 ptrtoint ([7 x i32]* @reltable.showbaud to i64)) to i32)]
define void @showbaud(i32 %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = add i32 %0, -128
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.showbaud to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.15, i64 0, i64 0), %1 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}