#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 */
struct json_object *json_object_new_object();
int /*<<< orphan*/ json_object_put(struct json_object *);
char *json_object_to_json_string(struct json_object *);
struct json_object *json_tokener_parse(char *);
int /*<<< orphan*/ jsonrpc_service(struct json_object *, struct json_object *);
int /*<<< orphan*/ printf(char *, char *);
char *jsonrpc_process(char *request_text) {
  char *response_text;
  struct json_object *request;
  struct json_object *response;
  request = json_tokener_parse(request_text);
  response = json_object_new_object();
  jsonrpc_service(request, response);
  response_text = json_object_to_json_string(response);
  printf("response_text=%s\n", response_text);
  json_object_put(request);
  json_object_put(response);
  return response_text;
}


x86 assembly (clang, -O0):
<jsonrpc_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <json_tokener_parse@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <json_object_new_object@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <jsonrpc_service@plt>
mov    -0x20(%rbp),%rdi
call   1040 <json_object_to_json_string@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <json_object_put@plt>
mov    -0x20(%rbp),%rdi
call   1080 <json_object_put@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonrpc_process>:
push   %r15
push   %r14
push   %rbx
call   1030 <json_tokener_parse@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <json_object_new_object@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <jsonrpc_service@plt>
mov    %rbx,%rdi
call   1040 <json_object_to_json_string@plt>
mov    %rax,%r15
lea    0xe6c(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1080 <json_object_put@plt>
mov    %rbx,%rdi
call   1080 <json_object_put@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.json_object = type { i32 }
@.str = [18 x i8] c"response_text=%s\0A\00"
define i8* @jsonrpc_process(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.json_object*
%5 = alloca %struct.json_object*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call %struct.json_object* @json_tokener_parse(i8* %6)
store %struct.json_object* %7, %struct.json_object** %4
%8 = call %struct.json_object* (...) @json_object_new_object()
store %struct.json_object* %8, %struct.json_object** %5
%9 = load %struct.json_object*, %struct.json_object** %4
%10 = load %struct.json_object*, %struct.json_object** %5
%11 = call i32 @jsonrpc_service(%struct.json_object* %9, %struct.json_object* %10)
%12 = load %struct.json_object*, %struct.json_object** %5
%13 = call i8* @json_object_to_json_string(%struct.json_object* %12)
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load %struct.json_object*, %struct.json_object** %4
%17 = call i32 @json_object_put(%struct.json_object* %16)
%18 = load %struct.json_object*, %struct.json_object** %5
%19 = call i32 @json_object_put(%struct.json_object* %18)
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
%struct.json_object = type { i32 }
@.str = [18 x i8] c"response_text=%s\0A\00"
define i8* @jsonrpc_process(i8* %0) {
%2 = tail call %struct.json_object* @json_tokener_parse(i8* %0)
%3 = tail call %struct.json_object* (...) @json_object_new_object()
%4 = tail call i32 @jsonrpc_service(%struct.json_object* %2, %struct.json_object* %3)
%5 = tail call i8* @json_object_to_json_string(%struct.json_object* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @json_object_put(%struct.json_object* %2)
%8 = tail call i32 @json_object_put(%struct.json_object* %3)
ret i8* %5
}