#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int scanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
char getCommand() {
  int inputinvalid;
  char command, c;
  do {
    printf("Bitte Operation eingeben (+/-): ");
    inputinvalid = scanf("%c%c", &command, &c) != 2 || c != '\n';
    fflush(stdin);
    inputinvalid = !(command == '+' || command == '-');
    if (inputinvalid)
      printf("Ungueltige Eingabe!\n");
  } while (inputinvalid);
  return command;
}


x86 assembly (clang, -O0):
<getCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0x6(%rbp),%rdx
call   1050 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0x7(%rbp)
jne    1175 <getCommand+0x45>
movsbl -0x6(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x2b,%ecx
mov    %al,-0x8(%rbp)
je     11ad <getCommand+0x7d>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11d0 <getCommand+0xa0>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <getCommand+0xa5>
cmpl   $0x0,-0x4(%rbp)
jne    1138 <getCommand+0x8>
movsbl -0x5(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%r14
lea    0xec8(%rip),%r15
lea    0x6(%rsp),%r12
lea    0x7(%rsp),%rbx
mov    0x2e7e(%rip),%rbp
lea    0xeb5(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0x0(%rbp),%edi
call   1050 <fflush@plt>
movzbl 0x6(%rsp),%eax
cmp    $0x2b,%al
je     11b5 <getCommand+0x75>
cmp    $0x2d,%al
je     11b5 <getCommand+0x75>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1180 <getCommand+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Bitte Operation eingeben (+/-): \00"
@.str.1 = [5 x i8] c"%c%c\00"
@stdin = global i32 0
@.str.2 = [21 x i8] c"Ungueltige Eingabe!\0A\00"
define signext i8 @getCommand() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
br label %4
4: ; preds = %33, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3)
%7 = icmp ne i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br label %12
12: ; preds = %8, %4
%13 = phi i1 [ true, %4 ], [ %11, %8 ]
%14 = zext i1 %13 to i32
store i32 %14, i32* %1
%15 = load i32, i32* @stdin
%16 = call i32 @fflush(i32 %15)
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 43
br i1 %19, label %24, label %20
20: ; preds = %12
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br label %24
24: ; preds = %20, %12
%25 = phi i1 [ true, %12 ], [ %23, %20 ]
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
store i32 %27, i32* %1
%28 = load i32, i32* %1
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %1
%35 = icmp ne i32 %34, 0
br i1 %35, label %4, label %36
36: ; preds = %33
%37 = load i8, i8* %2
ret i8 %37
}

LLVM IR (-O2):
@.str = [33 x i8] c"Bitte Operation eingeben (+/-): \00"
@.str.1 = [5 x i8] c"%c%c\00"
@stdin = global i32 0
@str = [20 x i8] c"Ungueltige Eingabe!\00"
define signext i8 @getCommand() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %9, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%6 = load i32, i32* @stdin
%7 = call i32 @fflush(i32 %6)
%8 = load i8, i8* %1
switch i8 %8, label %9 [
i8 45, label %11
i8 43, label %11
]
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %3
11: ; preds = %3, %3
ret i8 %8
}