#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*/ fscanf(int /*<<< orphan*/, char *, int *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int getLetters(void) {
  int letters = -1;
  printf("How many letters should the word have? : ");
  fscanf(stdin, "%d", &letters);
  while (letters < 1 || letters > 29) {
    while (getchar() != '\n')
      ;
    printf("Please enter a valid number of letters: ");
    fscanf(stdin, "%d", &letters);
  }
  while (getchar() != '\n')
    ;
  return letters;
}


x86 assembly (clang, -O0):
<getLetters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <fscanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     117d <getLetters+0x4d>
cmpl   $0x1d,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    118d <getLetters+0x5d>
jmp    11d4 <getLetters+0xa4>
jmp    1192 <getLetters+0x62>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11aa <getLetters+0x7a>
jmp    1192 <getLetters+0x62>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <fscanf@plt>
jmp    1164 <getLetters+0x34>
jmp    11d9 <getLetters+0xa9>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11f1 <getLetters+0xc1>
jmp    11d9 <getLetters+0xa9>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLetters>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e95(%rip),%r12
mov    (%r12),%edi
lea    0xecc(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <fscanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffe2,%eax
cmp    $0xffffffe2,%eax
ja     11c0 <getLetters+0x90>
lea    0xeb2(%rip),%r14
lea    0xea8(%rip),%r15
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1190 <getLetters+0x60>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffe2,%eax
cmp    $0xffffffe3,%eax
jb     1190 <getLetters+0x60>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11c0 <getLetters+0x90>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"How many letters should the word have? : \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Please enter a valid number of letters: \00"
define i32 @getLetters() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = call i32 @fscanf(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 29
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %23
13: ; preds = %11
br label %14
14: ; preds = %18, %13
%15 = call signext i8 (...) @getchar()
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @stdin
%22 = call i32 @fscanf(i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
23: ; preds = %11
br label %24
24: ; preds = %28, %23
%25 = call signext i8 (...) @getchar()
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br i1 %27, label %28, label %29
28: ; preds = %24
br label %24
29: ; preds = %24
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [42 x i8] c"How many letters should the word have? : \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Please enter a valid number of letters: \00"
define i32 @getLetters() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fscanf(i32 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -30
%8 = icmp ult i32 %7, -29
br i1 %8, label %9, label %20
9: ; preds = %0, %12
%10 = call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %13, label %12
12: ; preds = %9, %13
br label %9
13: ; preds = %9
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fscanf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = add i32 %17, -30
%19 = icmp ult i32 %18, -29
br i1 %19, label %12, label %20
20: ; preds = %13, %0
br label %21
21: ; preds = %20, %21
%22 = call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 10
br i1 %23, label %24, label %21
24: ; preds = %21
%25 = load i32, i32* %1
ret i32 %25
}