#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 evkeyvalq {
  int dummy;
};

/* Variables and functions */
int atoi_limited(char const *, int, int);
char *evhttp_find_header(struct evkeyvalq *, char *);
void setup_pagination(int *start, int *max, struct evkeyvalq *params) {
  const char *raw;
  *start = 1;
  *max = 26;
  raw = evhttp_find_header(params, "start-index");
  if (raw != NULL) {
    *start = atoi_limited(raw, 1, 1000000);
  }
  raw = evhttp_find_header(params, "max-results");
  if (raw != NULL) {
    *max = atoi_limited(raw, 1, 50);
  }
}


x86 assembly (clang, -O0):
<setup_pagination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1a,(%rax)
mov    -0x18(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1030 <evhttp_find_header@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1182 <setup_pagination+0x62>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0xf4240,%edx
call   1040 <atoi_limited@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <evhttp_find_header@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11bc <setup_pagination+0x9c>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x32,%edx
call   1040 <atoi_limited@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_pagination>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x1,(%rdi)
movl   $0x1a,(%rsi)
lea    0xebf(%rip),%rsi
mov    %rdx,%rdi
call   1030 <evhttp_find_header@plt>
test   %rax,%rax
je     1163 <setup_pagination+0x43>
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0xf4240,%edx
call   1040 <atoi_limited@plt>
mov    %eax,(%r15)
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <evhttp_find_header@plt>
test   %rax,%rax
je     118c <setup_pagination+0x6c>
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x32,%edx
call   1040 <atoi_limited@plt>
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.evkeyvalq = type { i32 }
@.str = [12 x i8] c"start-index\00"
@.str.1 = [12 x i8] c"max-results\00"
define void @setup_pagination(i32* %0, i32* %1, %struct.evkeyvalq* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca %struct.evkeyvalq*
%7 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store %struct.evkeyvalq* %2, %struct.evkeyvalq** %6
%8 = load i32*, i32** %4
store i32 1, i32* %8
%9 = load i32*, i32** %5
store i32 26, i32* %9
%10 = load %struct.evkeyvalq*, %struct.evkeyvalq** %6
%11 = call i8* @evhttp_find_header(%struct.evkeyvalq* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = call i32 @atoi_limited(i8* %15, i32 1, i32 1000000)
%17 = load i32*, i32** %4
store i32 %16, i32* %17
br label %18
18: ; preds = %14, %3
%19 = load %struct.evkeyvalq*, %struct.evkeyvalq** %6
%20 = call i8* @evhttp_find_header(%struct.evkeyvalq* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i8*, i8** %7
%25 = call i32 @atoi_limited(i8* %24, i32 1, i32 50)
%26 = load i32*, i32** %5
store i32 %25, i32* %26
br label %27
27: ; preds = %23, %18
ret void
}

LLVM IR (-O2):
%struct.evkeyvalq = type { i32 }
@.str = [12 x i8] c"start-index\00"
@.str.1 = [12 x i8] c"max-results\00"
define void @setup_pagination(i32* nocapture writeonly %0, i32* nocapture writeonly %1, %struct.evkeyvalq* %2) {
store i32 1, i32* %0
store i32 26, i32* %1
%4 = tail call i8* @evhttp_find_header(%struct.evkeyvalq* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @atoi_limited(i8* %4, i32 1, i32 1000000)
store i32 %7, i32* %0
br label %8
8: ; preds = %6, %3
%9 = tail call i8* @evhttp_find_header(%struct.evkeyvalq* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @atoi_limited(i8* %9, i32 1, i32 50)
store i32 %12, i32* %1
br label %13
13: ; preds = %11, %8
ret void
}