#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*/ printf(char *);
int readnum(char *, int, int *);
int select_menu_choice(char *buf, int buf_size) {
  int choice = 0;
  printf("Make a selection: \n"
         "1. Input Matrix\n"
         "2. Print Matrix\n"
         "3. Add Matrices\n"
         "4. Subtract Matrices\n"
         "5. Multiply Matrices\n"
         "6. Swap Matrix Row\n"
         "7. Swap Matrix Col\n"
         "8. Transpose Matrix\n"
         "9. Perform Reduced Row Echelon Form on Matrix\n"
         "10. Randomize Matrix\n"
         "11. Exit\n"
         ">> ");
  if (readnum(buf, buf_size, &choice) == 1)
    return 11;
  else
    return choice;
}


x86 assembly (clang, -O0):
<select_menu_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdx
call   1030 <readnum@plt>
cmp    $0x1,%eax
jne    1167 <select_menu_choice+0x47>
movl   $0xb,-0x4(%rbp)
jmp    116d <select_menu_choice+0x4d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_menu_choice>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <readnum@plt>
mov    %eax,%ecx
mov    $0xb,%eax
cmp    $0x1,%ecx
je     115b <select_menu_choice+0x3b>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [247 x i8] c"Make a selection: \0A1. Input Matrix\0A2. Print Matrix\0A3. Add Matrices\0A4. Subtract Matrices\0A5. Multiply Matrices\0A6. Swap Matrix Row\0A7. Swap Matrix Col\0A8. Transpose Matrix\0A9. Perform Reduced Row Echelon Form on Matrix\0A10. Randomize Matrix\0A11. Exit\0A>> \00"
define i32 @select_menu_choice(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([247 x i8], [247 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i32 @readnum(i8* %8, i32 %9, i32* %6)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 11, i32* %3
br label %15
13: ; preds = %2
%14 = load i32, i32* %6
store i32 %14, i32* %3
br label %15
15: ; preds = %13, %12
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [247 x i8] c"Make a selection: \0A1. Input Matrix\0A2. Print Matrix\0A3. Add Matrices\0A4. Subtract Matrices\0A5. Multiply Matrices\0A6. Swap Matrix Row\0A7. Swap Matrix Col\0A8. Transpose Matrix\0A9. Perform Reduced Row Echelon Form on Matrix\0A10. Randomize Matrix\0A11. Exit\0A>> \00"
define i32 @select_menu_choice(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([247 x i8], [247 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @readnum(i8* %0, i32 %1, i32* %3)
%7 = icmp eq i32 %6, 1
%8 = load i32, i32* %3
%9 = select i1 %7, i32 11, i32 %8
ret i32 %9
}