#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 */
char EOF;
int EXIT_SUCCESS;
char *GetWindForceDescription(int);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, int *);
int main(void) {
  int windSpeedInKnots = 0;
  int isInputValid = 0;
  char c = '\0';
  const char *descr = NULL;
  while (!isInputValid) {
    printf("Please enter the speed of wind (in knots): ");
    while (scanf("%d", &windSpeedInKnots) < 1) {
      puts("Input invalid. Please make sure wind speed is an integer.");
      while ((c = getchar()) != '\n' && c != EOF)
        continue;
    }
    while ((c = getchar()) != '\n' && c != EOF)
      continue;
    if (windSpeedInKnots < 0) {
      puts("Input invalid. The speed of wind cannot be negative.");
    } else {
      isInputValid = 1;
    }
  }
  descr = GetWindForceDescription(windSpeedInKnots);
  printf("Wind speed: %d knots\n", windSpeedInKnots);
  printf("Description: %s\n", descr);
  getchar();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118f <main+0x3f>
jmp    127f <main+0x12f>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jge    120d <main+0xbd>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x19(%rbp)
je     11f3 <main+0xa3>
movsbl -0xd(%rbp),%eax
mov    0x2e00(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1203 <main+0xb3>
jmp    1208 <main+0xb8>
jmp    11c2 <main+0x72>
jmp    119d <main+0x4d>
jmp    1212 <main+0xc2>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     1243 <main+0xf3>
movsbl -0xd(%rbp),%eax
mov    0x2db0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1253 <main+0x103>
jmp    1258 <main+0x108>
jmp    1212 <main+0xc2>
cmpl   $0x0,-0x8(%rbp)
jge    1273 <main+0x123>
lea    0xe00(%rip),%rdi
call   1030 <puts@plt>
jmp    127a <main+0x12a>
movl   $0x1,-0xc(%rbp)
jmp    1179 <main+0x29>
mov    -0x8(%rbp),%edi
call   1070 <GetWindForceDescription@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe96(%rip),%r14
lea    0xebb(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xeb2(%rip),%r12
mov    0x2e64(%rip),%rbp
lea    0xede(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
jg     11e0 <main+0x90>
mov    %r12,%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11a0 <main+0x50>
cmp    0x0(%rbp),%al
jne    11c0 <main+0x70>
jmp    11a0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11f0 <main+0xa0>
cmp    0x0(%rbp),%al
jne    11e0 <main+0x90>
cmpl   $0x0,0x4(%rsp)
jns    1201 <main+0xb1>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1190 <main+0x40>
mov    0x4(%rsp),%edi
call   1070 <GetWindForceDescription@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Please enter the speed of wind (in knots): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [58 x i8] c"Input invalid. Please make sure wind speed is an integer.\00"
@EOF = global i8 0
@.str.3 = [53 x i8] c"Input invalid. The speed of wind cannot be negative.\00"
@.str.4 = [22 x i8] c"Wind speed: %d knots\0A\00"
@.str.5 = [17 x i8] c"Description: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i8 0, i8* %4
store i8* null, i8** %5
br label %6
6: ; preds = %51, %0
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
br i1 %9, label %10, label %52
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %30, %10
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %29, %15
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = load i8, i8* @EOF
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br label %27
27: ; preds = %21, %17
%28 = phi i1 [ false, %17 ], [ %26, %21 ]
br i1 %28, label %29, label %30
29: ; preds = %27
br label %17
30: ; preds = %27
br label %12
31: ; preds = %12
br label %32
32: ; preds = %44, %31
%33 = call signext i8 (...) @getchar()
store i8 %33, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = load i8, i8* @EOF
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %38, %40
br label %42
42: ; preds = %36, %32
%43 = phi i1 [ false, %32 ], [ %41, %36 ]
br i1 %43, label %44, label %45
44: ; preds = %42
br label %32
45: ; preds = %42
%46 = load i32, i32* %2
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %51
50: ; preds = %45
store i32 1, i32* %3
br label %51
51: ; preds = %50, %48
br label %6
52: ; preds = %6
%53 = load i32, i32* %2
%54 = call i8* @GetWindForceDescription(i32 %53)
store i8* %54, i8** %5
%55 = load i32, i32* %2
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = load i8*, i8** %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = call signext i8 (...) @getchar()
%60 = load i32, i32* @EXIT_SUCCESS
ret i32 %60
}

LLVM IR (-O2):
@.str = [44 x i8] c"Please enter the speed of wind (in knots): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [58 x i8] c"Input invalid. Please make sure wind speed is an integer.\00"
@EOF = global i8 0
@.str.3 = [53 x i8] c"Input invalid. The speed of wind cannot be negative.\00"
@.str.4 = [22 x i8] c"Wind speed: %d knots\0A\00"
@.str.5 = [17 x i8] c"Description: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %28, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 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 slt i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %8, %3
br label %19
8: ; preds = %13
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %7
11: ; preds = %3, %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %13, %11
%14 = call signext i8 (...) @getchar()
%15 = icmp ne i8 %14, 10
%16 = load i8, i8* @EOF
%17 = icmp ne i8 %14, %16
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %13, label %8
19: ; preds = %7, %19
%20 = call signext i8 (...) @getchar()
%21 = icmp ne i8 %20, 10
%22 = load i8, i8* @EOF
%23 = icmp ne i8 %20, %22
%24 = select i1 %21, i1 %23, i1 false
br i1 %24, label %19, label %25
25: ; preds = %19
%26 = load i32, i32* %1
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %3
30: ; preds = %25
%31 = load i32, i32* %1
%32 = call i8* @GetWindForceDescription(i32 %31)
%33 = load i32, i32* %1
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %32)
%36 = call signext i8 (...) @getchar()
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}