int bee_event_handler(int sock) {
  char cmd[1400];
  memset(cmd, 0, 1400);
  if (sock > 0) {
    int len = read(sock, cmd, 1400);
    if (len > 0) {
      plogger_print(
          0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/kaija/bee/refs/heads/master/bee.c",
          1635, __func__, "Event command %s\n", cmd);
      if (strcmp(cmd, "pause") == 0) {
        return 0;
      } else if (strcmp(cmd, "destroy") == 0) {
        return 0;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<bee_event_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x590,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x580(%rbp),%rdi
xor    %esi,%esi
mov    $0x578,%edx
call   1030 <memset@plt>
cmpl   $0x0,-0x8(%rbp)
jle    121d <bee_event_handler+0xdd>
mov    -0x8(%rbp),%edi
lea    -0x580(%rbp),%rsi
mov    $0x578,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0x584(%rbp)
cmpl   $0x0,-0x584(%rbp)
jle    1218 <bee_event_handler+0xd8>
lea    -0x580(%rbp),%r9
xor    %edi,%edi
lea    0xe5c(%rip),%rsi
mov    $0x663,%edx
lea    0xecc(%rip),%rcx
lea    0xed7(%rip),%r8
mov    $0x0,%al
call   1060 <plogger_print@plt>
lea    -0x580(%rbp),%rdi
lea    0xed4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <bee_event_handler+0xa6>
movl   $0x0,-0x4(%rbp)
jmp    1224 <bee_event_handler+0xe4>
lea    -0x580(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    120e <bee_event_handler+0xce>
movl   $0x0,-0x4(%rbp)
jmp    1224 <bee_event_handler+0xe4>
jmp    1213 <bee_event_handler+0xd3>
jmp    1218 <bee_event_handler+0xd8>
jmp    121d <bee_event_handler+0xdd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x590,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bee_event_handler>:
push   %rbx
sub    $0x580,%rsp
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0x578,%edx
xor    %esi,%esi
call   1030 <memset@plt>
test   %ebx,%ebx
jle    1188 <bee_event_handler+0x58>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x578,%edx
xor    %eax,%eax
call   1040 <read@plt>
test   %eax,%eax
jle    1188 <bee_event_handler+0x58>
lea    0xe97(%rip),%rsi
lea    0xf0c(%rip),%rcx
lea    0xf17(%rip),%r8
mov    %rsp,%r9
xor    %edi,%edi
mov    $0x663,%edx
xor    %eax,%eax
call   1050 <plogger_print@plt>
xor    %eax,%eax
add    $0x580,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [124 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaija/bee/refs/heads/master/bee.c\00"
@__func__.bee_event_handler = [18 x i8] c"bee_event_handler\00"
@.str.1 = [18 x i8] c"Event command %s\0A\00"
@.str.2 = [6 x i8] c"pause\00"
@.str.3 = [8 x i8] c"destroy\00"
define i32 @bee_event_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1400 x i8]
%5 = alloca i32
store i32 %0, i32* %3
%6 = getelementptr inbounds [1400 x i8], [1400 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %1
%10 = load i32, i32* %3
%11 = getelementptr inbounds [1400 x i8], [1400 x i8]* %4, i64 0, i64 0
%12 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %10, i8* %11, i32 1400)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %9
%16 = getelementptr inbounds [1400 x i8], [1400 x i8]* %4, i64 0, i64 0
%17 = call i32 (i32, i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @plogger_print to i32 (i32, i8*, i32, i8*, i8*, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0), i32 1635, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__func__.bee_event_handler, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [1400 x i8], [1400 x i8]* %4, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %2
br label %31
22: ; preds = %15
%23 = getelementptr inbounds [1400 x i8], [1400 x i8]* %4, i64 0, i64 0
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, i32* %2
br label %31
27: ; preds = %22
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28, %9
br label %30
30: ; preds = %29, %1
store i32 0, i32* %2
br label %31
31: ; preds = %30, %26, %21
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [124 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaija/bee/refs/heads/master/bee.c\00"
@__func__.bee_event_handler = [18 x i8] c"bee_event_handler\00"
@.str.1 = [18 x i8] c"Event command %s\0A\00"
define i32 @bee_event_handler(i32 %0) {
%2 = alloca [1400 x i8]
%3 = getelementptr inbounds [1400 x i8], [1400 x i8]* %2, i64 0, i64 0
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %3, i32 1400)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 (i32, i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @plogger_print to i32 (i32, i8*, i32, i8*, i8*, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0), i32 1635, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__func__.bee_event_handler, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %10
10: ; preds = %8, %5, %1
ret i32 0
}