#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ retrieve();
int /*<<< orphan*/ solve();
int /*<<< orphan*/ stdin;
void main_loop() {
  char input[16];
  while (1) {
    puts("<S>olve eqns or <R>etrieve result");
    fgets(input, 16, stdin);
    if (input[0] == 'S') {
      solve();
    } else if (input[0] == 'R') {
      retrieve();
    } else {
      return;
    }
  }
}


x86 assembly (clang, -O0):
<main_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    -0x10(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1060 <fgets@plt>
movsbl -0x10(%rbp),%eax
cmp    $0x53,%eax
jne    1184 <main_loop+0x44>
mov    $0x0,%al
call   1030 <solve@plt>
jmp    11a8 <main_loop+0x68>
movsbl -0x10(%rbp),%eax
cmp    $0x52,%eax
jne    119d <main_loop+0x5d>
mov    $0x0,%al
call   1050 <retrieve@plt>
jmp    11a3 <main_loop+0x63>
add    $0x10,%rsp
pop    %rbp
ret
jmp    11a8 <main_loop+0x68>
jmp    1148 <main_loop+0x8>

x86 assembly (clang, -O2):
<main_loop>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%r14
mov    0x2e91(%rip),%r15
mov    %rsp,%rbx
jmp    1167 <main_loop+0x27>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <retrieve@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1060 <fgets@plt>
movzbl (%rsp),%eax
cmp    $0x52,%al
je     1160 <main_loop+0x20>
cmp    $0x53,%al
jne    1194 <main_loop+0x54>
xor    %eax,%eax
call   1030 <solve@plt>
jmp    1167 <main_loop+0x27>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"<S>olve eqns or <R>etrieve result\00"
@stdin = global i32 0
define void @main_loop() {
%1 = alloca [16 x i8]
br label %2
2: ; preds = %0, %22
%3 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 16, i32 %5)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 83
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @solve()
br label %22
13: ; preds = %2
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 82
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 (...) @retrieve()
br label %21
20: ; preds = %13
ret void
21: ; preds = %18
br label %22
22: ; preds = %21, %11
br label %2
}

LLVM IR (-O2):
@.str = [34 x i8] c"<S>olve eqns or <R>etrieve result\00"
@stdin = global i32 0
define void @main_loop() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %12, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 16, i32 %5)
%7 = load i8, i8* %2
switch i8 %7, label %13 [
i8 83, label %8
i8 82, label %10
]
8: ; preds = %3
%9 = call i32 (...) @solve()
br label %12
10: ; preds = %3
%11 = call i32 (...) @retrieve()
br label %12
12: ; preds = %10, %8
br label %3
13: ; preds = %3
ret void
}