#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ add_CRC(int *, int, int);
int /*<<< orphan*/ printf(char *);
int rt_modbus_force_multiple_outputs(int *, int);
int rt_modbus_force_single_output(int *, int);
int rt_modbus_loopback(int *, int);
int rt_modbus_preset_multiple_registers(int *, int);
int rt_modbus_preset_single_register(int *, int);
int rt_modbus_read_analog_inputs(int *, int);
int rt_modbus_read_exception_status(int *, int);
int rt_modbus_read_input_table(int *, int);
int rt_modbus_read_output_table(int *, int);
int rt_modbus_read_registers(int *, int);
int rt_modbus_read_scratch_pad(int *, int);
int rt_modbus_report_device_type(int *, int);
int rt_modbus_process_request(uint8_t *buf, int n) {
  switch (buf[1]) {
  case (0x01):
    printf("READ_OUTPUT_TABLE:\n");
    return rt_modbus_read_output_table(buf, n);
  case (0x02):
    printf("READ_INPUT_TABLE:\n");
    printf("Calling rt_modbus_read_input_table()\n");
    return rt_modbus_read_input_table(buf, n);
  case (0x03):
    printf("READ_REGISTERS:\n");
    return rt_modbus_read_registers(buf, n);
  case (0x04):
    printf("READ_ANALOG_INPUTS:\n");
    return rt_modbus_read_analog_inputs(buf, n);
  case (0x05):
    printf("FORCE_SINGLE_OUTPUT:\n");
    return rt_modbus_force_single_output(buf, n);
  case (0x06):
    printf("PRESET_SINGLE_REGISTER:\n");
    return rt_modbus_preset_single_register(buf, n);
  case (0x07):
    printf("READ_EXCEPTION_STATUS:\n");
    return rt_modbus_read_exception_status(buf, n);
  case (0x08):
    printf("LOOPBACK:\n");
    return rt_modbus_loopback(buf, n);
  case (0x0F):
    printf("^^^^^^^^^^^^^^^^^^ FORCE_MULTIPLE_OUTPUTS:\n");
    return rt_modbus_force_multiple_outputs(buf, n);
  case (0x10):
    printf("@@@@@@@@@@@@@@@@@@@@ PRESET_MULTIPLE_REGISTERS:\n");
    return rt_modbus_preset_multiple_registers(buf, n);
  case (0x11):
    printf("REPORT_DEVICE_TYPE:\n");
    return rt_modbus_report_device_type(buf, n);
  case (67):
    printf("READ_SCRATCH_PAD:\n");
    return rt_modbus_read_scratch_pad(buf, n);
  default:
    printf("UNSUPORTED OPCODE:\n");
    if (buf[1] < 80)
      buf[1] += 0x80;
    else
      buf[1] = 0xFF;
    buf[2] = 0x01;
    add_CRC(buf, 5, 0xffff);
    return 5;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rt_modbus_process_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x42,%eax
ja     13a8 <rt_modbus_process_request+0x1c8>
mov    -0x20(%rbp),%rax
lea    0xded(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <rt_modbus_read_output_table@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xedd(%rip),%rdi
call   1050 <printf@plt>
lea    0xee4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10c0 <rt_modbus_read_input_table@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xeea(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <rt_modbus_read_registers@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xedb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <rt_modbus_read_analog_inputs@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xed0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10f0 <rt_modbus_force_single_output@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xec6(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <rt_modbus_preset_single_register@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xebf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <rt_modbus_read_exception_status@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xeb7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1100 <rt_modbus_loopback@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <rt_modbus_force_multiple_outputs@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10d0 <rt_modbus_preset_multiple_registers@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xebf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <rt_modbus_report_device_type@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10e0 <rt_modbus_read_scratch_pad@plt>
mov    %eax,-0x4(%rbp)
jmp    1407 <rt_modbus_process_request+0x227>
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x50,0x4(%rax)
jge    13d7 <rt_modbus_process_request+0x1f7>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x80,%ecx
mov    %ecx,0x4(%rax)
jmp    13e2 <rt_modbus_process_request+0x202>
mov    -0x10(%rbp),%rax
movl   $0xff,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
mov    $0xffff,%edx
call   10b0 <add_CRC@plt>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rt_modbus_process_request>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x4(%rdi),%eax
add    $0xffffffff,%eax
cmp    $0x42,%eax
ja     12f3 <rt_modbus_process_request+0x113>
mov    %esi,%ebp
lea    0xe02(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1028(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <rt_modbus_read_output_table@plt>
lea    0xfd5(%rip),%rdi
call   1050 <puts@plt>
lea    0xfdb(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10c0 <rt_modbus_read_input_table@plt>
lea    0xf9d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <rt_modbus_read_registers@plt>
lea    0xf6d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <rt_modbus_read_analog_inputs@plt>
lea    0xf3c(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10f0 <rt_modbus_force_single_output@plt>
lea    0xf08(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <rt_modbus_preset_single_register@plt>
lea    0xed5(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <rt_modbus_read_exception_status@plt>
lea    0xeaf(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1100 <rt_modbus_loopback@plt>
lea    0xf4f(%rip),%rdi
call   1050 <puts@plt>
mov    0x4(%rbx),%eax
lea    0x80(%rax),%ecx
cmp    $0x50,%eax
mov    $0xff,%eax
cmovl  %ecx,%eax
mov    %eax,0x4(%rbx)
movl   $0x1,0x8(%rbx)
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0xffff,%edx
call   10b0 <add_CRC@plt>
mov    $0x5,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe20(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <rt_modbus_force_multiple_outputs@plt>
lea    0xdd4(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10d0 <rt_modbus_preset_multiple_registers@plt>
lea    0xda4(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10a0 <rt_modbus_report_device_type@plt>
lea    0xd76(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10e0 <rt_modbus_read_scratch_pad@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"READ_OUTPUT_TABLE:\0A\00"
@.str.1 = [19 x i8] c"READ_INPUT_TABLE:\0A\00"
@.str.2 = [38 x i8] c"Calling rt_modbus_read_input_table()\0A\00"
@.str.3 = [17 x i8] c"READ_REGISTERS:\0A\00"
@.str.4 = [21 x i8] c"READ_ANALOG_INPUTS:\0A\00"
@.str.5 = [22 x i8] c"FORCE_SINGLE_OUTPUT:\0A\00"
@.str.6 = [25 x i8] c"PRESET_SINGLE_REGISTER:\0A\00"
@.str.7 = [24 x i8] c"READ_EXCEPTION_STATUS:\0A\00"
@.str.8 = [11 x i8] c"LOOPBACK:\0A\00"
@.str.9 = [44 x i8] c"^^^^^^^^^^^^^^^^^^ FORCE_MULTIPLE_OUTPUTS:\0A\00"
@.str.10 = [49 x i8] c"@@@@@@@@@@@@@@@@@@@@ PRESET_MULTIPLE_REGISTERS:\0A\00"
@.str.11 = [21 x i8] c"REPORT_DEVICE_TYPE:\0A\00"
@.str.12 = [19 x i8] c"READ_SCRATCH_PAD:\0A\00"
@.str.13 = [20 x i8] c"UNSUPORTED OPCODE:\0A\00"
define i32 @rt_modbus_process_request(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32*, i32** %4
%7 = getelementptr inbounds i32, i32* %6, i64 1
%8 = load i32, i32* %7
switch i32 %8, label %70 [
i32 1, label %9
i32 2, label %14
i32 3, label %20
i32 4, label %25
i32 5, label %30
i32 6, label %35
i32 7, label %40
i32 8, label %45
i32 15, label %50
i32 16, label %55
i32 17, label %60
i32 67, label %65
]
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @rt_modbus_read_output_table(i32* %11, i32 %12)
store i32 %13, i32* %3
br label %89
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = call i32 @rt_modbus_read_input_table(i32* %17, i32 %18)
store i32 %19, i32* %3
br label %89
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32*, i32** %4
%23 = load i32, i32* %5
%24 = call i32 @rt_modbus_read_registers(i32* %22, i32 %23)
store i32 %24, i32* %3
br label %89
25: ; preds = %2
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = call i32 @rt_modbus_read_analog_inputs(i32* %27, i32 %28)
store i32 %29, i32* %3
br label %89
30: ; preds = %2
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32*, i32** %4
%33 = load i32, i32* %5
%34 = call i32 @rt_modbus_force_single_output(i32* %32, i32 %33)
store i32 %34, i32* %3
br label %89
35: ; preds = %2
%36 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32*, i32** %4
%38 = load i32, i32* %5
%39 = call i32 @rt_modbus_preset_single_register(i32* %37, i32 %38)
store i32 %39, i32* %3
br label %89
40: ; preds = %2
%41 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%42 = load i32*, i32** %4
%43 = load i32, i32* %5
%44 = call i32 @rt_modbus_read_exception_status(i32* %42, i32 %43)
store i32 %44, i32* %3
br label %89
45: ; preds = %2
%46 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32*, i32** %4
%48 = load i32, i32* %5
%49 = call i32 @rt_modbus_loopback(i32* %47, i32 %48)
store i32 %49, i32* %3
br label %89
50: ; preds = %2
%51 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
%52 = load i32*, i32** %4
%53 = load i32, i32* %5
%54 = call i32 @rt_modbus_force_multiple_outputs(i32* %52, i32 %53)
store i32 %54, i32* %3
br label %89
55: ; preds = %2
%56 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
%57 = load i32*, i32** %4
%58 = load i32, i32* %5
%59 = call i32 @rt_modbus_preset_multiple_registers(i32* %57, i32 %58)
store i32 %59, i32* %3
br label %89
60: ; preds = %2
%61 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%62 = load i32*, i32** %4
%63 = load i32, i32* %5
%64 = call i32 @rt_modbus_report_device_type(i32* %62, i32 %63)
store i32 %64, i32* %3
br label %89
65: ; preds = %2
%66 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%67 = load i32*, i32** %4
%68 = load i32, i32* %5
%69 = call i32 @rt_modbus_read_scratch_pad(i32* %67, i32 %68)
store i32 %69, i32* %3
br label %89
70: ; preds = %2
%71 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%72 = load i32*, i32** %4
%73 = getelementptr inbounds i32, i32* %72, i64 1
%74 = load i32, i32* %73
%75 = icmp slt i32 %74, 80
br i1 %75, label %76, label %81
76: ; preds = %70
%77 = load i32*, i32** %4
%78 = getelementptr inbounds i32, i32* %77, i64 1
%79 = load i32, i32* %78
%80 = add nsw i32 %79, 128
store i32 %80, i32* %78
br label %84
81: ; preds = %70
%82 = load i32*, i32** %4
%83 = getelementptr inbounds i32, i32* %82, i64 1
store i32 255, i32* %83
br label %84
84: ; preds = %81, %76
%85 = load i32*, i32** %4
%86 = getelementptr inbounds i32, i32* %85, i64 2
store i32 1, i32* %86
%87 = load i32*, i32** %4
%88 = call i32 @add_CRC(i32* %87, i32 5, i32 65535)
store i32 5, i32* %3
br label %89
89: ; preds = %84, %65, %60, %55, %50, %45, %40, %35, %30, %25, %20, %14, %9
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@str = [18 x i8] c"READ_SCRATCH_PAD:\00"
@str.14 = [20 x i8] c"REPORT_DEVICE_TYPE:\00"
@str.15 = [48 x i8] c"@@@@@@@@@@@@@@@@@@@@ PRESET_MULTIPLE_REGISTERS:\00"
@str.16 = [43 x i8] c"^^^^^^^^^^^^^^^^^^ FORCE_MULTIPLE_OUTPUTS:\00"
@str.17 = [10 x i8] c"LOOPBACK:\00"
@str.18 = [23 x i8] c"READ_EXCEPTION_STATUS:\00"
@str.19 = [24 x i8] c"PRESET_SINGLE_REGISTER:\00"
@str.20 = [21 x i8] c"FORCE_SINGLE_OUTPUT:\00"
@str.21 = [20 x i8] c"READ_ANALOG_INPUTS:\00"
@str.22 = [16 x i8] c"READ_REGISTERS:\00"
@str.23 = [18 x i8] c"READ_INPUT_TABLE:\00"
@str.24 = [37 x i8] c"Calling rt_modbus_read_input_table()\00"
@str.25 = [19 x i8] c"READ_OUTPUT_TABLE:\00"
@str.26 = [19 x i8] c"UNSUPORTED OPCODE:\00"
define i32 @rt_modbus_process_request(i32* %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = load i32, i32* %3
switch i32 %4, label %42 [
i32 1, label %5
i32 2, label %8
i32 3, label %12
i32 4, label %15
i32 5, label %18
i32 6, label %21
i32 7, label %24
i32 8, label %27
i32 15, label %30
i32 16, label %33
i32 17, label %36
i32 67, label %39
]
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.25, i64 0, i64 0))
%7 = tail call i32 @rt_modbus_read_output_table(i32* %0, i32 %1)
br label %50
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.23, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.24, i64 0, i64 0))
%11 = tail call i32 @rt_modbus_read_input_table(i32* %0, i32 %1)
br label %50
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.22, i64 0, i64 0))
%14 = tail call i32 @rt_modbus_read_registers(i32* %0, i32 %1)
br label %50
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.21, i64 0, i64 0))
%17 = tail call i32 @rt_modbus_read_analog_inputs(i32* %0, i32 %1)
br label %50
18: ; preds = %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.20, i64 0, i64 0))
%20 = tail call i32 @rt_modbus_force_single_output(i32* %0, i32 %1)
br label %50
21: ; preds = %2
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.19, i64 0, i64 0))
%23 = tail call i32 @rt_modbus_preset_single_register(i32* %0, i32 %1)
br label %50
24: ; preds = %2
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
%26 = tail call i32 @rt_modbus_read_exception_status(i32* %0, i32 %1)
br label %50
27: ; preds = %2
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.17, i64 0, i64 0))
%29 = tail call i32 @rt_modbus_loopback(i32* %0, i32 %1)
br label %50
30: ; preds = %2
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.16, i64 0, i64 0))
%32 = tail call i32 @rt_modbus_force_multiple_outputs(i32* %0, i32 %1)
br label %50
33: ; preds = %2
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.15, i64 0, i64 0))
%35 = tail call i32 @rt_modbus_preset_multiple_registers(i32* %0, i32 %1)
br label %50
36: ; preds = %2
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0))
%38 = tail call i32 @rt_modbus_report_device_type(i32* %0, i32 %1)
br label %50
39: ; preds = %2
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%41 = tail call i32 @rt_modbus_read_scratch_pad(i32* %0, i32 %1)
br label %50
42: ; preds = %2
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.26, i64 0, i64 0))
%44 = load i32, i32* %3
%45 = icmp slt i32 %44, 80
%46 = add nsw i32 %44, 128
%47 = select i1 %45, i32 %46, i32 255
store i32 %47, i32* %3
%48 = getelementptr inbounds i32, i32* %0, i64 2
store i32 1, i32* %48
%49 = tail call i32 @add_CRC(i32* %0, i32 5, i32 65535)
br label %50
50: ; preds = %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %8, %5
%51 = phi i32 [ 5, %42 ], [ %41, %39 ], [ %38, %36 ], [ %35, %33 ], [ %32, %30 ], [ %29, %27 ], [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %8 ], [ %7, %5 ]
ret i32 %51
}