#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 */
typedef int /*<<< orphan*/ operation;

/* Variables and functions */
int /*<<< orphan*/ clearerr(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char printPrompt() {
  char operation[3];
  printf("\n-----------------------------\n1. Matrix input and output\n2. "
         "Matrix Addition\n3. Exit\n\nPlease choose an operation: ");
  if (fgets(operation, sizeof(operation), stdin) != NULL) {
    if (strchr(operation, '\n')) {
      return operation[0];
    } else {
      do {
        fgets(operation, sizeof(operation), stdin);
      } while (!strchr(operation, '\n'));
      strcpy(operation, "");
    }
  }
  if (feof(stdin)) {
    clearerr(stdin);
    printf("\n");
  }
  return operation[0];
}


x86 assembly (clang, -O0):
<printPrompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    -0x4(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1208 <printPrompt+0xa8>
lea    -0x4(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11b8 <printPrompt+0x58>
mov    -0x4(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    1240 <printPrompt+0xe0>
jmp    11bd <printPrompt+0x5d>
lea    -0x4(%rbp),%rdi
mov    0x2e20(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1060 <fgets@plt>
lea    -0x4(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11bd <printPrompt+0x5d>
lea    -0x4(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1208 <printPrompt+0xa8>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     123a <printPrompt+0xda>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1080 <clearerr@plt>
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPrompt>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e61(%rip),%r14
mov    (%r14),%edx
lea    0x5(%rsp),%rdi
mov    $0x3,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11f3 <printPrompt+0x83>
lea    0x5(%rsp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1212 <printPrompt+0xa2>
lea    0x5(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11c0 <printPrompt+0x50>
lea    0xe89(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcpy@plt>
mov    (%r14),%edi
call   1080 <feof@plt>
test   %rax,%rax
je     1212 <printPrompt+0xa2>
mov    (%r14),%edi
call   1090 <clearerr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x5(%rsp),%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [115 x i8] c"\0A-----------------------------\0A1. Matrix input and output\0A2. Matrix Addition\0A3. Exit\0A\0APlease choose an operation: \00"
@stdin = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
define signext i8 @printPrompt() {
%1 = alloca i8
%2 = alloca [3 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 3, i32 %5)
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %29
8: ; preds = %0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%10 = call i64 @strchr(i8* %9, i8 signext 10)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
store i8 %14, i8* %1
br label %40
15: ; preds = %8
br label %16
16: ; preds = %20, %15
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32* @fgets(i8* %17, i32 3, i32 %18)
br label %20
20: ; preds = %16
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%22 = call i64 @strchr(i8* %21, i8 signext 10)
%23 = icmp ne i64 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %16, label %25
25: ; preds = %20
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25
br label %29
29: ; preds = %28, %0
%30 = load i32, i32* @stdin
%31 = call i64 @feof(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stdin
%35 = call i32 @clearerr(i32 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %33, %29
%38 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%39 = load i8, i8* %38
store i8 %39, i8* %1
br label %40
40: ; preds = %37, %12
%41 = load i8, i8* %1
ret i8 %41
}

LLVM IR (-O2):
@.str = [115 x i8] c"\0A-----------------------------\0A1. Matrix input and output\0A2. Matrix Addition\0A3. Exit\0A\0APlease choose an operation: \00"
@stdin = global i32 0
@.str.1 = [1 x i8] zeroinitializer
define signext i8 @printPrompt() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %2, i32 3, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %19, label %7
7: ; preds = %0
%8 = call i64 @strchr(i8* %2, i8 signext 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = load i8, i8* %2
br label %29
12: ; preds = %7, %12
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %2, i32 3, i32 %13)
%15 = call i64 @strchr(i8* %2, i8 signext 10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12
%18 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %0
%20 = load i32, i32* @stdin
%21 = call i64 @feof(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32, i32* @stdin
%25 = call i32 @clearerr(i32 %24)
%26 = call i32 @putchar(i32 10)
br label %27
27: ; preds = %23, %19
%28 = load i8, i8* %2
br label %29
29: ; preds = %27, %10
%30 = phi i8 [ %11, %10 ], [ %28, %27 ]
ret i8 %30
}