
/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

void serial_select_result(int fd,int event)

{
  int iVar1;
  Serial serial;
  ssize_t len;
  int *piVar2;
  int iVar3;
  int in_GS_OFFSET;
  char buf [4096];
  
  iVar3 = event;
  iVar1 = *(int *)(in_GS_OFFSET + 0x14);
  serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd);
  if (serial != (Serial)0x0) {
    if (iVar3 == 1) {
      len = read(serial->fd,buf,0x1000);
      if (len == 0) {
        if (-1 < serial->fd) {
          close(serial->fd);
          serial->fd = -1;
        }
        serial->finished = 1;
        notify_remote_exit(serial->frontend);
      }
      else if (len < 0) {
        piVar2 = __errno_location();
        if (*piVar2 != 0xb) {
          perror("read serial port");
                    /* WARNING: Subroutine does not return */
          exit(1);
        }
      }
      else {
        iVar3 = from_backend(serial->frontend,0,buf,len);
        serial->inbufsize = iVar3;
        serial_uxsel_setup(serial);
      }
    }
    else if (iVar3 == 2) {
      serial_try_write(serial);
    }
  }
  if (iVar1 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail_local();
}



/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

void FUN_0009df70(undefined4 param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  ssize_t sVar3;
  int *piVar4;
  undefined4 uVar5;
  int in_GS_OFFSET;
  undefined1 local_1010 [4096];
  int local_10;
  
  iVar1 = param_2;
  local_10 = *(int *)(in_GS_OFFSET + 0x14);
  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);
  if (puVar2 != (undefined4 *)0x0) {
    if (iVar1 == 1) {
      sVar3 = read(puVar2[1],local_1010,0x1000);
      if (sVar3 == 0) {
        if (-1 < (int)puVar2[1]) {
          close(puVar2[1]);
          puVar2[1] = 0xffffffff;
        }
        puVar2[2] = 1;
        FUN_00093290(*puVar2);
      }
      else if (sVar3 < 0) {
        piVar4 = __errno_location();
        if (*piVar4 != 0xb) {
          perror("read serial port");
                    /* WARNING: Subroutine does not return */
          exit(1);
        }
      }
      else {
        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);
        puVar2[3] = uVar5;
        FUN_0009dd70();
      }
    }
    else if (iVar1 == 2) {
      FUN_0009de80();
    }
  }
  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  FUN_000a39d0();
}


