#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  FILE *fin;
  fin = fopen("pedals.in", "r");
  int numCases;
  fscanf(fin, "%d", &numCases);
  int i;
  for (i = 1; i <= numCases; i++) {
    int numCommands;
    fscanf(fin, "%d", &numCommands);
    int j;
    printf("Course %d:\n", i);
    for (j = 0; j < numCommands; j++) {
      char command[10];
      int number;
      fscanf(fin, "%s", command);
      if (strcmp(command, "forward") == 0)
        number = 1;
      else if (strcmp(command, "backward") == 0)
        number = 2;
      else if (strcmp(command, "left") == 0)
        number = 3;
      else if (strcmp(command, "right") == 0)
        number = 4;
      else {
        fscanf(fin, "%s", command);
        if (strcmp(command, "left") == 0)
          number = 5;
        else
          number = 6;
      }
      printf("%d\n", number);
    }
    printf("\n");
  }
  fclose(fin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1319 <main+0x1c9>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12fd <main+0x1ad>
mov    -0x10(%rbp),%rdi
lea    -0x2a(%rbp),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
lea    -0x2a(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <main+0xc5>
movl   $0x1,-0x30(%rbp)
jmp    12de <main+0x18e>
lea    -0x2a(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123b <main+0xeb>
movl   $0x2,-0x30(%rbp)
jmp    12d9 <main+0x189>
lea    -0x2a(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1261 <main+0x111>
movl   $0x3,-0x30(%rbp)
jmp    12d4 <main+0x184>
lea    -0x2a(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1287 <main+0x137>
movl   $0x4,-0x30(%rbp)
jmp    12cf <main+0x17f>
mov    -0x10(%rbp),%rdi
lea    -0x2a(%rbp),%rdx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
lea    -0x2a(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12c3 <main+0x173>
movl   $0x5,-0x30(%rbp)
jmp    12ca <main+0x17a>
movl   $0x6,-0x30(%rbp)
jmp    12cf <main+0x17f>
jmp    12d4 <main+0x184>
jmp    12d9 <main+0x189>
jmp    12de <main+0x18e>
mov    -0x30(%rbp),%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cd <main+0x7d>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1193 <main+0x43>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe81(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12ee <main+0x18e>
mov    $0x1,%ebp
lea    0xe6a(%rip),%r12
lea    0x1e(%rsp),%r14
lea    0xe7d(%rip),%r13
jmp    11de <main+0x7e>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    0xc(%rsp),%ecx
mov    %eax,%ebp
jge    12ee <main+0x18e>
mov    %rbx,%rdi
lea    0xe24(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0xe14(%rip),%rdi
mov    %rbp,0x10(%rsp)
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x8(%rsp)
lea    0xe09(%rip),%rbp
jle    11c0 <main+0x60>
xor    %r15d,%r15d
jmp    123a <main+0xda>
nopl   0x0(%rax)
mov    $0x1,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
cmp    0x8(%rsp),%r15d
jge    11c0 <main+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1220 <main+0xc0>
mov    %r14,%rdi
lea    0xdc2(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12d0 <main+0x170>
mov    %r14,%rdi
lea    0xdb7(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12da <main+0x17a>
mov    %r14,%rdi
lea    0xda8(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12e4 <main+0x184>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r14,%rdi
lea    0xd7f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x1,%rax
mov    $0x6,%esi
sbb    $0x0,%esi
jmp    1225 <main+0xc5>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%esi
jmp    1225 <main+0xc5>
mov    $0x3,%esi
jmp    1225 <main+0xc5>
mov    $0x4,%esi
jmp    1225 <main+0xc5>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"pedals.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"Course %d:\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"forward\00"
@.str.6 = [9 x i8] c"backward\00"
@.str.7 = [5 x i8] c"left\00"
@.str.8 = [6 x i8] c"right\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i8]
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = load i32*, i32** %2
%11 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %12
12: ; preds = %69, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %72
16: ; preds = %12
%17 = load i32*, i32** %2
%18 = call i32 (i32*, i8*, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %19)
store i32 0, i32* %6
br label %21
21: ; preds = %64, %16
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %67
25: ; preds = %21
%26 = load i32*, i32** %2
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 1, i32* %8
br label %61
33: ; preds = %25
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 2, i32* %8
br label %60
38: ; preds = %33
%39 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 3, i32* %8
br label %59
43: ; preds = %38
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 4, i32* %8
br label %58
48: ; preds = %43
%49 = load i32*, i32** %2
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%51 = call i32 (i32*, i8*, ...) @fscanf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %48
store i32 5, i32* %8
br label %57
56: ; preds = %48
store i32 6, i32* %8
br label %57
57: ; preds = %56, %55
br label %58
58: ; preds = %57, %47
br label %59
59: ; preds = %58, %42
br label %60
60: ; preds = %59, %37
br label %61
61: ; preds = %60, %32
%62 = load i32, i32* %8
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %21
67: ; preds = %21
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %69
69: ; preds = %67
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 1
store i32 %71, i32* %4
br label %12
72: ; preds = %12
%73 = load i32*, i32** %2
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str = [10 x i8] c"pedals.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"Course %d:\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"forward\00"
@.str.6 = [9 x i8] c"backward\00"
@.str.7 = [5 x i8] c"left\00"
@.str.8 = [6 x i8] c"right\00"
@.str.9 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = call i32 (i32*, i8*, ...) @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %48, label %9
9: ; preds = %0
%10 = bitcast i32* %2 to i8*
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
br label %12
12: ; preds = %9, %43
%13 = phi i32 [ 1, %9 ], [ %45, %43 ]
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %12, %37
%19 = phi i32 [ %40, %37 ], [ 0, %12 ]
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%21 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %18
%24 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%34 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
%36 = select i1 %35, i32 5, i32 6
br label %37
37: ; preds = %32, %29, %26, %23, %18
%38 = phi i32 [ 1, %18 ], [ 2, %23 ], [ 3, %26 ], [ 4, %29 ], [ %36, %32 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %38)
%40 = add nuw nsw i32 %19, 1
%41 = load i32, i32* %2
%42 = icmp slt i32 %40, %41
br i1 %42, label %18, label %43
43: ; preds = %37, %12
%44 = call i32 @putchar(i32 10)
%45 = add nuw nsw i32 %13, 1
%46 = load i32, i32* %1
%47 = icmp slt i32 %13, %46
br i1 %47, label %12, label %48
48: ; preds = %43, %0
%49 = call i32 @fclose(i32* %4)
ret i32 0
}