#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 */
char c40_getchar();
int /*<<< orphan*/ c40_printf(char *, ...);
unsigned long get_baud(void) {
  char inchar;
  c40_printf("\n\nBaud Rates :\n");
  c40_printf("  1) 150\n  2) 300\n  3) 600\n  4) 1200\n  5) 2400\n"
             "  6) 4800\n  7) 9600\n  8) 19200\n  R) Return");
  c40_printf("\n");
  c40_printf("Selection => ");
  while (1) {
    inchar = c40_getchar();
    if ((inchar >= '1') && (inchar <= '7'))
      switch (inchar) {
      case '1':
        return (150);
      case '2':
        return (300);
      case '3':
        return (600);
      case '4':
        return (1200);
      case '5':
        return (2400);
      case '6':
        return (4800);
      case '7':
        return (9600);
      case '8':
        return (19200);
      }
    else if ((inchar == 'r') || (inchar == 'R'))
      return (0);
    else
      c40_printf("%c", 7);
  }
}


x86 assembly (clang, -O0):
<get_baud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xf31(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
mov    $0x0,%al
call   1030 <c40_getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x31,%eax
jl     121b <get_baud+0xfb>
movsbl -0x9(%rbp),%eax
cmp    $0x37,%eax
jg     121b <get_baud+0xfb>
movsbl -0x9(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     1216 <get_baud+0xf6>
mov    -0x18(%rbp),%rax
lea    0xe5b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x96,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x12c,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x258,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x4b0,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x960,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x12c0,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x2580,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
movq   $0x4b00,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
jmp    125a <get_baud+0x13a>
movsbl -0x9(%rbp),%eax
cmp    $0x72,%eax
je     1235 <get_baud+0x115>
movsbl -0x9(%rbp),%eax
cmp    $0x52,%eax
jne    1242 <get_baud+0x122>
movq   $0x0,-0x8(%rbp)
jmp    125f <get_baud+0x13f>
lea    0xe4f(%rip),%rdi
mov    $0x7,%esi
mov    $0x0,%al
call   1040 <c40_printf@plt>
jmp    125a <get_baud+0x13a>
jmp    1160 <get_baud+0x40>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_baud>:
push   %r14
push   %rbx
push   %rax
lea    0xef1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xef0(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xf2e(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xf2e(%rip),%rbx
jmp    1172 <get_baud+0x52>
nopl   0x0(%rax,%rax,1)
jbe    1198 <get_baud+0x78>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
lea    -0x31(%rax),%ecx
cmp    $0x6,%cl
jbe    1170 <get_baud+0x50>
and    $0xdf,%al
cmp    $0x52,%al
je     11df <get_baud+0xbf>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <c40_printf@plt>
jmp    1172 <get_baud+0x52>
mov    $0x96,%r14d
movzbl %cl,%eax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x12c,%r14d
jmp    11df <get_baud+0xbf>
mov    $0x258,%r14d
jmp    11df <get_baud+0xbf>
mov    $0x4b0,%r14d
jmp    11df <get_baud+0xbf>
mov    $0x960,%r14d
jmp    11df <get_baud+0xbf>
mov    $0x12c0,%r14d
jmp    11df <get_baud+0xbf>
mov    $0x2580,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0A\0ABaud Rates :\0A\00"
@.str.1 = [90 x i8] c" 1) 150\0A 2) 300\0A 3) 600\0A 4) 1200\0A 5) 2400\0A 6) 4800\0A 7) 9600\0A 8) 19200\0A R) Return\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [14 x i8] c"Selection => \00"
@.str.4 = [3 x i8] c"%c\00"
define i64 @get_baud() {
%1 = alloca i64
%2 = alloca i8
%3 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %0, %40
%8 = call signext i8 (...) @c40_getchar()
store i8 %8, i8* %2
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp sge i32 %10, 49
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp sle i32 %14, 55
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %27 [
i32 49, label %19
i32 50, label %20
i32 51, label %21
i32 52, label %22
i32 53, label %23
i32 54, label %24
i32 55, label %25
i32 56, label %26
]
19: ; preds = %16
store i64 150, i64* %1
br label %41
20: ; preds = %16
store i64 300, i64* %1
br label %41
21: ; preds = %16
store i64 600, i64* %1
br label %41
22: ; preds = %16
store i64 1200, i64* %1
br label %41
23: ; preds = %16
store i64 2400, i64* %1
br label %41
24: ; preds = %16
store i64 4800, i64* %1
br label %41
25: ; preds = %16
store i64 9600, i64* %1
br label %41
26: ; preds = %16
store i64 19200, i64* %1
br label %41
27: ; preds = %16
br label %40
28: ; preds = %12, %7
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 114
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 82
br i1 %35, label %36, label %37
36: ; preds = %32, %28
store i64 0, i64* %1
br label %41
37: ; preds = %32
%38 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 7)
br label %39
39: ; preds = %37
br label %40
40: ; preds = %39, %27
br label %7
41: ; preds = %36, %26, %25, %24, %23, %22, %21, %20, %19
%42 = load i64, i64* %1
ret i64 %42
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0A\0ABaud Rates :\0A\00"
@.str.1 = [90 x i8] c" 1) 150\0A 2) 300\0A 3) 600\0A 4) 1200\0A 5) 2400\0A 6) 4800\0A 7) 9600\0A 8) 19200\0A R) Return\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [14 x i8] c"Selection => \00"
@.str.4 = [3 x i8] c"%c\00"
define i64 @get_baud() {
%1 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %5
5: ; preds = %10, %0
%6 = tail call signext i8 (...) @c40_getchar()
%7 = add i8 %6, -49
%8 = icmp ult i8 %7, 7
br i1 %8, label %9, label %12
9: ; preds = %5
switch i8 %6, label %10 [
i8 49, label %17
i8 50, label %19
i8 51, label %20
i8 52, label %21
i8 53, label %22
i8 54, label %23
i8 55, label %11
]
10: ; preds = %9, %15
br label %5
11: ; preds = %9
br label %23
12: ; preds = %5
%13 = and i8 %6, -33
%14 = icmp eq i8 %13, 82
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 7)
br label %10
17: ; preds = %9, %12
%18 = phi i64 [ 0, %12 ], [ 150, %9 ]
br label %23
19: ; preds = %9
br label %23
20: ; preds = %9
br label %23
21: ; preds = %9
br label %23
22: ; preds = %9
br label %23
23: ; preds = %9, %22, %21, %20, %19, %17, %11
%24 = phi i64 [ 9600, %11 ], [ %18, %17 ], [ 300, %19 ], [ 600, %20 ], [ 1200, %21 ], [ 2400, %22 ], [ 4800, %9 ]
ret i64 %24
}