#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 issue_get_cmd(int, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ strcasecmp(char *, char *);
int process_command(int fd, char *cmd) {
  char action[10];
  char option[10];
  sscanf(cmd, "%s%s", action, option);
  if (!strcasecmp(action, "GET")) {
    return issue_get_cmd(fd, option);
  } else if (!strcasecmp(action, "SYNCH")) {
    return (0);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<process_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    0xeae(%rip),%rsi
call   1050 <sscanf@plt>
lea    -0x1a(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1184 <process_command+0x54>
mov    -0x8(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   1040 <issue_get_cmd@plt>
mov    %eax,-0x4(%rbp)
jmp    11b5 <process_command+0x85>
lea    -0x1a(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11a9 <process_command+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <process_command+0x85>
jmp    11ae <process_command+0x7e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_command>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %edi,%ebp
lea    0xebe(%rip),%rsi
lea    0xe(%rsp),%rbx
lea    0x4(%rsp),%rcx
mov    %rax,%rdi
mov    %rbx,%rdx
call   1050 <sscanf@plt>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1181 <process_command+0x51>
lea    0xe98(%rip),%rsi
lea    0xe(%rsp),%rdi
call   1030 <strcasecmp@plt>
neg    %eax
sbb    %eax,%eax
jmp    118d <process_command+0x5d>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
call   1040 <issue_get_cmd@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [6 x i8] c"SYNCH\00"
define i32 @process_command(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [10 x i8]
%7 = alloca [10 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%11 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%13 = call i32 @strcasecmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%18 = call i32 @issue_get_cmd(i32 %16, i8* %17)
store i32 %18, i32* %3
br label %26
19: ; preds = %2
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcasecmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 0, i32* %3
br label %26
24: ; preds = %19
br label %25
25: ; preds = %24
store i32 -1, i32* %3
br label %26
26: ; preds = %25, %23, %15
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [6 x i8] c"SYNCH\00"
define i32 @process_command(i32 %0, i8* nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%8 = call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @issue_get_cmd(i32 %0, i8* %6)
br label %16
12: ; preds = %2
%13 = call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
%15 = sext i1 %14 to i32
br label %16
16: ; preds = %12, %10
%17 = phi i32 [ %11, %10 ], [ %15, %12 ]
ret i32 %17
}