PUSH EDI
PUSH ESI
PUSH EBX
CALL 0x0001c4f0
ADD EBX,0x727d8
SUB ESP,0x1014
MOV EAX,GS:[0x14]
MOV dword ptr [ESP + 0x1010],EAX
XOR EAX,EAX
MOV EDI,dword ptr [ESP + 0x1028]
LEA EAX,[EBX + 0xfff8d550]
PUSH EAX
LEA EAX,[ESP + 0x1028]
PUSH EAX
PUSH dword ptr [EBX + 0x12d4]
CALL 0x000817b0
ADD ESP,0x10
TEST EAX,EAX
JZ 0x0009dfc7
MOV ESI,EAX
CMP EDI,0x1
JZ 0x0009dfe8
CMP EDI,0x2
JZ 0x0009e028
MOV EAX,dword ptr [ESP + 0x100c]
XOR EAX,dword ptr GS:[0x14]
JNZ 0x0009e095
ADD ESP,0x1010
POP EBX
POP ESI
POP EDI
RET
SUB ESP,0x4
PUSH 0x1000
LEA EDI,[ESP + 0x14]
PUSH EDI
PUSH dword ptr [EAX + 0x4]
CALL 0x0001bc80
ADD ESP,0x10
TEST EAX,EAX
JNZ 0x0009e030
MOV EAX,dword ptr [ESI + 0x4]
TEST EAX,EAX
JNS 0x0009e060
SUB ESP,0xc
MOV dword ptr [ESI + 0x8],0x1
PUSH dword ptr [ESI]
CALL 0x00093290
ADD ESP,0x10
JMP 0x0009dfc7
CALL 0x0009de80
JMP 0x0009dfc7
JNS 0x0009e078
CALL 0x0001ac30
CMP dword ptr [EAX],0xb
JZ 0x0009dfc7
SUB ESP,0xc
LEA EAX,[EBX + 0xfffbd8b3]
PUSH EAX
CALL 0x0001b930
MOV dword ptr [ESP],0x1
CALL 0x0001b740
SUB ESP,0xc
PUSH EAX
CALL 0x0001bc40
MOV dword ptr [ESI + 0x4],0xffffffff
ADD ESP,0x10
JMP 0x0009e00b
PUSH EAX
PUSH EDI
PUSH 0x0
PUSH dword ptr [ESI]
CALL 0x00092bf0
MOV dword ptr [ESI + 0xc],EAX
MOV EAX,ESI
CALL 0x0009dd70
ADD ESP,0x10
JMP 0x0009dfc7
CALL 0x000a39d0
(translation_unit "/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n\nvoid FUN_0009df70(undefined4 param_1,int param_2)\n\n{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  FUN_000a39d0();\n}\n\n" comment (function_definition "void FUN_0009df70(undefined4 param_1,int param_2)\n\n{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  FUN_000a39d0();\n}" primitive_type (function_declarator "FUN_0009df70(undefined4 param_1,int param_2)" identifier (parameter_list "(undefined4 param_1,int param_2)" ( (parameter_declaration "undefined4 param_1" type_identifier identifier) , (parameter_declaration "int param_2" primitive_type identifier) ))) (compound_statement "{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  FUN_000a39d0();\n}" { (declaration "int iVar1;" primitive_type identifier ;) (declaration "undefined4 *puVar2;" type_identifier (pointer_declarator "*puVar2" * identifier) ;) (declaration "ssize_t sVar3;" primitive_type identifier ;) (declaration "int *piVar4;" primitive_type (pointer_declarator "*piVar4" * identifier) ;) (declaration "undefined4 uVar5;" type_identifier identifier ;) (declaration "int in_GS_OFFSET;" primitive_type identifier ;) (declaration "undefined1 local_1010 [4096];" type_identifier (array_declarator "local_1010 [4096]" identifier [ number_literal ]) ;) (declaration "int local_10;" primitive_type identifier ;) (expression_statement "iVar1 = param_2;" (assignment_expression "iVar1 = param_2" identifier = identifier) ;) (expression_statement "local_10 = *(int *)(in_GS_OFFSET + 0x14);" (assignment_expression "local_10 = *(int *)(in_GS_OFFSET + 0x14)" identifier = (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) ;) (expression_statement "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);" (assignment_expression "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" identifier = (cast_expression "(undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" identifier (argument_list "(DAT_00111a24,&param_1,FUN_0009dca0)" ( identifier , (pointer_expression "&param_1" & identifier) , identifier ))))) ;) (if_statement "if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" if (parenthesized_expression "(puVar2 != (undefined4 *)0x0)" ( (binary_expression "puVar2 != (undefined4 *)0x0" identifier != (cast_expression "(undefined4 *)0x0" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" { (if_statement "if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" if (parenthesized_expression "(iVar1 == 1)" ( (binary_expression "iVar1 == 1" identifier == number_literal) )) (compound_statement "{\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }" { (expression_statement "sVar3 = read(puVar2[1],local_1010,0x1000);" (assignment_expression "sVar3 = read(puVar2[1],local_1010,0x1000)" identifier = (call_expression "read(puVar2[1],local_1010,0x1000)" identifier (argument_list "(puVar2[1],local_1010,0x1000)" ( (subscript_expression "puVar2[1]" identifier [ number_literal ]) , identifier , number_literal )))) ;) (if_statement "if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" if (parenthesized_expression "(sVar3 == 0)" ( (binary_expression "sVar3 == 0" identifier == number_literal) )) (compound_statement "{\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }" { (if_statement "if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" if (parenthesized_expression "(-1 < (int)puVar2[1])" ( (binary_expression "-1 < (int)puVar2[1]" number_literal < (cast_expression "(int)puVar2[1]" ( (type_descriptor "int" primitive_type) ) (subscript_expression "puVar2[1]" identifier [ number_literal ]))) )) (compound_statement "{\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" { (expression_statement "close(puVar2[1]);" (call_expression "close(puVar2[1])" identifier (argument_list "(puVar2[1])" ( (subscript_expression "puVar2[1]" identifier [ number_literal ]) ))) ;) (expression_statement "puVar2[1] = 0xffffffff;" (assignment_expression "puVar2[1] = 0xffffffff" (subscript_expression "puVar2[1]" identifier [ number_literal ]) = number_literal) ;) })) (expression_statement "puVar2[2] = 1;" (assignment_expression "puVar2[2] = 1" (subscript_expression "puVar2[2]" identifier [ number_literal ]) = number_literal) ;) (expression_statement "FUN_00093290(*puVar2);" (call_expression "FUN_00093290(*puVar2)" identifier (argument_list "(*puVar2)" ( (pointer_expression "*puVar2" * identifier) ))) ;) }) (else_clause "else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" else (if_statement "if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" if (parenthesized_expression "(sVar3 < 0)" ( (binary_expression "sVar3 < 0" identifier < number_literal) )) (compound_statement "{\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }" { (expression_statement "piVar4 = __errno_location();" (assignment_expression "piVar4 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }" if (parenthesized_expression "(*piVar4 != 0xb)" ( (binary_expression "*piVar4 != 0xb" (pointer_expression "*piVar4" * identifier) != number_literal) )) (compound_statement "{\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }" { (expression_statement "perror("read serial port");" (call_expression "perror("read serial port")" identifier (argument_list "("read serial port")" ( (string_literal ""read serial port"" " string_content ") ))) ;) comment (expression_statement "exit(1);" (call_expression "exit(1)" identifier (argument_list "(1)" ( number_literal ))) ;) })) }) (else_clause "else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" else (compound_statement "{\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" { (expression_statement "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);" (assignment_expression "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3)" identifier = (call_expression "FUN_00092bf0(*puVar2,0,local_1010,sVar3)" identifier (argument_list "(*puVar2,0,local_1010,sVar3)" ( (pointer_expression "*puVar2" * identifier) , number_literal , identifier , identifier )))) ;) (expression_statement "puVar2[3] = uVar5;" (assignment_expression "puVar2[3] = uVar5" (subscript_expression "puVar2[3]" identifier [ number_literal ]) = identifier) ;) (expression_statement "FUN_0009dd70();" (call_expression "FUN_0009dd70()" identifier (argument_list "()" ( ))) ;) }))))) }) (else_clause "else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" else (if_statement "if (iVar1 == 2) {\n      FUN_0009de80();\n    }" if (parenthesized_expression "(iVar1 == 2)" ( (binary_expression "iVar1 == 2" identifier == number_literal) )) (compound_statement "{\n      FUN_0009de80();\n    }" { (expression_statement "FUN_0009de80();" (call_expression "FUN_0009de80()" identifier (argument_list "()" ( ))) ;) })))) })) (if_statement "if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }" if (parenthesized_expression "(local_10 == *(int *)(in_GS_OFFSET + 0x14))" ( (binary_expression "local_10 == *(int *)(in_GS_OFFSET + 0x14)" identifier == (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) )) (compound_statement "{\n    return;\n  }" { (return_statement "return;" return ;) })) comment (expression_statement "FUN_000a39d0();" (call_expression "FUN_000a39d0()" identifier (argument_list "()" ( ))) ;) })))
(translation_unit "/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n\nvoid serial_select_result(int fd,int event)\n\n{\n  int iVar1;\n  Serial serial;\n  ssize_t len;\n  int *piVar2;\n  int iVar3;\n  int in_GS_OFFSET;\n  char buf [4096];\n  \n  iVar3 = event;\n  iVar1 = *(int *)(in_GS_OFFSET + 0x14);\n  serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd);\n  if (serial != (Serial)0x0) {\n    if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }\n  }\n  if (iVar1 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  __stack_chk_fail_local();\n}\n\n" comment (function_definition "void serial_select_result(int fd,int event)\n\n{\n  int iVar1;\n  Serial serial;\n  ssize_t len;\n  int *piVar2;\n  int iVar3;\n  int in_GS_OFFSET;\n  char buf [4096];\n  \n  iVar3 = event;\n  iVar1 = *(int *)(in_GS_OFFSET + 0x14);\n  serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd);\n  if (serial != (Serial)0x0) {\n    if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }\n  }\n  if (iVar1 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  __stack_chk_fail_local();\n}" primitive_type (function_declarator "serial_select_result(int fd,int event)" identifier (parameter_list "(int fd,int event)" ( (parameter_declaration "int fd" primitive_type identifier) , (parameter_declaration "int event" primitive_type identifier) ))) (compound_statement "{\n  int iVar1;\n  Serial serial;\n  ssize_t len;\n  int *piVar2;\n  int iVar3;\n  int in_GS_OFFSET;\n  char buf [4096];\n  \n  iVar3 = event;\n  iVar1 = *(int *)(in_GS_OFFSET + 0x14);\n  serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd);\n  if (serial != (Serial)0x0) {\n    if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }\n  }\n  if (iVar1 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    /* WARNING: Subroutine does not return */\n  __stack_chk_fail_local();\n}" { (declaration "int iVar1;" primitive_type identifier ;) (declaration "Serial serial;" type_identifier identifier ;) (declaration "ssize_t len;" primitive_type identifier ;) (declaration "int *piVar2;" primitive_type (pointer_declarator "*piVar2" * identifier) ;) (declaration "int iVar3;" primitive_type identifier ;) (declaration "int in_GS_OFFSET;" primitive_type identifier ;) (declaration "char buf [4096];" primitive_type (array_declarator "buf [4096]" identifier [ number_literal ]) ;) (expression_statement "iVar3 = event;" (assignment_expression "iVar3 = event" identifier = identifier) ;) (expression_statement "iVar1 = *(int *)(in_GS_OFFSET + 0x14);" (assignment_expression "iVar1 = *(int *)(in_GS_OFFSET + 0x14)" identifier = (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) ;) (expression_statement "serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd);" (assignment_expression "serial = (Serial)find234(serial_by_fd,&fd,serial_find_by_fd)" identifier = (cast_expression "(Serial)find234(serial_by_fd,&fd,serial_find_by_fd)" ( (type_descriptor "Serial" type_identifier) ) (call_expression "find234(serial_by_fd,&fd,serial_find_by_fd)" identifier (argument_list "(serial_by_fd,&fd,serial_find_by_fd)" ( identifier , (pointer_expression "&fd" & identifier) , identifier ))))) ;) (if_statement "if (serial != (Serial)0x0) {\n    if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }\n  }" if (parenthesized_expression "(serial != (Serial)0x0)" ( (binary_expression "serial != (Serial)0x0" identifier != (cast_expression "(Serial)0x0" ( (type_descriptor "Serial" type_identifier) ) number_literal)) )) (compound_statement "{\n    if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }\n  }" { (if_statement "if (iVar3 == 1) {\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }\n    else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }" if (parenthesized_expression "(iVar3 == 1)" ( (binary_expression "iVar3 == 1" identifier == number_literal) )) (compound_statement "{\n      len = read(serial->fd,buf,0x1000);\n      if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }\n    }" { (expression_statement "len = read(serial->fd,buf,0x1000);" (assignment_expression "len = read(serial->fd,buf,0x1000)" identifier = (call_expression "read(serial->fd,buf,0x1000)" identifier (argument_list "(serial->fd,buf,0x1000)" ( (field_expression "serial->fd" identifier -> field_identifier) , identifier , number_literal )))) ;) (if_statement "if (len == 0) {\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }\n      else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }" if (parenthesized_expression "(len == 0)" ( (binary_expression "len == 0" identifier == number_literal) )) (compound_statement "{\n        if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }\n        serial->finished = 1;\n        notify_remote_exit(serial->frontend);\n      }" { (if_statement "if (-1 < serial->fd) {\n          close(serial->fd);\n          serial->fd = -1;\n        }" if (parenthesized_expression "(-1 < serial->fd)" ( (binary_expression "-1 < serial->fd" number_literal < (field_expression "serial->fd" identifier -> field_identifier)) )) (compound_statement "{\n          close(serial->fd);\n          serial->fd = -1;\n        }" { (expression_statement "close(serial->fd);" (call_expression "close(serial->fd)" identifier (argument_list "(serial->fd)" ( (field_expression "serial->fd" identifier -> field_identifier) ))) ;) (expression_statement "serial->fd = -1;" (assignment_expression "serial->fd = -1" (field_expression "serial->fd" identifier -> field_identifier) = number_literal) ;) })) (expression_statement "serial->finished = 1;" (assignment_expression "serial->finished = 1" (field_expression "serial->finished" identifier -> field_identifier) = number_literal) ;) (expression_statement "notify_remote_exit(serial->frontend);" (call_expression "notify_remote_exit(serial->frontend)" identifier (argument_list "(serial->frontend)" ( (field_expression "serial->frontend" identifier -> field_identifier) ))) ;) }) (else_clause "else if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }" else (if_statement "if (len < 0) {\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }\n      else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }" if (parenthesized_expression "(len < 0)" ( (binary_expression "len < 0" identifier < number_literal) )) (compound_statement "{\n        piVar2 = __errno_location();\n        if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }\n      }" { (expression_statement "piVar2 = __errno_location();" (assignment_expression "piVar2 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (*piVar2 != 0xb) {\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }" if (parenthesized_expression "(*piVar2 != 0xb)" ( (binary_expression "*piVar2 != 0xb" (pointer_expression "*piVar2" * identifier) != number_literal) )) (compound_statement "{\n          perror("read serial port");\n                    /* WARNING: Subroutine does not return */\n          exit(1);\n        }" { (expression_statement "perror("read serial port");" (call_expression "perror("read serial port")" identifier (argument_list "("read serial port")" ( (string_literal ""read serial port"" " string_content ") ))) ;) comment (expression_statement "exit(1);" (call_expression "exit(1)" identifier (argument_list "(1)" ( number_literal ))) ;) })) }) (else_clause "else {\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }" else (compound_statement "{\n        iVar3 = from_backend(serial->frontend,0,buf,len);\n        serial->inbufsize = iVar3;\n        serial_uxsel_setup(serial);\n      }" { (expression_statement "iVar3 = from_backend(serial->frontend,0,buf,len);" (assignment_expression "iVar3 = from_backend(serial->frontend,0,buf,len)" identifier = (call_expression "from_backend(serial->frontend,0,buf,len)" identifier (argument_list "(serial->frontend,0,buf,len)" ( (field_expression "serial->frontend" identifier -> field_identifier) , number_literal , identifier , identifier )))) ;) (expression_statement "serial->inbufsize = iVar3;" (assignment_expression "serial->inbufsize = iVar3" (field_expression "serial->inbufsize" identifier -> field_identifier) = identifier) ;) (expression_statement "serial_uxsel_setup(serial);" (call_expression "serial_uxsel_setup(serial)" identifier (argument_list "(serial)" ( identifier ))) ;) }))))) }) (else_clause "else if (iVar3 == 2) {\n      serial_try_write(serial);\n    }" else (if_statement "if (iVar3 == 2) {\n      serial_try_write(serial);\n    }" if (parenthesized_expression "(iVar3 == 2)" ( (binary_expression "iVar3 == 2" identifier == number_literal) )) (compound_statement "{\n      serial_try_write(serial);\n    }" { (expression_statement "serial_try_write(serial);" (call_expression "serial_try_write(serial)" identifier (argument_list "(serial)" ( identifier ))) ;) })))) })) (if_statement "if (iVar1 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }" if (parenthesized_expression "(iVar1 == *(int *)(in_GS_OFFSET + 0x14))" ( (binary_expression "iVar1 == *(int *)(in_GS_OFFSET + 0x14)" identifier == (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) )) (compound_statement "{\n    return;\n  }" { (return_statement "return;" return ;) })) comment (expression_statement "__stack_chk_fail_local();" (call_expression "__stack_chk_fail_local()" identifier (argument_list "()" ( ))) ;) })))
(translation_unit "void FUN_0009df70(undefined4 param_1,int param_2)\n\n{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    \n  FUN_000a39d0();\n}\n\n" (function_definition "void FUN_0009df70(undefined4 param_1,int param_2)\n\n{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    \n  FUN_000a39d0();\n}" primitive_type (function_declarator "FUN_0009df70(undefined4 param_1,int param_2)" identifier (parameter_list "(undefined4 param_1,int param_2)" ( (parameter_declaration "undefined4 param_1" type_identifier identifier) , (parameter_declaration "int param_2" primitive_type identifier) ))) (compound_statement "{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    \n  FUN_000a39d0();\n}" { (declaration "int iVar1;" primitive_type identifier ;) (declaration "undefined4 *puVar2;" type_identifier (pointer_declarator "*puVar2" * identifier) ;) (declaration "ssize_t sVar3;" primitive_type identifier ;) (declaration "int *piVar4;" primitive_type (pointer_declarator "*piVar4" * identifier) ;) (declaration "undefined4 uVar5;" type_identifier identifier ;) (declaration "int in_GS_OFFSET;" primitive_type identifier ;) (declaration "undefined1 local_1010 [4096];" type_identifier (array_declarator "local_1010 [4096]" identifier [ number_literal ]) ;) (declaration "int local_10;" primitive_type identifier ;) (expression_statement "iVar1 = param_2;" (assignment_expression "iVar1 = param_2" identifier = identifier) ;) (expression_statement "local_10 = *(int *)(in_GS_OFFSET + 0x14);" (assignment_expression "local_10 = *(int *)(in_GS_OFFSET + 0x14)" identifier = (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) ;) (expression_statement "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);" (assignment_expression "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" identifier = (cast_expression "(undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" identifier (argument_list "(DAT_00111a24,&param_1,FUN_0009dca0)" ( identifier , (pointer_expression "&param_1" & identifier) , identifier ))))) ;) (if_statement "if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" if (parenthesized_expression "(puVar2 != (undefined4 *)0x0)" ( (binary_expression "puVar2 != (undefined4 *)0x0" identifier != (cast_expression "(undefined4 *)0x0" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" { (if_statement "if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" if (parenthesized_expression "(iVar1 == 1)" ( (binary_expression "iVar1 == 1" identifier == number_literal) )) (compound_statement "{\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }" { (expression_statement "sVar3 = read(puVar2[1],local_1010,0x1000);" (assignment_expression "sVar3 = read(puVar2[1],local_1010,0x1000)" identifier = (call_expression "read(puVar2[1],local_1010,0x1000)" identifier (argument_list "(puVar2[1],local_1010,0x1000)" ( (subscript_expression "puVar2[1]" identifier [ number_literal ]) , identifier , number_literal )))) ;) (if_statement "if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" if (parenthesized_expression "(sVar3 == 0)" ( (binary_expression "sVar3 == 0" identifier == number_literal) )) (compound_statement "{\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }" { (if_statement "if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" if (parenthesized_expression "(-1 < (int)puVar2[1])" ( (binary_expression "-1 < (int)puVar2[1]" number_literal < (cast_expression "(int)puVar2[1]" ( (type_descriptor "int" primitive_type) ) (subscript_expression "puVar2[1]" identifier [ number_literal ]))) )) (compound_statement "{\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" { (expression_statement "close(puVar2[1]);" (call_expression "close(puVar2[1])" identifier (argument_list "(puVar2[1])" ( (subscript_expression "puVar2[1]" identifier [ number_literal ]) ))) ;) (expression_statement "puVar2[1] = 0xffffffff;" (assignment_expression "puVar2[1] = 0xffffffff" (subscript_expression "puVar2[1]" identifier [ number_literal ]) = number_literal) ;) })) (expression_statement "puVar2[2] = 1;" (assignment_expression "puVar2[2] = 1" (subscript_expression "puVar2[2]" identifier [ number_literal ]) = number_literal) ;) (expression_statement "FUN_00093290(*puVar2);" (call_expression "FUN_00093290(*puVar2)" identifier (argument_list "(*puVar2)" ( (pointer_expression "*puVar2" * identifier) ))) ;) }) (else_clause "else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" else (if_statement "if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" if (parenthesized_expression "(sVar3 < 0)" ( (binary_expression "sVar3 < 0" identifier < number_literal) )) (compound_statement "{\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }" { (expression_statement "piVar4 = __errno_location();" (assignment_expression "piVar4 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }" if (parenthesized_expression "(*piVar4 != 0xb)" ( (binary_expression "*piVar4 != 0xb" (pointer_expression "*piVar4" * identifier) != number_literal) )) (compound_statement "{\n          perror("read serial port");\n                    \n          exit(1);\n        }" { (expression_statement "perror("read serial port");" (call_expression "perror("read serial port")" identifier (argument_list "("read serial port")" ( (string_literal ""read serial port"" " string_content ") ))) ;) (expression_statement "exit(1);" (call_expression "exit(1)" identifier (argument_list "(1)" ( number_literal ))) ;) })) }) (else_clause "else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" else (compound_statement "{\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" { (expression_statement "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);" (assignment_expression "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3)" identifier = (call_expression "FUN_00092bf0(*puVar2,0,local_1010,sVar3)" identifier (argument_list "(*puVar2,0,local_1010,sVar3)" ( (pointer_expression "*puVar2" * identifier) , number_literal , identifier , identifier )))) ;) (expression_statement "puVar2[3] = uVar5;" (assignment_expression "puVar2[3] = uVar5" (subscript_expression "puVar2[3]" identifier [ number_literal ]) = identifier) ;) (expression_statement "FUN_0009dd70();" (call_expression "FUN_0009dd70()" identifier (argument_list "()" ( ))) ;) }))))) }) (else_clause "else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" else (if_statement "if (iVar1 == 2) {\n      FUN_0009de80();\n    }" if (parenthesized_expression "(iVar1 == 2)" ( (binary_expression "iVar1 == 2" identifier == number_literal) )) (compound_statement "{\n      FUN_0009de80();\n    }" { (expression_statement "FUN_0009de80();" (call_expression "FUN_0009de80()" identifier (argument_list "()" ( ))) ;) })))) })) (if_statement "if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }" if (parenthesized_expression "(local_10 == *(int *)(in_GS_OFFSET + 0x14))" ( (binary_expression "local_10 == *(int *)(in_GS_OFFSET + 0x14)" identifier == (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" * (cast_expression "(int *)(in_GS_OFFSET + 0x14)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(in_GS_OFFSET + 0x14)" ( (binary_expression "in_GS_OFFSET + 0x14" identifier + number_literal) ))))) )) (compound_statement "{\n    return;\n  }" { (return_statement "return;" return ;) })) (expression_statement "FUN_000a39d0();" (call_expression "FUN_000a39d0()" identifier (argument_list "()" ( ))) ;) })))
(translation_unit (function_definition TYPE (function_declarator IDENT (parameter_list ( (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) ))) (compound_statement { (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE (array_declarator IDENT [ LIT ]) ;) (declaration TYPE IDENT ;) (expression_statement (assignment_expression IDENT = IDENT) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + LIT) ))))) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (call_expression IDENT (argument_list ( IDENT , (pointer_expression & IDENT) , IDENT ))))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT != (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) )) (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( (subscript_expression IDENT [ LIT ]) , IDENT , LIT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression LIT < (cast_expression ( (type_descriptor TYPE) ) (subscript_expression IDENT [ LIT ]))) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( (subscript_expression IDENT [ LIT ]) ))) ;) (expression_statement (assignment_expression (subscript_expression IDENT [ LIT ]) = LIT) ;) })) (expression_statement (assignment_expression (subscript_expression IDENT [ LIT ]) = LIT) ;) (expression_statement (call_expression IDENT (argument_list ( (pointer_expression * IDENT) ))) ;) }) (else_clause else (if_statement if (parenthesized_expression ( (binary_expression IDENT < LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( )))) ;) (if_statement if (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) != LIT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( (string_literal " string_content ") ))) ;) (expression_statement (call_expression IDENT (argument_list ( LIT ))) ;) })) }) (else_clause else (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( (pointer_expression * IDENT) , LIT , IDENT , IDENT )))) ;) (expression_statement (assignment_expression (subscript_expression IDENT [ LIT ]) = IDENT) ;) (expression_statement (call_expression IDENT (argument_list ( ))) ;) }))))) }) (else_clause else (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( ))) ;) })))) })) (if_statement if (parenthesized_expression ( (binary_expression IDENT == (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + LIT) ))))) )) (compound_statement { (return_statement return ;) })) (expression_statement (call_expression IDENT (argument_list ( ))) ;) })))
(function_definition "void FUN_0009df70(undefined4 param_1,int param_2)\n\n{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    \n  FUN_000a39d0();\n}" (primitive_type "void") (function_declarator "FUN_0009df70(undefined4 param_1,int param_2)" (identifier "FUN_0009df70") (parameter_list "(undefined4 param_1,int param_2)" (( "(") (parameter_declaration "undefined4 param_1" (type_identifier "undefined4") (identifier "param_1")) (, ",") (parameter_declaration "int param_2" (primitive_type "int") (identifier "param_2")) () ")"))) (compound_statement "{\n  int iVar1;\n  undefined4 *puVar2;\n  ssize_t sVar3;\n  int *piVar4;\n  undefined4 uVar5;\n  int in_GS_OFFSET;\n  undefined1 local_1010 [4096];\n  int local_10;\n  \n  iVar1 = param_2;\n  local_10 = *(int *)(in_GS_OFFSET + 0x14);\n  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);\n  if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }\n  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }\n                    \n  FUN_000a39d0();\n}" ({ "{") (declaration "int iVar1;" (primitive_type "int") (identifier "iVar1") (; ";")) (declaration "undefined4 *puVar2;" (type_identifier "undefined4") (pointer_declarator "*puVar2" (* "*") (identifier "puVar2")) (; ";")) (declaration "ssize_t sVar3;" (primitive_type "ssize_t") (identifier "sVar3") (; ";")) (declaration "int *piVar4;" (primitive_type "int") (pointer_declarator "*piVar4" (* "*") (identifier "piVar4")) (; ";")) (declaration "undefined4 uVar5;" (type_identifier "undefined4") (identifier "uVar5") (; ";")) (declaration "int in_GS_OFFSET;" (primitive_type "int") (identifier "in_GS_OFFSET") (; ";")) (declaration "undefined1 local_1010 [4096];" (type_identifier "undefined1") (array_declarator "local_1010 [4096]" (identifier "local_1010") ([ "[") (number_literal "4096") (] "]")) (; ";")) (declaration "int local_10;" (primitive_type "int") (identifier "local_10") (; ";")) (expression_statement "iVar1 = param_2;" (assignment_expression "iVar1 = param_2" (identifier "iVar1") (= "=") (identifier "param_2")) (; ";")) (expression_statement "local_10 = *(int *)(in_GS_OFFSET + 0x14);" (assignment_expression "local_10 = *(int *)(in_GS_OFFSET + 0x14)" (identifier "local_10") (= "=") (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" (* "*") (cast_expression "(int *)(in_GS_OFFSET + 0x14)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(in_GS_OFFSET + 0x14)" (( "(") (binary_expression "in_GS_OFFSET + 0x14" (identifier "in_GS_OFFSET") (+ "+") (number_literal "0x14")) () ")"))))) (; ";")) (expression_statement "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);" (assignment_expression "puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" (identifier "puVar2") (= "=") (cast_expression "(undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" (( "(") (type_descriptor "undefined4 *" (type_identifier "undefined4") (abstract_pointer_declarator "*" (* "*"))) () ")") (call_expression "FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0)" (identifier "FUN_000817b0") (argument_list "(DAT_00111a24,&param_1,FUN_0009dca0)" (( "(") (identifier "DAT_00111a24") (, ",") (pointer_expression "&param_1" (& "&") (identifier "param_1")) (, ",") (identifier "FUN_0009dca0") () ")"))))) (; ";")) (if_statement "if (puVar2 != (undefined4 *)0x0) {\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" (if "if") (parenthesized_expression "(puVar2 != (undefined4 *)0x0)" (( "(") (binary_expression "puVar2 != (undefined4 *)0x0" (identifier "puVar2") (!= "!=") (cast_expression "(undefined4 *)0x0" (( "(") (type_descriptor "undefined4 *" (type_identifier "undefined4") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")")) (compound_statement "{\n    if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }\n  }" ({ "{") (if_statement "if (iVar1 == 1) {\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }\n    else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" (if "if") (parenthesized_expression "(iVar1 == 1)" (( "(") (binary_expression "iVar1 == 1" (identifier "iVar1") (== "==") (number_literal "1")) () ")")) (compound_statement "{\n      sVar3 = read(puVar2[1],local_1010,0x1000);\n      if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }\n    }" ({ "{") (expression_statement "sVar3 = read(puVar2[1],local_1010,0x1000);" (assignment_expression "sVar3 = read(puVar2[1],local_1010,0x1000)" (identifier "sVar3") (= "=") (call_expression "read(puVar2[1],local_1010,0x1000)" (identifier "read") (argument_list "(puVar2[1],local_1010,0x1000)" (( "(") (subscript_expression "puVar2[1]" (identifier "puVar2") ([ "[") (number_literal "1") (] "]")) (, ",") (identifier "local_1010") (, ",") (number_literal "0x1000") () ")")))) (; ";")) (if_statement "if (sVar3 == 0) {\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }\n      else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" (if "if") (parenthesized_expression "(sVar3 == 0)" (( "(") (binary_expression "sVar3 == 0" (identifier "sVar3") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n        if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }\n        puVar2[2] = 1;\n        FUN_00093290(*puVar2);\n      }" ({ "{") (if_statement "if (-1 < (int)puVar2[1]) {\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" (if "if") (parenthesized_expression "(-1 < (int)puVar2[1])" (( "(") (binary_expression "-1 < (int)puVar2[1]" (number_literal "-1") (< "<") (cast_expression "(int)puVar2[1]" (( "(") (type_descriptor "int" (primitive_type "int")) () ")") (subscript_expression "puVar2[1]" (identifier "puVar2") ([ "[") (number_literal "1") (] "]")))) () ")")) (compound_statement "{\n          close(puVar2[1]);\n          puVar2[1] = 0xffffffff;\n        }" ({ "{") (expression_statement "close(puVar2[1]);" (call_expression "close(puVar2[1])" (identifier "close") (argument_list "(puVar2[1])" (( "(") (subscript_expression "puVar2[1]" (identifier "puVar2") ([ "[") (number_literal "1") (] "]")) () ")"))) (; ";")) (expression_statement "puVar2[1] = 0xffffffff;" (assignment_expression "puVar2[1] = 0xffffffff" (subscript_expression "puVar2[1]" (identifier "puVar2") ([ "[") (number_literal "1") (] "]")) (= "=") (number_literal "0xffffffff")) (; ";")) (} "}"))) (expression_statement "puVar2[2] = 1;" (assignment_expression "puVar2[2] = 1" (subscript_expression "puVar2[2]" (identifier "puVar2") ([ "[") (number_literal "2") (] "]")) (= "=") (number_literal "1")) (; ";")) (expression_statement "FUN_00093290(*puVar2);" (call_expression "FUN_00093290(*puVar2)" (identifier "FUN_00093290") (argument_list "(*puVar2)" (( "(") (pointer_expression "*puVar2" (* "*") (identifier "puVar2")) () ")"))) (; ";")) (} "}")) (else_clause "else if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" (else "else") (if_statement "if (sVar3 < 0) {\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }\n      else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" (if "if") (parenthesized_expression "(sVar3 < 0)" (( "(") (binary_expression "sVar3 < 0" (identifier "sVar3") (< "<") (number_literal "0")) () ")")) (compound_statement "{\n        piVar4 = __errno_location();\n        if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }\n      }" ({ "{") (expression_statement "piVar4 = __errno_location();" (assignment_expression "piVar4 = __errno_location()" (identifier "piVar4") (= "=") (call_expression "__errno_location()" (identifier "__errno_location") (argument_list "()" (( "(") () ")")))) (; ";")) (if_statement "if (*piVar4 != 0xb) {\n          perror("read serial port");\n                    \n          exit(1);\n        }" (if "if") (parenthesized_expression "(*piVar4 != 0xb)" (( "(") (binary_expression "*piVar4 != 0xb" (pointer_expression "*piVar4" (* "*") (identifier "piVar4")) (!= "!=") (number_literal "0xb")) () ")")) (compound_statement "{\n          perror("read serial port");\n                    \n          exit(1);\n        }" ({ "{") (expression_statement "perror("read serial port");" (call_expression "perror("read serial port")" (identifier "perror") (argument_list "("read serial port")" (( "(") (string_literal ""read serial port"" (" """) (string_content "read serial port") (" """)) () ")"))) (; ";")) (expression_statement "exit(1);" (call_expression "exit(1)" (identifier "exit") (argument_list "(1)" (( "(") (number_literal "1") () ")"))) (; ";")) (} "}"))) (} "}")) (else_clause "else {\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" (else "else") (compound_statement "{\n        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);\n        puVar2[3] = uVar5;\n        FUN_0009dd70();\n      }" ({ "{") (expression_statement "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);" (assignment_expression "uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3)" (identifier "uVar5") (= "=") (call_expression "FUN_00092bf0(*puVar2,0,local_1010,sVar3)" (identifier "FUN_00092bf0") (argument_list "(*puVar2,0,local_1010,sVar3)" (( "(") (pointer_expression "*puVar2" (* "*") (identifier "puVar2")) (, ",") (number_literal "0") (, ",") (identifier "local_1010") (, ",") (identifier "sVar3") () ")")))) (; ";")) (expression_statement "puVar2[3] = uVar5;" (assignment_expression "puVar2[3] = uVar5" (subscript_expression "puVar2[3]" (identifier "puVar2") ([ "[") (number_literal "3") (] "]")) (= "=") (identifier "uVar5")) (; ";")) (expression_statement "FUN_0009dd70();" (call_expression "FUN_0009dd70()" (identifier "FUN_0009dd70") (argument_list "()" (( "(") () ")"))) (; ";")) (} "}")))))) (} "}")) (else_clause "else if (iVar1 == 2) {\n      FUN_0009de80();\n    }" (else "else") (if_statement "if (iVar1 == 2) {\n      FUN_0009de80();\n    }" (if "if") (parenthesized_expression "(iVar1 == 2)" (( "(") (binary_expression "iVar1 == 2" (identifier "iVar1") (== "==") (number_literal "2")) () ")")) (compound_statement "{\n      FUN_0009de80();\n    }" ({ "{") (expression_statement "FUN_0009de80();" (call_expression "FUN_0009de80()" (identifier "FUN_0009de80") (argument_list "()" (( "(") () ")"))) (; ";")) (} "}"))))) (} "}"))) (if_statement "if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {\n    return;\n  }" (if "if") (parenthesized_expression "(local_10 == *(int *)(in_GS_OFFSET + 0x14))" (( "(") (binary_expression "local_10 == *(int *)(in_GS_OFFSET + 0x14)" (identifier "local_10") (== "==") (pointer_expression "*(int *)(in_GS_OFFSET + 0x14)" (* "*") (cast_expression "(int *)(in_GS_OFFSET + 0x14)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(in_GS_OFFSET + 0x14)" (( "(") (binary_expression "in_GS_OFFSET + 0x14" (identifier "in_GS_OFFSET") (+ "+") (number_literal "0x14")) () ")"))))) () ")")) (compound_statement "{\n    return;\n  }" ({ "{") (return_statement "return;" (return "return") (; ";")) (} "}"))) (expression_statement "FUN_000a39d0();" (call_expression "FUN_000a39d0()" (identifier "FUN_000a39d0") (argument_list "()" (( "(") () ")"))) (; ";")) (} "}")))

