#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 scanf(char *, int *, char *);
int getDraws(int max) {
  int inputInvalid, numbers;
  char c;
  do {
    printf("Wieviele werden davon gezogen (mind. 1 und max. %d): ", max);
    inputInvalid = scanf("%d%c", &numbers, &c) != 2 || c != '\n';
    inputInvalid |= numbers < 1 || numbers > max;
    if (inputInvalid)
      printf("Eingabe ungueltig!\n");
  } while (inputInvalid);
  return numbers;
}


x86 assembly (clang, -O0):
<getDraws>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0xd(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0xe(%rbp)
jne    116d <getDraws+0x4d>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0xf(%rbp)
jl     1193 <getDraws+0x73>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
setg   %al
mov    %al,-0xf(%rbp)
mov    -0xf(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b9 <getDraws+0x99>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <getDraws+0x9e>
cmpl   $0x0,-0x8(%rbp)
jne    112b <getDraws+0xb>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDraws>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xebc(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x3(%rsp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    117b <getDraws+0x4b>
cmpb   $0xa,0x3(%rsp)
jne    117b <getDraws+0x4b>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    117b <getDraws+0x4b>
cmp    %ebx,%eax
jle    11da <getDraws+0xaa>
lea    0xeb9(%rip),%r14
lea    0xe77(%rip),%r15
lea    0xea6(%rip),%r12
lea    0x4(%rsp),%r13
lea    0x3(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11a0 <getDraws+0x70>
cmpb   $0xa,0x3(%rsp)
jne    11a0 <getDraws+0x70>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11a0 <getDraws+0x70>
cmp    %ebx,%eax
jg     11a0 <getDraws+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Wieviele werden davon gezogen (mind. 1 und max. %d): \00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [20 x i8] c"Eingabe ungueltig!\0A\00"
define i32 @getDraws(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %2
br label %6
6: ; preds = %34, %1
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i8* %5)
%10 = icmp ne i32 %9, 2
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br label %15
15: ; preds = %11, %6
%16 = phi i1 [ true, %6 ], [ %14, %11 ]
%17 = zext i1 %16 to i32
store i32 %17, i32* %3
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 1
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp sgt i32 %21, %22
br label %24
24: ; preds = %20, %15
%25 = phi i1 [ true, %15 ], [ %23, %20 ]
%26 = zext i1 %25 to i32
%27 = load i32, i32* %3
%28 = or i32 %27, %26
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 0
br i1 %36, label %6, label %37
37: ; preds = %34
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [54 x i8] c"Wieviele werden davon gezogen (mind. 1 und max. %d): \00"
@.str.1 = [5 x i8] c"%d%c\00"
@str = [19 x i8] c"Eingabe ungueltig!\00"
define i32 @getDraws(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %3)
%7 = icmp ne i32 %6, 2
%8 = load i8, i8* %3
%9 = icmp ne i8 %8, 10
%10 = select i1 %7, i1 true, i1 %9
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1
%13 = icmp sgt i32 %11, %0
%14 = or i1 %12, %13
%15 = or i1 %10, %14
br i1 %15, label %16, label %29
16: ; preds = %1, %16
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %0)
%19 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %3)
%20 = icmp ne i32 %19, 2
%21 = load i8, i8* %3
%22 = icmp ne i8 %21, 10
%23 = select i1 %20, i1 true, i1 %22
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 1
%26 = icmp sgt i32 %24, %0
%27 = or i1 %25, %26
%28 = or i1 %23, %27
br i1 %28, label %16, label %29
29: ; preds = %16, %1
%30 = phi i32 [ %11, %1 ], [ %24, %16 ]
ret i32 %30
}