#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_request {
  int dummy;
};
struct auth_engine {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ HTTP_NOTIMPLEMENTED;
char *evhttp_find_header(struct evkeyvalq *, char *);
int /*<<< orphan*/ evhttp_send_error(struct evhttp_request *,
                                     int /*<<< orphan*/, char *);
int /*<<< orphan*/ reply(struct evhttp_request *, char *);
int /*<<< orphan*/ request_token(struct auth_engine *, struct session *,
                                 struct evhttp_request *, char const *);
scalar_t__ strcmp(char const *, char *);
void auth_cb(struct auth_engine *auth, struct session *session,
             struct evhttp_request *req, struct evkeyvalq *params) {
  const char *error;
  const char *code;
  if ((error = evhttp_find_header(params, "error")) != NULL) {
    if (strcmp(error, "access_denied") == 0) {
      reply(req, "<p>So um.. You're new to this, aren't you?"
                 "You're supposed to say yes. Let's try"
                 " <a href=\"/\">again</a>, ok?");
    } else {
      reply(req, "<p>Uh oh</p>");
    }
  } else if ((code = evhttp_find_header(params, "code")) != NULL) {
    request_token(auth, session, req, code);
  } else {
    evhttp_send_error(req, HTTP_NOTIMPLEMENTED, "TBD: Handle auth callback");
  }
}


x86 assembly (clang, -O0):
<auth_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <evhttp_find_header@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11ca <auth_cb+0x7a>
mov    -0x28(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <auth_cb+0x65>
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1040 <reply@plt>
jmp    11c5 <auth_cb+0x75>
mov    -0x18(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1040 <reply@plt>
jmp    1220 <auth_cb+0xd0>
mov    -0x20(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <evhttp_find_header@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1202 <auth_cb+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1060 <request_token@plt>
jmp    121b <auth_cb+0xcb>
mov    -0x18(%rbp),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
lea    0xe7b(%rip),%rdx
call   1070 <evhttp_send_error@plt>
jmp    1220 <auth_cb+0xd0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_cb>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe95(%rip),%rsi
mov    %rcx,%rdi
call   1030 <evhttp_find_header@plt>
test   %rax,%rax
je     1195 <auth_cb+0x45>
lea    0xe87(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c5 <auth_cb+0x75>
lea    0xeec(%rip),%rsi
jmp    11cc <auth_cb+0x7c>
lea    0xef0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <evhttp_find_header@plt>
test   %rax,%rax
je     11df <auth_cb+0x8f>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <request_token@plt>
lea    0xe48(%rip),%rsi
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <reply@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdx
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <evhttp_send_error@plt>

LLVM IR (-O0):
%struct.auth_engine = type { i32 }
%struct.session = type { i32 }
%struct.evhttp_request = type { i32 }
%struct.evkeyvalq = type { i32 }
@.str = [6 x i8] c"error\00"
@.str.1 = [14 x i8] c"access_denied\00"
@.str.2 = [107 x i8] c"<p>So um.. You're new to this, aren't you?You're supposed to say yes. Let's try <a href=\22/\22>again</a>, ok?\00"
@.str.3 = [13 x i8] c"<p>Uh oh</p>\00"
@.str.4 = [5 x i8] c"code\00"
@HTTP_NOTIMPLEMENTED = global i32 0
@.str.5 = [26 x i8] c"TBD: Handle auth callback\00"
define void @auth_cb(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, %struct.evkeyvalq* %3) {
%5 = alloca %struct.auth_engine*
%6 = alloca %struct.session*
%7 = alloca %struct.evhttp_request*
%8 = alloca %struct.evkeyvalq*
%9 = alloca i8*
%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.evkeyvalq* %3, %struct.evkeyvalq** %8
%11 = load %struct.evkeyvalq*, %struct.evkeyvalq** %8
%12 = call i8* @evhttp_find_header(%struct.evkeyvalq* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %25
14: ; preds = %4
%15 = load i8*, i8** %9
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%20 = call i32 @reply(%struct.evhttp_request* %19, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.2, i64 0, i64 0))
br label %24
21: ; preds = %14
%22 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%23 = call i32 @reply(%struct.evhttp_request* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
br label %40
25: ; preds = %4
%26 = load %struct.evkeyvalq*, %struct.evkeyvalq** %8
%27 = call i8* @evhttp_find_header(%struct.evkeyvalq* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* %27, i8** %10
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load %struct.auth_engine*, %struct.auth_engine** %5
%31 = load %struct.session*, %struct.session** %6
%32 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%33 = load i8*, i8** %10
%34 = call i32 @request_token(%struct.auth_engine* %30, %struct.session* %31, %struct.evhttp_request* %32, i8* %33)
br label %39
35: ; preds = %25
%36 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%37 = load i32, i32* @HTTP_NOTIMPLEMENTED
%38 = call i32 @evhttp_send_error(%struct.evhttp_request* %36, i32 %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %35, %29
br label %40
40: ; preds = %39, %24
ret void
}

LLVM IR (-O2):
%struct.auth_engine = type { i32 }
%struct.session = type { i32 }
%struct.evhttp_request = type { i32 }
%struct.evkeyvalq = type { i32 }
@.str = [6 x i8] c"error\00"
@.str.1 = [14 x i8] c"access_denied\00"
@.str.2 = [107 x i8] c"<p>So um.. You're new to this, aren't you?You're supposed to say yes. Let's try <a href=\22/\22>again</a>, ok?\00"
@.str.3 = [13 x i8] c"<p>Uh oh</p>\00"
@.str.4 = [5 x i8] c"code\00"
@HTTP_NOTIMPLEMENTED = global i32 0
@.str.5 = [26 x i8] c"TBD: Handle auth callback\00"
define void @auth_cb(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, %struct.evkeyvalq* %3) {
%5 = tail call i8* @evhttp_find_header(%struct.evkeyvalq* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @reply(%struct.evhttp_request* %2, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.2, i64 0, i64 0))
br label %22
12: ; preds = %7
%13 = tail call i32 @reply(%struct.evhttp_request* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %22
14: ; preds = %4
%15 = tail call i8* @evhttp_find_header(%struct.evkeyvalq* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @request_token(%struct.auth_engine* %0, %struct.session* %1, %struct.evhttp_request* %2, i8* %15)
br label %22
19: ; preds = %14
%20 = load i32, i32* @HTTP_NOTIMPLEMENTED
%21 = tail call i32 @evhttp_send_error(%struct.evhttp_request* %2, i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %17, %19, %10, %12
ret void
}