#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 c40_getchar();
int /*<<< orphan*/ c40_printf(char *, ...);
unsigned long get_clock(void) {
  c40_printf("\n\n");
  c40_printf("1) 40 MHz\n2) 50 MHz\n");
  c40_printf("Selection => ");
  while (1) {
    switch (c40_getchar()) {
    case '1':
      c40_printf("\n");
      return ((unsigned long)40);
    case '2':
      c40_printf("\n");
      return ((unsigned long)50);
    default:
      c40_printf("%c", 7);
    }
  }
}


x86 assembly (clang, -O0):
<get_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
sub    $0x31,%eax
je     117d <get_clock+0x5d>
jmp    116c <get_clock+0x4c>
mov    -0xc(%rbp),%eax
sub    $0x32,%eax
je     1198 <get_clock+0x78>
jmp    11b3 <get_clock+0x93>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
movq   $0x28,-0x8(%rbp)
jmp    11cb <get_clock+0xab>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
movq   $0x32,-0x8(%rbp)
jmp    11cb <get_clock+0xab>
lea    0xe6c(%rip),%rdi
mov    $0x7,%esi
mov    $0x0,%al
call   1040 <c40_printf@plt>
jmp    1152 <get_clock+0x32>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_clock>:
push   %rbx
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xed4(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <c40_getchar@plt>
cmp    $0x31,%eax
je     1182 <get_clock+0x62>
cmp    $0x32,%eax
je     1189 <get_clock+0x69>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <c40_printf@plt>
jmp    1160 <get_clock+0x40>
mov    $0x28,%ebx
jmp    118e <get_clock+0x6e>
mov    $0x32,%ebx
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [21 x i8] c"1) 40 MHz\0A2) 50 MHz\0A\00"
@.str.2 = [14 x i8] c"Selection => \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"%c\00"
define i64 @get_clock() {
%1 = alloca i64
%2 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %0, %13
%6 = call i32 (...) @c40_getchar()
switch i32 %6, label %11 [
i32 49, label %7
i32 50, label %9
]
7: ; preds = %5
%8 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i64 40, i64* %1
br label %14
9: ; preds = %5
%10 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i64 50, i64* %1
br label %14
11: ; preds = %5
%12 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 7)
br label %13
13: ; preds = %11
br label %5
14: ; preds = %9, %7
%15 = load i64, i64* %1
ret i64 %15
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [21 x i8] c"1) 40 MHz\0A2) 50 MHz\0A\00"
@.str.2 = [14 x i8] c"Selection => \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"%c\00"
define i64 @get_clock() {
%1 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %4
4: ; preds = %0, %6
%5 = tail call i32 (...) @c40_getchar()
switch i32 %5, label %6 [
i32 49, label %9
i32 50, label %8
]
6: ; preds = %4
%7 = 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 %4
8: ; preds = %4
br label %9
9: ; preds = %4, %8
%10 = phi i64 [ 50, %8 ], [ 40, %4 ]
%11 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i64 %10
}