#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*/ sprintf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int enginecommand(char str[256], char reply[256]) {
  char command[256], param1[256], param2[256];
  sscanf(str, "%s %s %s", command, param1, param2);
  sprintf(reply, "?");
  if (strcmp(command, "name") == 0) {
    sprintf(reply, "dama italiana 1.03");
    return 1;
  }
  if (strcmp(command, "about") == 0) {
    sprintf(reply, "Dama Italiana 1.02\n\n2001 by Martin Fierz");
    return 1;
  }
  if (strcmp(command, "help") == 0) {
    sprintf(reply, "damahelp.htm");
    return 1;
  }
  if (strcmp(command, "set") == 0) {
    if (strcmp(param1, "hashsize") == 0) {
      return 0;
    }
    if (strcmp(param1, "book") == 0) {
      return 0;
    }
  }
  if (strcmp(command, "get") == 0) {
    if (strcmp(param1, "hashsize") == 0) {
      return 0;
    }
    if (strcmp(param1, "book") == 0) {
      return 0;
    }
    if (strcmp(param1, "protocolversion") == 0) {
      sprintf(reply, "2");
      return 1;
    }
    if (strcmp(param1, "gametype") == 0) {
      sprintf(reply, "32");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<enginecommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    -0x320(%rbp),%r8
lea    0xe9d(%rip),%rsi
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <enginecommand+0x81>
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x120(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ea <enginecommand+0xba>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x120(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1223 <enginecommand+0xf3>
mov    -0x18(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x120(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1297 <enginecommand+0x167>
lea    -0x220(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1269 <enginecommand+0x139>
movl   $0x0,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x220(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1292 <enginecommand+0x162>
movl   $0x0,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
jmp    1297 <enginecommand+0x167>
lea    -0x120(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    137d <enginecommand+0x24d>
lea    -0x220(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12dd <enginecommand+0x1ad>
movl   $0x0,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x220(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1306 <enginecommand+0x1d6>
movl   $0x0,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x220(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    133f <enginecommand+0x20f>
mov    -0x18(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
lea    -0x220(%rbp),%rdi
lea    0xd3d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1378 <enginecommand+0x248>
mov    -0x18(%rbp),%rdi
lea    0xd2c(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1384 <enginecommand+0x254>
jmp    137d <enginecommand+0x24d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enginecommand>:
push   %rbp
push   %rbx
sub    $0x308,%rsp
mov    %rsi,%rbx
lea    0xecd(%rip),%rsi
lea    0x100(%rsp),%rbp
mov    %rsp,%rcx
lea    0x200(%rsp),%r8
mov    %rbp,%rdx
call   1040 <sscanf@plt>
movw   $0x3f,(%rbx)
lea    0xeaf(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1248 <enginecommand+0x128>
lea    0xeaf(%rip),%rsi
lea    0x100(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     125b <enginecommand+0x13b>
lea    0xec1(%rip),%rsi
lea    0x100(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     127d <enginecommand+0x15d>
lea    0xeb6(%rip),%rsi
lea    0x100(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12a9 <enginecommand+0x189>
lea    0xeab(%rip),%rsi
lea    0x100(%rsp),%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    129d <enginecommand+0x17d>
lea    0xe7e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     129d <enginecommand+0x17d>
lea    0xe6f(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     129d <enginecommand+0x17d>
lea    0xe60(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12d9 <enginecommand+0x1b9>
lea    0xe58(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    129d <enginecommand+0x17d>
movb   $0x0,0x2(%rbx)
movw   $0x3233,(%rbx)
jmp    1298 <enginecommand+0x178>
movups 0xdbf(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0x33302e,0xf(%rbx)
jmp    1298 <enginecommand+0x178>
movups 0xdde(%rip),%xmm0
movups %xmm0,0x19(%rbx)
movups 0xdca(%rip),%xmm0
movups %xmm0,0x10(%rbx)
movups 0xdaf(%rip),%xmm0
movups %xmm0,(%rbx)
jmp    1298 <enginecommand+0x178>
movabs $0x6d74682e706c65,%rax
mov    %rax,0x5(%rbx)
movabs $0x706c6568616d6164,%rax
65 6c 70
mov    %rax,(%rbx)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x308,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdb6(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     129d <enginecommand+0x17d>
lea    0xda9(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11c2 <enginecommand+0xa2>
jmp    129d <enginecommand+0x17d>
movw   $0x32,(%rbx)
jmp    1298 <enginecommand+0x178>

LLVM IR (-O0):
@.str = [9 x i8] c"%s %s %s\00"
@.str.1 = [2 x i8] c"?\00"
@.str.2 = [5 x i8] c"name\00"
@.str.3 = [19 x i8] c"dama italiana 1.03\00"
@.str.4 = [6 x i8] c"about\00"
@.str.5 = [41 x i8] c"Dama Italiana 1.02\0A\0A2001 by Martin Fierz\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [13 x i8] c"damahelp.htm\00"
@.str.8 = [4 x i8] c"set\00"
@.str.9 = [9 x i8] c"hashsize\00"
@.str.10 = [5 x i8] c"book\00"
@.str.11 = [4 x i8] c"get\00"
@.str.12 = [16 x i8] c"protocolversion\00"
@.str.13 = [2 x i8] c"2\00"
@.str.14 = [9 x i8] c"gametype\00"
@.str.15 = [3 x i8] c"32\00"
define i32 @enginecommand(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%13 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %81
22: ; preds = %2
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %81
29: ; preds = %22
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %81
36: ; preds = %29
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 0, i32* %3
br label %81
45: ; preds = %40
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 0, i32* %3
br label %81
50: ; preds = %45
br label %51
51: ; preds = %50, %36
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %80
55: ; preds = %51
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %55
store i32 0, i32* %3
br label %81
60: ; preds = %55
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 0, i32* %3
br label %81
65: ; preds = %60
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%67 = call i64 @strcmp(i8* %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i8*, i8** %5
%71 = call i32 @sprintf(i8* %70, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %3
br label %81
72: ; preds = %65
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i8*, i8** %5
%78 = call i32 @sprintf(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %3
br label %81
79: ; preds = %72
br label %80
80: ; preds = %79, %51
store i32 0, i32* %3
br label %81
81: ; preds = %80, %76, %69, %64, %59, %49, %44, %33, %26, %19
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s %s %s\00"
@.str.2 = [5 x i8] c"name\00"
@.str.3 = [19 x i8] c"dama italiana 1.03\00"
@.str.4 = [6 x i8] c"about\00"
@.str.5 = [41 x i8] c"Dama Italiana 1.02\0A\0A2001 by Martin Fierz\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [13 x i8] c"damahelp.htm\00"
@.str.8 = [4 x i8] c"set\00"
@.str.9 = [9 x i8] c"hashsize\00"
@.str.10 = [5 x i8] c"book\00"
@.str.11 = [4 x i8] c"get\00"
@.str.12 = [16 x i8] c"protocolversion\00"
@.str.14 = [9 x i8] c"gametype\00"
@.str.15 = [3 x i8] c"32\00"
define i32 @enginecommand(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7, i8* %8)
%10 = bitcast i8* %1 to i16*
store i16 63, i16* %10
%11 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
br label %48
14: ; preds = %2
%15 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
br label %48
18: ; preds = %14
%19 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %48
22: ; preds = %18
%23 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %48, label %28
28: ; preds = %25
%29 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %48, label %31
31: ; preds = %28, %22
%32 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %48, label %37
37: ; preds = %34
%38 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %48, label %40
40: ; preds = %37
%41 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40
store i16 50, i16* %10
br label %48
44: ; preds = %40
%45 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
br label %48
48: ; preds = %31, %44, %37, %34, %28, %25, %47, %43, %21, %17, %13
%49 = phi i32 [ 1, %13 ], [ 1, %17 ], [ 1, %21 ], [ 1, %43 ], [ 1, %47 ], [ 0, %25 ], [ 0, %28 ], [ 0, %34 ], [ 0, %37 ], [ 0, %44 ], [ 0, %31 ]
ret i32 %49
}