/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

void function_1(int fd,int event)

{
  int var_15;
  type_1 var_3;
  ssize_t var_6;
  int *piVar2;
  int var_4;
  int var_1;
  char buf [4096];
  
  var_4 = event;
  var_15 = *(int *)(var_1 + 0x14);
  var_3 = (type_1)var_2(serial_by_fd,&fd,serial_find_by_fd);
  if (var_3 != (type_1)0x0) {
    if (var_4 == 1) {
      var_6 = var_5(var_3->fd,buf,0x1000);
      if (var_6 == 0) {
        if (-1 < var_3->fd) {
          var_7(var_3->fd);
          var_3->fd = -1;
        }
        var_3->finished = 1;
        var_8(var_3->frontend);
      }
      else if (var_6 < 0) {
        piVar2 = var_9();
        if (*piVar2 != 0xb) {
          var_10("read serial port");
                    /* WARNING: Subroutine does not return */
          var_11(1);
        }
      }
      else {
        var_4 = var_12(var_3->frontend,0,buf,var_6);
        var_3->inbufsize = var_4;
        var_13(var_3);
      }
    }
    else if (var_4 == 2) {
      var_14(var_3);
    }
  }
  if (var_15 == *(int *)(var_1 + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  var_16();
}


(translation_unit (function_definition type: (primitive_type) declarator: (function_declarator declarator: (identifier) parameters: (parameter_list (parameter_declaration type: (type_identifier) declarator: (identifier)) (parameter_declaration type: (primitive_type) declarator: (identifier)))) body: (compound_statement (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (type_identifier) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (type_identifier) declarator: (identifier)) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (type_identifier) declarator: (array_declarator declarator: (identifier) size: (number_literal))) (declaration type: (primitive_type) declarator: (identifier)) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (pointer_expression argument: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))))))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (call_expression function: (identifier) arguments: (argument_list (identifier) (pointer_expression argument: (identifier)) (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (number_literal)))) consequence: (compound_statement (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (subscript_expression argument: (identifier) index: (number_literal)) (identifier) (number_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (if_statement condition: (parenthesized_expression (binary_expression left: (number_literal) right: (cast_expression type: (type_descriptor type: (primitive_type)) value: (subscript_expression argument: (identifier) index: (number_literal))))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (subscript_expression argument: (identifier) index: (number_literal))))) (expression_statement (assignment_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal))))) (expression_statement (assignment_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal))) (expression_statement (call_expression function: (identifier) arguments: (argument_list (pointer_expression argument: (identifier)))))) alternative: (else_clause (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (pointer_expression argument: (identifier)) right: (number_literal))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (string_literal (string_content))))) (expression_statement (call_expression function: (identifier) arguments: (argument_list (number_literal))))))) alternative: (else_clause (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (pointer_expression argument: (identifier)) (number_literal) (identifier) (identifier))))) (expression_statement (assignment_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (identifier))) (expression_statement (call_expression function: (identifier) arguments: (argument_list))))))))) alternative: (else_clause (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (pointer_expression argument: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))))))) consequence: (compound_statement (return_statement))) (expression_statement (call_expression function: (identifier) arguments: (argument_list))))))

