#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 session {
  int dummy;
};
struct evkeyvalq {
  int dummy;
};
struct evhttp_uri {
  int dummy;
};
struct evhttp_request {
  int dummy;
};
struct auth_engine {
  int dummy;
};
typedef int /*<<< orphan*/ params;

/* Variables and functions */
int /*<<< orphan*/ auth_cb(struct auth_engine *, struct session *,
                           struct evhttp_request *, struct evkeyvalq *);
int /*<<< orphan*/ auth_dispatch(struct auth_engine *, struct evhttp_request *);
int /*<<< orphan*/ evhttp_clear_headers(struct evkeyvalq *);
char *evhttp_find_header(struct evkeyvalq *, char *);
int /*<<< orphan*/ evhttp_parse_query_str(int /*<<< orphan*/,
                                          struct evkeyvalq *);
int /*<<< orphan*/ evhttp_uri_get_query(struct evhttp_uri *);
int /*<<< orphan*/ memset(struct evkeyvalq *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char const *, char *);
void auth_handle(struct auth_engine *auth, struct session *session,
                 struct evhttp_request *req, struct evhttp_uri *uri) {
  struct evkeyvalq params;
  const char *state;
  memset(&params, 0, sizeof(params));
  evhttp_parse_query_str(evhttp_uri_get_query(uri), &params);
  state = evhttp_find_header(&params, "state");
  if (state != NULL && strcmp(state, "auth") == 0) {
    auth_cb(auth, session, req, &params);
  } else {
    auth_dispatch(auth, req);
  }
  evhttp_clear_headers(&params);
}


x86 assembly (clang, -O0):
<auth_handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <evhttp_uri_get_query@plt>
mov    %eax,%edi
lea    -0x28(%rbp),%rsi
call   1060 <evhttp_parse_query_str@plt>
lea    -0x28(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1040 <evhttp_find_header@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120f <auth_handle+0x8f>
mov    -0x30(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    120f <auth_handle+0x8f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1090 <auth_cb@plt>
jmp    121c <auth_handle+0x9c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <auth_dispatch@plt>
lea    -0x28(%rbp),%rdi
call   1080 <evhttp_clear_headers@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_handle>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x8(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   10a0 <evhttp_uri_get_query@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <evhttp_parse_query_str@plt>
lea    0xe3a(%rip),%rsi
mov    %r13,%rdi
call   1040 <evhttp_find_header@plt>
test   %rax,%rax
je     11e7 <auth_handle+0x67>
lea    0xe2c(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f4 <auth_handle+0x74>
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <auth_dispatch@plt>
jmp    1207 <auth_handle+0x87>
lea    0x8(%rsp),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1090 <auth_cb@plt>
lea    0x8(%rsp),%rdi
call   1080 <evhttp_clear_headers@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.auth_engine = type { i32 }
%struct.session = type { i32 }
%struct.evhttp_request = type { i32 }
%struct.evhttp_uri = type { i32 }
%struct.evkeyvalq = type { i32 }
@.str = [6 x i8] c"state\00"
@.str.1 = [5 x i8] c"auth\00"
define void @auth_handle(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, %struct.evhttp_uri* %3) {
%5 = alloca %struct.auth_engine*
%6 = alloca %struct.session*
%7 = alloca %struct.evhttp_request*
%8 = alloca %struct.evhttp_uri*
%9 = alloca %struct.evkeyvalq
%10 = alloca i8*
store %struct.auth_engine* %0, %struct.auth_engine** %5
store %struct.session* %1, %struct.session** %6
store %struct.evhttp_request* %2, %struct.evhttp_request** %7
store %struct.evhttp_uri* %3, %struct.evhttp_uri** %8
%11 = call i32 @memset(%struct.evkeyvalq* %9, i32 0, i32 4)
%12 = load %struct.evhttp_uri*, %struct.evhttp_uri** %8
%13 = call i32 @evhttp_uri_get_query(%struct.evhttp_uri* %12)
%14 = call i32 @evhttp_parse_query_str(i32 %13, %struct.evkeyvalq* %9)
%15 = call i8* @evhttp_find_header(%struct.evkeyvalq* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %10
%16 = load i8*, i8** %10
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %27
18: ; preds = %4
%19 = load i8*, i8** %10
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load %struct.auth_engine*, %struct.auth_engine** %5
%24 = load %struct.session*, %struct.session** %6
%25 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%26 = call i32 @auth_cb(%struct.auth_engine* %23, %struct.session* %24, %struct.evhttp_request* %25, %struct.evkeyvalq* %9)
br label %31
27: ; preds = %18, %4
%28 = load %struct.auth_engine*, %struct.auth_engine** %5
%29 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%30 = call i32 @auth_dispatch(%struct.auth_engine* %28, %struct.evhttp_request* %29)
br label %31
31: ; preds = %27, %22
%32 = call i32 @evhttp_clear_headers(%struct.evkeyvalq* %9)
ret void
}

LLVM IR (-O2):
%struct.auth_engine = type { i32 }
%struct.session = type { i32 }
%struct.evhttp_request = type { i32 }
%struct.evhttp_uri = type { i32 }
%struct.evkeyvalq = type { i32 }
@.str = [6 x i8] c"state\00"
@.str.1 = [5 x i8] c"auth\00"
define void @auth_handle(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, %struct.evhttp_uri* %3) {
%5 = alloca %struct.evkeyvalq
%6 = bitcast %struct.evkeyvalq* %5 to i8*
%7 = call i32 @memset(%struct.evkeyvalq* %5, i32 0, i32 4)
%8 = call i32 @evhttp_uri_get_query(%struct.evhttp_uri* %3)
%9 = call i32 @evhttp_parse_query_str(i32 %8, %struct.evkeyvalq* %5)
%10 = call i8* @evhttp_find_header(%struct.evkeyvalq* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %4
%13 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @auth_cb(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, %struct.evkeyvalq* %5)
br label %19
17: ; preds = %12, %4
%18 = call i32 @auth_dispatch(%struct.auth_engine* %0, %struct.evhttp_request* %2)
br label %19
19: ; preds = %17, %15
%20 = call i32 @evhttp_clear_headers(%struct.evkeyvalq* %5)
ret void
}