#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 */
struct property {
  int dummy;
};

/* Variables and functions */
struct property *buyProp(struct property *, int);
struct property *improveProp(struct property *, int);
int /*<<< orphan*/ printProp(struct property *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
struct property *sellProp(struct property *, int);
int main() {
  int choice = 0, numplayer = 0, turn = 0;
  struct property *head = NULL;
  printf("How many players today, governor?\n");
  scanf("%d", &numplayer);
  while (1) {
    printf("Player %d, what would you like to do?\n", turn % numplayer + 1);
    printf("     1. Buy\n");
    printf("     2. Improve\n");
    printf("     3. Sell\n");
    printf("     4. View Properties\n");
    printf("     5. End Turn\n");
    printf("     6. Quit Tracker\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      head = buyProp(head, turn % numplayer + 1);
      continue;
    case 2:
      head = improveProp(head, turn % numplayer + 1);
      continue;
    case 3:
      head = sellProp(head, turn % numplayer + 1);
      continue;
    case 4:
      printProp(head);
      continue;
    case 5:
      break;
    case 6:
      return 0;
    default:
      printf("That is not a valid selection\n\n");
      continue;
    }
    turn++;
  }
}


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)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe11(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     12d1 <main+0x171>
mov    -0x20(%rbp),%rax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
add    $0x1,%esi
call   1050 <buyProp@plt>
mov    %rax,-0x18(%rbp)
jmp    11aa <main+0x4a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
add    $0x1,%esi
call   1070 <improveProp@plt>
mov    %rax,-0x18(%rbp)
jmp    11aa <main+0x4a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
add    $0x1,%esi
call   1040 <sellProp@plt>
mov    %rax,-0x18(%rbp)
jmp    11aa <main+0x4a>
mov    -0x18(%rbp),%rdi
call   1080 <printProp@plt>
jmp    11aa <main+0x4a>
jmp    12e4 <main+0x184>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x4a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11aa <main+0x4a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
lea    0xef9(%rip),%r14
lea    0xf03(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe41(%rip),%rbp
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    11dc <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    %r13d,%eax
cltd
idivl  (%rsp)
lea    0x1(%rdx),%esi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xddd(%rip),%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     11d0 <main+0x60>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %rbx,%rdi
call   1090 <printProp@plt>
jmp    11dc <main+0x6c>
mov    %r13d,%eax
cltd
idivl  (%rsp)
lea    0x1(%rdx),%esi
mov    %rbx,%rdi
call   1060 <buyProp@plt>
mov    %rax,%rbx
jmp    11dc <main+0x6c>
mov    %r13d,%eax
cltd
idivl  (%rsp)
lea    0x1(%rdx),%esi
mov    %rbx,%rdi
call   1080 <improveProp@plt>
mov    %rax,%rbx
jmp    11dc <main+0x6c>
mov    %r13d,%eax
cltd
idivl  (%rsp)
lea    0x1(%rdx),%esi
mov    %rbx,%rdi
call   1050 <sellProp@plt>
mov    %rax,%rbx
jmp    11dc <main+0x6c>
add    $0x1,%r13d
jmp    11dc <main+0x6c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.property = type { i32 }
@.str = [35 x i8] c"How many players today, governor?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Player %d, what would you like to do?\0A\00"
@.str.3 = [13 x i8] c" 1. Buy\0A\00"
@.str.4 = [17 x i8] c" 2. Improve\0A\00"
@.str.5 = [14 x i8] c" 3. Sell\0A\00"
@.str.6 = [25 x i8] c" 4. View Properties\0A\00"
@.str.7 = [18 x i8] c" 5. End Turn\0A\00"
@.str.8 = [22 x i8] c" 6. Quit Tracker\0A\00"
@.str.9 = [32 x i8] c"That is not a valid selection\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.property*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store %struct.property* null, %struct.property** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %0, %22, %29, %36, %43, %48, %50
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = srem i32 %9, %10
%12 = add nsw i32 %11, 1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
switch i32 %21, label %48 [
i32 1, label %22
i32 2, label %29
i32 3, label %36
i32 4, label %43
i32 5, label %46
i32 6, label %47
]
22: ; preds = %8
%23 = load %struct.property*, %struct.property** %5
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = srem i32 %24, %25
%27 = add nsw i32 %26, 1
%28 = call %struct.property* @buyProp(%struct.property* %23, i32 %27)
store %struct.property* %28, %struct.property** %5
br label %8
29: ; preds = %8
%30 = load %struct.property*, %struct.property** %5
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = srem i32 %31, %32
%34 = add nsw i32 %33, 1
%35 = call %struct.property* @improveProp(%struct.property* %30, i32 %34)
store %struct.property* %35, %struct.property** %5
br label %8
36: ; preds = %8
%37 = load %struct.property*, %struct.property** %5
%38 = load i32, i32* %4
%39 = load i32, i32* %3
%40 = srem i32 %38, %39
%41 = add nsw i32 %40, 1
%42 = call %struct.property* @sellProp(%struct.property* %37, i32 %41)
store %struct.property* %42, %struct.property** %5
br label %8
43: ; preds = %8
%44 = load %struct.property*, %struct.property** %5
%45 = call i32 @printProp(%struct.property* %44)
br label %8
46: ; preds = %8
br label %50
47: ; preds = %8
ret i32 0
48: ; preds = %8
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %8
50: ; preds = %46
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %8
}

LLVM IR (-O2):
%struct.property = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Player %d, what would you like to do?\0A\00"
@str = [34 x i8] c"How many players today, governor?\00"
@str.10 = [12 x i8] c" 1. Buy\00"
@str.11 = [16 x i8] c" 2. Improve\00"
@str.12 = [13 x i8] c" 3. Sell\00"
@str.13 = [24 x i8] c" 4. View Properties\00"
@str.14 = [17 x i8] c" 5. End Turn\00"
@str.15 = [21 x i8] c" 6. Quit Tracker\00"
@str.16 = [31 x i8] c"That is not a valid selection\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %48, %0
%8 = phi i32 [ %49, %48 ], [ 0, %0 ]
%9 = phi %struct.property* [ %11, %48 ], [ null, %0 ]
br label %10
10: ; preds = %40, %7
%11 = phi %struct.property* [ %9, %7 ], [ %41, %40 ]
br label %12
12: ; preds = %44, %10
%13 = load i32, i32* %2
%14 = srem i32 %8, %13
%15 = add nuw nsw i32 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
switch i32 %24, label %46 [
i32 1, label %25
i32 2, label %30
i32 3, label %35
i32 4, label %42
i32 5, label %48
i32 6, label %45
]
25: ; preds = %12
%26 = load i32, i32* %2
%27 = srem i32 %8, %26
%28 = add nuw nsw i32 %27, 1
%29 = call %struct.property* @buyProp(%struct.property* %11, i32 %28)
br label %40
30: ; preds = %12
%31 = load i32, i32* %2
%32 = srem i32 %8, %31
%33 = add nuw nsw i32 %32, 1
%34 = call %struct.property* @improveProp(%struct.property* %11, i32 %33)
br label %40
35: ; preds = %12
%36 = load i32, i32* %2
%37 = srem i32 %8, %36
%38 = add nuw nsw i32 %37, 1
%39 = call %struct.property* @sellProp(%struct.property* %11, i32 %38)
br label %40
40: ; preds = %35, %30, %25
%41 = phi %struct.property* [ %29, %25 ], [ %34, %30 ], [ %39, %35 ]
br label %10
42: ; preds = %12
%43 = call i32 @printProp(%struct.property* %11)
br label %44
44: ; preds = %42, %46
br label %12
45: ; preds = %12
ret i32 0
46: ; preds = %12
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0))
br label %44
48: ; preds = %12
%49 = add nuw nsw i32 %8, 1
br label %7
}