/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

void MASKED(undefined4 param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  ssize_t sVar3;
  int *piVar4;
  undefined4 uVar5;
  int in_GS_OFFSET;
  undefined1 local_1010 [4096];
  int local_10;
  
  iVar1 = param_2;
  local_10 = *(int *)(in_GS_OFFSET + 0x14);
  puVar2 = (undefined4 *)FUN_000817b0(DAT_00111a24,&param_1,FUN_0009dca0);
  if (puVar2 != (undefined4 *)0x0) {
    if (iVar1 == 1) {
      sVar3 = read(puVar2[1],local_1010,0x1000);
      if (sVar3 == 0) {
        if (-1 < (int)puVar2[1]) {
          close(puVar2[1]);
          puVar2[1] = 0xffffffff;
        }
        puVar2[2] = 1;
        FUN_00093290(*puVar2);
      }
      else if (sVar3 < 0) {
        piVar4 = __errno_location();
        if (*piVar4 != 0xb) {
          perror("read serial port");
                    /* WARNING: Subroutine does not return */
          exit(1);
        }
      }
      else {
        uVar5 = FUN_00092bf0(*puVar2,0,local_1010,sVar3);
        puVar2[3] = uVar5;
        FUN_0009dd70();
      }
    }
    else if (iVar1 == 2) {
      FUN_0009de80();
    }
  }
  if (local_10 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  FUN_000a39d0();
}

