#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  int userLat = 0;
  int userLong = 0;
  char userLatQuad[6];
  char userLongQuad[5];
  char userDir;
  int userDist;
  char userChoice;
  printf("\nWelcome to the basic exploration program!");
  do {
    printf("\nPlease enter the direction and distance you want to go in:");
    scanf(" %c", &userDir);
    scanf("%d", &userDist);
    switch (userDir) {
    case ('n'):
      userLat += userDist;
      break;
    case ('N'):
      userLat += userDist;
      break;
    case ('w'):
      userLong -= userDist;
      break;
    case ('W'):
      userLong -= userDist;
      break;
    case ('e'):
      userLong += userDist;
      break;
    case ('E'):
      userLong += userDist;
      break;
    case ('s'):
      userLat -= userDist;
      break;
    case ('S'):
      userLat -= userDist;
      break;
    }
    if (userLat > 0) {
      strcpy(userLatQuad, "North");
    } else {
      strcpy(userLatQuad, "South");
    }
    if (userLong > 0) {
      strcpy(userLongQuad, "East");
    } else {
      strcpy(userLongQuad, "West");
    }
    printf("\n\nYou are now %d meters %s by %d meters %s", userLat, userLatQuad,
           userLong, userLongQuad);
    printf("\n\nDo you wish to continue?");
    scanf(" %c", &userChoice);
  } while (userChoice != 'n');
  exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xf68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf85(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xfad(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xf9e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x18(%rbp),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x32,%eax
ja     123f <main+0xff>
mov    -0x28(%rbp),%rax
lea    0xe3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    123f <main+0xff>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    125e <main+0x11e>
lea    -0x12(%rbp),%rdi
lea    0xee6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    126e <main+0x12e>
lea    -0x12(%rbp),%rdi
lea    0xed7(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0xc(%rbp)
jle    128d <main+0x14d>
lea    -0x17(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1030 <strcpy@plt>
jmp    129d <main+0x15d>
lea    -0x17(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%esi
lea    -0x12(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    -0x17(%rbp),%r8
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x6e,%eax
jne    116b <main+0x2b>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf77(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfd0(%rip),%rbx
lea    0x12(%rsp),%rbp
lea    0xd(%rsp),%r14
lea    0xe8c(%rip),%r13
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11ca <main+0x8a>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xfc1(%rip),%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %r12d,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfd2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x6e,0xb(%rsp)
je     127c <main+0x13c>
lea    0xf26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf49(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xc(%rsp),%eax
add    $0xffffffbb,%eax
cmp    $0x32,%eax
ja     1245 <main+0x105>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    0x4(%rsp),%r12d
jmp    1245 <main+0x105>
nopl   0x0(%rax,%rax,1)
add    0x4(%rsp),%r15d
jmp    1245 <main+0x105>
nopw   0x0(%rax,%rax,1)
sub    0x4(%rsp),%r15d
jmp    1245 <main+0x105>
nopw   0x0(%rax,%rax,1)
sub    0x4(%rsp),%r12d
lea    0xeee(%rip),%rsi
test   %r15d,%r15d
jg     1258 <main+0x118>
lea    0xee8(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xedf(%rip),%rsi
test   %r12d,%r12d
jg     1180 <main+0x40>
lea    0xed4(%rip),%rsi
jmp    1180 <main+0x40>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"\0AWelcome to the basic exploration program!\00"
@.str.1 = [60 x i8] c"\0APlease enter the direction and distance you want to go in:\00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"North\00"
@.str.5 = [6 x i8] c"South\00"
@.str.6 = [5 x i8] c"East\00"
@.str.7 = [5 x i8] c"West\00"
@.str.8 = [43 x i8] c"\0A\0AYou are now %d meters %s by %d meters %s\00"
@.str.9 = [27 x i8] c"\0A\0ADo you wish to continue?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
%5 = alloca [5 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %74, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
switch i32 %15, label %48 [
i32 110, label %16
i32 78, label %20
i32 119, label %24
i32 87, label %28
i32 101, label %32
i32 69, label %36
i32 115, label %40
i32 83, label %44
]
16: ; preds = %10
%17 = load i32, i32* %7
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %17
store i32 %19, i32* %2
br label %48
20: ; preds = %10
%21 = load i32, i32* %7
%22 = load i32, i32* %2
%23 = add nsw i32 %22, %21
store i32 %23, i32* %2
br label %48
24: ; preds = %10
%25 = load i32, i32* %7
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, %25
store i32 %27, i32* %3
br label %48
28: ; preds = %10
%29 = load i32, i32* %7
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, %29
store i32 %31, i32* %3
br label %48
32: ; preds = %10
%33 = load i32, i32* %7
%34 = load i32, i32* %3
%35 = add nsw i32 %34, %33
store i32 %35, i32* %3
br label %48
36: ; preds = %10
%37 = load i32, i32* %7
%38 = load i32, i32* %3
%39 = add nsw i32 %38, %37
store i32 %39, i32* %3
br label %48
40: ; preds = %10
%41 = load i32, i32* %7
%42 = load i32, i32* %2
%43 = sub nsw i32 %42, %41
store i32 %43, i32* %2
br label %48
44: ; preds = %10
%45 = load i32, i32* %7
%46 = load i32, i32* %2
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %2
br label %48
48: ; preds = %10, %44, %40, %36, %32, %28, %24, %20, %16
%49 = load i32, i32* %2
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%53 = call i32 @strcpy(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %57
54: ; preds = %48
%55 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %54, %51
%58 = load i32, i32* %3
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%62 = call i32 @strcpy(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %66
63: ; preds = %57
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%65 = call i32 @strcpy(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %63, %60
%67 = load i32, i32* %2
%68 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%69 = load i32, i32* %3
%70 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i32 %67, i8* %68, i32 %69, i8* %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%73 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %74
74: ; preds = %66
%75 = load i8, i8* %8
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 110
br i1 %77, label %10, label %78
78: ; preds = %74
%79 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [43 x i8] c"\0AWelcome to the basic exploration program!\00"
@.str.1 = [60 x i8] c"\0APlease enter the direction and distance you want to go in:\00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"North\00"
@.str.5 = [6 x i8] c"South\00"
@.str.6 = [5 x i8] c"East\00"
@.str.7 = [5 x i8] c"West\00"
@.str.8 = [43 x i8] c"\0A\0AYou are now %d meters %s by %d meters %s\00"
@.str.9 = [27 x i8] c"\0A\0ADo you wish to continue?\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [5 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %42, %0
%11 = phi i32 [ 0, %0 ], [ %43, %42 ]
%12 = phi i32 [ 0, %0 ], [ %44, %42 ]
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
switch i32 %17, label %42 [
i32 110, label %18
i32 78, label %21
i32 119, label %24
i32 87, label %27
i32 101, label %30
i32 69, label %33
i32 115, label %36
i32 83, label %39
]
18: ; preds = %10
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %11
br label %42
21: ; preds = %10
%22 = load i32, i32* %4
%23 = add nsw i32 %22, %11
br label %42
24: ; preds = %10
%25 = load i32, i32* %4
%26 = sub nsw i32 %12, %25
br label %42
27: ; preds = %10
%28 = load i32, i32* %4
%29 = sub nsw i32 %12, %28
br label %42
30: ; preds = %10
%31 = load i32, i32* %4
%32 = add nsw i32 %31, %12
br label %42
33: ; preds = %10
%34 = load i32, i32* %4
%35 = add nsw i32 %34, %12
br label %42
36: ; preds = %10
%37 = load i32, i32* %4
%38 = sub nsw i32 %11, %37
br label %42
39: ; preds = %10
%40 = load i32, i32* %4
%41 = sub nsw i32 %11, %40
br label %42
42: ; preds = %10, %39, %36, %33, %30, %27, %24, %21, %18
%43 = phi i32 [ %11, %10 ], [ %41, %39 ], [ %38, %36 ], [ %11, %33 ], [ %11, %30 ], [ %11, %27 ], [ %11, %24 ], [ %23, %21 ], [ %20, %18 ]
%44 = phi i32 [ %12, %10 ], [ %12, %39 ], [ %12, %36 ], [ %35, %33 ], [ %32, %30 ], [ %29, %27 ], [ %26, %24 ], [ %12, %21 ], [ %12, %18 ]
%45 = icmp sgt i32 %43, 0
%46 = select i1 %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%47 = call i32 @strcpy(i8* %6, i8* %46)
%48 = icmp sgt i32 %44, 0
%49 = select i1 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0)
%50 = call i32 @strcpy(i8* %7, i8* %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i32 %43, i8* %6, i32 %44, i8* %7)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%54 = load i8, i8* %5
%55 = icmp eq i8 %54, 110
br i1 %55, label %56, label %10
56: ; preds = %42
%57 = call i32 @exit(i32 1)
unreachable
}