#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 *, int *);
int /*<<< orphan*/ stdin;
int getOperatingBit() {
  int retbyte;
  int inputInvalid = 1;
  do {
    printf("Auf welche Bitposition soll sich die Operation beziehen? (7..0): ");
    inputInvalid = scanf("%d", &retbyte) != 1;
    fflush(stdin);
    inputInvalid = retbyte < 0 || retbyte > 7;
    if (inputInvalid)
      printf("Die Eingabe ist ungueltig.\n");
  } while (inputInvalid);
  return retbyte;
}


x86 assembly (clang, -O0):
<getOperatingBit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jl     1190 <getOperatingBit+0x60>
cmpl   $0x7,-0x4(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b1 <getOperatingBit+0x81>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <getOperatingBit+0x86>
cmpl   $0x0,-0x8(%rbp)
jne    113f <getOperatingBit+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOperatingBit>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e77(%rip),%r13
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    0xc(%rsp),%eax
cmp    $0x8,%eax
jb     11cd <getOperatingBit+0x8d>
lea    0xebb(%rip),%r14
lea    0xe6f(%rip),%r15
lea    0xeaa(%rip),%r12
lea    0xc(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    0xc(%rsp),%eax
cmp    $0x7,%eax
ja     11a0 <getOperatingBit+0x60>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Auf welche Bitposition soll sich die Operation beziehen? (7..0): \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.2 = [28 x i8] c"Die Eingabe ist ungueltig.\0A\00"
define i32 @getOperatingBit() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
br label %3
3: ; preds = %23, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = icmp ne i32 %5, 1
%7 = zext i1 %6 to i32
store i32 %7, i32* %2
%8 = load i32, i32* @stdin
%9 = call i32 @fflush(i32 %8)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 7
br label %15
15: ; preds = %12, %3
%16 = phi i1 [ true, %3 ], [ %14, %12 ]
%17 = zext i1 %16 to i32
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
br label %23
23: ; preds = %22
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %3, label %26
26: ; preds = %23
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [66 x i8] c"Auf welche Bitposition soll sich die Operation beziehen? (7..0): \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@str = [27 x i8] c"Die Eingabe ist ungueltig.\00"
define i32 @getOperatingBit() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* %1
%8 = icmp ugt i32 %7, 7
br i1 %8, label %9, label %17
9: ; preds = %0, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* @stdin
%14 = call i32 @fflush(i32 %13)
%15 = load i32, i32* %1
%16 = icmp ugt i32 %15, 7
br i1 %16, label %9, label %17
17: ; preds = %9, %0
%18 = phi i32 [ %7, %0 ], [ %15, %9 ]
ret i32 %18
}