#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 */
struct json_object {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ controller_get_device_info(struct json_object *,
                                              struct json_object *);
int /*<<< orphan*/ controller_get_devices(struct json_object *,
                                          struct json_object *);
int /*<<< orphan*/ controller_get_events(struct json_object *,
                                         struct json_object *);
int /*<<< orphan*/ controller_set_device(struct json_object *,
                                         struct json_object *);
int /*<<< orphan*/ controller_set_device_info(struct json_object *,
                                              struct json_object *);
char *jsonrpc_request_method(struct json_object *);
int /*<<< orphan*/ jsonrpc_system_list_methods(struct json_object *,
                                               struct json_object *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
void jsonrpc_service(struct json_object *request,
                     struct json_object *response) {
  char *method = jsonrpc_request_method(request);
  printf("method=%s.\n", method);
  if (strcmp(method, "system.listMethods") == 0) {
    jsonrpc_system_list_methods(request, response);
  } else if (strcmp(method, "controller.getDevices") == 0) {
    controller_get_devices(request, response);
  } else if (strcmp(method, "controller.getDeviceInfo") == 0) {
    controller_get_device_info(request, response);
  } else if (strcmp(method, "controller.setDeviceInfo") == 0) {
    controller_set_device_info(request, response);
  } else if (strcmp(method, "controller.setDevice") == 0) {
    controller_set_device(request, response);
  } else if (strcmp(method, "controller.getEvents") == 0) {
    controller_get_events(request, response);
  }
}


x86 assembly (clang, -O0):
<jsonrpc_service>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <jsonrpc_request_method@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11e9 <jsonrpc_service+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <jsonrpc_system_list_methods@plt>
jmp    12d9 <jsonrpc_service+0x149>
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <jsonrpc_service+0x85>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <controller_get_devices@plt>
jmp    12d4 <jsonrpc_service+0x144>
mov    -0x18(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1241 <jsonrpc_service+0xb1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <controller_get_device_info@plt>
jmp    12cf <jsonrpc_service+0x13f>
mov    -0x18(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    126d <jsonrpc_service+0xdd>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10b0 <controller_set_device_info@plt>
jmp    12ca <jsonrpc_service+0x13a>
mov    -0x18(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1299 <jsonrpc_service+0x109>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <controller_set_device@plt>
jmp    12c5 <jsonrpc_service+0x135>
mov    -0x18(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12c0 <jsonrpc_service+0x130>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <controller_get_events@plt>
jmp    12c5 <jsonrpc_service+0x135>
jmp    12ca <jsonrpc_service+0x13a>
jmp    12cf <jsonrpc_service+0x13f>
jmp    12d4 <jsonrpc_service+0x144>
jmp    12d9 <jsonrpc_service+0x149>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonrpc_service>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <jsonrpc_request_method@plt>
mov    %rax,%rbx
lea    0xe56(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1230 <jsonrpc_service+0xa0>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1240 <jsonrpc_service+0xb0>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1250 <jsonrpc_service+0xc0>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1260 <jsonrpc_service+0xd0>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1270 <jsonrpc_service+0xe0>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1280 <jsonrpc_service+0xf0>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    10a0 <jsonrpc_system_list_methods@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <controller_get_devices@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <controller_get_device_info@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    10b0 <controller_set_device_info@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <controller_set_device@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1090 <controller_get_events@plt>

LLVM IR (-O0):
%struct.json_object = type { i32 }
@.str = [12 x i8] c"method=%s.\0A\00"
@.str.1 = [19 x i8] c"system.listMethods\00"
@.str.2 = [22 x i8] c"controller.getDevices\00"
@.str.3 = [25 x i8] c"controller.getDeviceInfo\00"
@.str.4 = [25 x i8] c"controller.setDeviceInfo\00"
@.str.5 = [21 x i8] c"controller.setDevice\00"
@.str.6 = [21 x i8] c"controller.getEvents\00"
define void @jsonrpc_service(%struct.json_object* %0, %struct.json_object* %1) {
%3 = alloca %struct.json_object*
%4 = alloca %struct.json_object*
%5 = alloca i8*
store %struct.json_object* %0, %struct.json_object** %3
store %struct.json_object* %1, %struct.json_object** %4
%6 = load %struct.json_object*, %struct.json_object** %3
%7 = call i8* @jsonrpc_request_method(%struct.json_object* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load %struct.json_object*, %struct.json_object** %3
%15 = load %struct.json_object*, %struct.json_object** %4
%16 = call i32 @jsonrpc_system_list_methods(%struct.json_object* %14, %struct.json_object* %15)
br label %62
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load %struct.json_object*, %struct.json_object** %3
%23 = load %struct.json_object*, %struct.json_object** %4
%24 = call i32 @controller_get_devices(%struct.json_object* %22, %struct.json_object* %23)
br label %61
25: ; preds = %17
%26 = load i8*, i8** %5
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load %struct.json_object*, %struct.json_object** %3
%31 = load %struct.json_object*, %struct.json_object** %4
%32 = call i32 @controller_get_device_info(%struct.json_object* %30, %struct.json_object* %31)
br label %60
33: ; preds = %25
%34 = load i8*, i8** %5
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load %struct.json_object*, %struct.json_object** %3
%39 = load %struct.json_object*, %struct.json_object** %4
%40 = call i32 @controller_set_device_info(%struct.json_object* %38, %struct.json_object* %39)
br label %59
41: ; preds = %33
%42 = load i8*, i8** %5
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load %struct.json_object*, %struct.json_object** %3
%47 = load %struct.json_object*, %struct.json_object** %4
%48 = call i32 @controller_set_device(%struct.json_object* %46, %struct.json_object* %47)
br label %58
49: ; preds = %41
%50 = load i8*, i8** %5
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load %struct.json_object*, %struct.json_object** %3
%55 = load %struct.json_object*, %struct.json_object** %4
%56 = call i32 @controller_get_events(%struct.json_object* %54, %struct.json_object* %55)
br label %57
57: ; preds = %53, %49
br label %58
58: ; preds = %57, %45
br label %59
59: ; preds = %58, %37
br label %60
60: ; preds = %59, %29
br label %61
61: ; preds = %60, %21
br label %62
62: ; preds = %61, %13
ret void
}

LLVM IR (-O2):
%struct.json_object = type { i32 }
@.str = [12 x i8] c"method=%s.\0A\00"
@.str.1 = [19 x i8] c"system.listMethods\00"
@.str.2 = [22 x i8] c"controller.getDevices\00"
@.str.3 = [25 x i8] c"controller.getDeviceInfo\00"
@.str.4 = [25 x i8] c"controller.setDeviceInfo\00"
@.str.5 = [21 x i8] c"controller.setDevice\00"
@.str.6 = [21 x i8] c"controller.getEvents\00"
define void @jsonrpc_service(%struct.json_object* %0, %struct.json_object* %1) {
%3 = tail call i8* @jsonrpc_request_method(%struct.json_object* %0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @jsonrpc_system_list_methods(%struct.json_object* %0, %struct.json_object* %1)
br label %34
9: ; preds = %2
%10 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @controller_get_devices(%struct.json_object* %0, %struct.json_object* %1)
br label %34
14: ; preds = %9
%15 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @controller_get_device_info(%struct.json_object* %0, %struct.json_object* %1)
br label %34
19: ; preds = %14
%20 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @controller_set_device_info(%struct.json_object* %0, %struct.json_object* %1)
br label %34
24: ; preds = %19
%25 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @controller_set_device(%struct.json_object* %0, %struct.json_object* %1)
br label %34
29: ; preds = %24
%30 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = tail call i32 @controller_get_events(%struct.json_object* %0, %struct.json_object* %1)
br label %34
34: ; preds = %12, %22, %29, %32, %27, %17, %7
ret void
}