#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 colog_response {
  int dummy;
};
struct colog_request {
  int dummy;
};

/* Variables and functions */
scalar_t__ check_verbose();
int /*<<< orphan*/ drop_request(struct colog_request *);
int /*<<< orphan*/ printf(char *, int, int, int, char *, char *);
struct colog_request *resolve_responded(int, int);
int colog_received_response(int when, int pid, int tid, char *who, int dir,
                            char *wptr) {
  struct colog_request *qptr;
  struct colog_request *rptr;
  struct colog_response *aptr;
  if (!(qptr = resolve_responded(pid, tid)))
    return (78);
  else {
    if (check_verbose())
      printf("recv reponse event(%u,%u,%u,%s,%s)\n", when, pid, tid, who, wptr);
    drop_request(qptr);
    return (0);
  }
}


x86 assembly (clang, -O0):
<colog_received_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <resolve_responded@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1182 <colog_received_response+0x42>
movl   $0x4e,-0x4(%rbp)
jmp    11c0 <colog_received_response+0x80>
mov    $0x0,%al
call   1060 <check_verbose@plt>
cmp    $0x0,%rax
je     11b0 <colog_received_response+0x70>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xe55(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <drop_request@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colog_received_response>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r12
mov    %rcx,%r15
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%r14d
mov    %esi,%edi
mov    %edx,%esi
call   1030 <resolve_responded@plt>
test   %rax,%rax
je     11a2 <colog_received_response+0x62>
mov    %rax,%rbp
mov    %r12,(%rsp)
xor    %r12d,%r12d
xor    %eax,%eax
call   1060 <check_verbose@plt>
test   %rax,%rax
je     1198 <colog_received_response+0x58>
lea    0xe7c(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r13d,%ecx
mov    %r15,%r8
mov    (%rsp),%r9
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1040 <drop_request@plt>
jmp    11a8 <colog_received_response+0x68>
mov    $0x4e,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.colog_request = type { i32 }
%struct.colog_response = type { i32 }
@.str = [36 x i8] c"recv reponse event(%u,%u,%u,%s,%s)\0A\00"
define i32 @colog_received_response(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca %struct.colog_request*
%15 = alloca %struct.colog_request*
%16 = alloca %struct.colog_response*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = call %struct.colog_request* @resolve_responded(i32 %17, i32 %18)
store %struct.colog_request* %19, %struct.colog_request** %14
%20 = icmp ne %struct.colog_request* %19, null
br i1 %20, label %22, label %21
21: ; preds = %6
store i32 78, i32* %7
br label %35
22: ; preds = %6
%23 = call i64 (...) @check_verbose()
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = load i8*, i8** %11
%30 = load i8*, i8** %13
%31 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27, i32 %28, i8* %29, i8* %30)
br label %32
32: ; preds = %25, %22
%33 = load %struct.colog_request*, %struct.colog_request** %14
%34 = call i32 @drop_request(%struct.colog_request* %33)
store i32 0, i32* %7
br label %35
35: ; preds = %32, %21
%36 = load i32, i32* %7
ret i32 %36
}

LLVM IR (-O2):
%struct.colog_request = type { i32 }
%struct.colog_response = type { i32 }
@.str = [36 x i8] c"recv reponse event(%u,%u,%u,%s,%s)\0A\00"
define i32 @colog_received_response(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4, i8* %5) {
%7 = tail call %struct.colog_request* @resolve_responded(i32 %1, i32 %2)
%8 = icmp eq %struct.colog_request* %7, null
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i64 (...) @check_verbose()
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i8* %3, i8* %5)
br label %14
14: ; preds = %12, %9
%15 = tail call i32 @drop_request(%struct.colog_request* %7)
br label %16
16: ; preds = %6, %14
%17 = phi i32 [ 0, %14 ], [ 78, %6 ]
ret i32 %17
}