#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*/ exercise_answer(char *, int);
int /*<<< orphan*/ exercise_begin(char *, int);
int exercise_end(char const *, char *, int);
int /*<<< orphan*/ exercise_open_answer_file(char *, int);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int exercise_process(const char *cmd, char *line, int pass) {
  if (!strcmp(cmd, "setanswerfile"))
    exercise_open_answer_file(line, pass);
  else if (!strncmp(cmd, "exercise", 8))
    exercise_begin(line, pass);
  else if (!strcmp(cmd, "answer"))
    exercise_answer(line, pass);
  else
    return exercise_end(cmd, line, pass);
  return 1;
}


x86 assembly (clang, -O0):
<exercise_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    119d <exercise_process+0x3d>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <exercise_open_answer_file@plt>
jmp    1218 <exercise_process+0xb8>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x8,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    11cc <exercise_process+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <exercise_begin@plt>
jmp    1213 <exercise_process+0xb3>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <exercise_process+0x96>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <exercise_answer@plt>
jmp    120e <exercise_process+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <exercise_end@plt>
mov    %eax,-0x4(%rbp)
jmp    121f <exercise_process+0xbf>
jmp    1213 <exercise_process+0xb3>
jmp    1218 <exercise_process+0xb8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exercise_process>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe8c(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11ba <exercise_process+0x5a>
lea    0xe8a(%rip),%rsi
mov    %rbp,%rdi
mov    $0x8,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     11c7 <exercise_process+0x67>
lea    0xe7b(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11d4 <exercise_process+0x74>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <exercise_end@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1080 <exercise_open_answer_file@plt>
jmp    11df <exercise_process+0x7f>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1070 <exercise_begin@plt>
jmp    11df <exercise_process+0x7f>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <exercise_answer@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"setanswerfile\00"
@.str.1 = [9 x i8] c"exercise\00"
@.str.2 = [7 x i8] c"answer\00"
define i32 @exercise_process(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @exercise_open_answer_file(i8* %12, i32 %13)
br label %38
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i32 @exercise_begin(i8* %20, i32 %21)
br label %37
23: ; preds = %15
%24 = load i8*, i8** %5
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = call i32 @exercise_answer(i8* %28, i32 %29)
br label %36
31: ; preds = %23
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = call i32 @exercise_end(i8* %32, i8* %33, i32 %34)
store i32 %35, i32* %4
br label %39
36: ; preds = %27
br label %37
37: ; preds = %36, %19
br label %38
38: ; preds = %37, %11
store i32 1, i32* %4
br label %39
39: ; preds = %38, %31
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [14 x i8] c"setanswerfile\00"
@.str.1 = [9 x i8] c"exercise\00"
@.str.2 = [7 x i8] c"answer\00"
define i32 @exercise_process(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @exercise_open_answer_file(i8* %1, i32 %2)
br label %20
8: ; preds = %3
%9 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @exercise_begin(i8* %1, i32 %2)
br label %20
13: ; preds = %8
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @exercise_answer(i8* %1, i32 %2)
br label %20
18: ; preds = %13
%19 = tail call i32 @exercise_end(i8* %0, i8* %1, i32 %2)
br label %20
20: ; preds = %6, %16, %11, %18
%21 = phi i32 [ %19, %18 ], [ 1, %11 ], [ 1, %16 ], [ 1, %6 ]
ret i32 %21
}