#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_space(void) {
  char inchar;
  c40_printf("\n");
  c40_printf("1) A32\n2) A24\n3) A16\n\n");
  c40_printf("Selection => ");
  while (1) {
    inchar = c40_getchar();
    if ((inchar >= 1) && (inchar <= 3)) {
      return (inchar - '1');
      c40_printf("\n");
    } else
      c40_printf("%c", 7);
  }
}


x86 assembly (clang, -O0):
<get_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
mov    $0x0,%al
call   1030 <c40_getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jl     1185 <get_space+0x65>
movsbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jg     1185 <get_space+0x65>
movsbl -0x1(%rbp),%eax
sub    $0x31,%eax
cltq
add    $0x10,%rsp
pop    %rbp
ret
lea    0xe99(%rip),%rdi
mov    $0x7,%esi
mov    $0x0,%al
call   1040 <c40_printf@plt>
jmp    1152 <get_space+0x32>

x86 assembly (clang, -O2):
<get_space>:
push   %rbx
lea    0xeed(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
mov    %eax,%ecx
add    $0xff,%cl
cmp    $0x3,%cl
jb     118e <get_space+0x6e>
lea    0xec2(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <c40_printf@plt>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
lea    -0x1(%rax),%ecx
cmp    $0x3,%cl
jae    1170 <get_space+0x50>
movzbl %al,%eax
add    $0xffffffffffffffcf,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [23 x i8] c"1) A32\0A2) A24\0A3) A16\0A\0A\00"
@.str.2 = [14 x i8] c"Selection => \00"
@.str.3 = [3 x i8] c"%c\00"
define i64 @get_space() {
%1 = alloca i8
%2 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([23 x i8], [23 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, %21
%6 = call signext i8 (...) @c40_getchar()
store i8 %6, i8* %1
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = load i8, i8* %1
%12 = sext i8 %11 to i32
%13 = icmp sle i32 %12, 3
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8, i8* %1
%16 = sext i8 %15 to i32
%17 = sub nsw i32 %16, 49
%18 = sext i32 %17 to i64
ret i64 %18
19: ; preds = %10, %5
%20 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 7)
br label %21
21: ; preds = %19
br label %5
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [23 x i8] c"1) A32\0A2) A24\0A3) A16\0A\0A\00"
@.str.2 = [14 x i8] c"Selection => \00"
@.str.3 = [3 x i8] c"%c\00"
define i64 @get_space() {
%1 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([23 x i8], [23 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))
%4 = tail call signext i8 (...) @c40_getchar()
%5 = add i8 %4, -1
%6 = icmp ult i8 %5, 3
br i1 %6, label %7, label %11
7: ; preds = %11, %0
%8 = phi i8 [ %4, %0 ], [ %13, %11 ]
%9 = zext i8 %8 to i64
%10 = add nuw nsw i64 %9, -49
ret i64 %10
11: ; preds = %0, %11
%12 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 7)
%13 = tail call signext i8 (...) @c40_getchar()
%14 = add i8 %13, -1
%15 = icmp ult i8 %14, 3
br i1 %15, label %7, label %11
}