#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 */
typedef int /*<<< orphan*/ sqlite3_stmt;

/* Variables and functions */
int atoi(char *);
int sqlite3_column_count(int /*<<< orphan*/ *);
scalar_t__ sqlite3_column_name(int /*<<< orphan*/ *, int);
scalar_t__ sqlite3_column_text(int /*<<< orphan*/ *, int);
char *sqlite3_malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int evaluate_stmt_string(sqlite3_stmt *pp_stmt, char *number, int priority) {
  int num_column;
  int count;
  char *col_name;
  char *col_value;
  int tmp_priority = 0;
  char tmp_number[32] = "";
  num_column = sqlite3_column_count(pp_stmt);
  col_name = sqlite3_malloc(2 * num_column * sizeof(const char *) + 1);
  for (count = 0; count < num_column; count++) {
    col_name = (char *)sqlite3_column_name(pp_stmt, count);
    col_value = (char *)sqlite3_column_text(pp_stmt, count);
    if (0 == strcmp(col_name, "priority")) {
      tmp_priority = atoi(col_value);
    } else if (0 == strcmp(col_name, "countrycode")) {
      strcat(tmp_number, col_value);
    } else if (0 == strcmp(col_name, "areacode")) {
      strcat(tmp_number, col_value);
    } else if (0 == strcmp(col_name, "number")) {
      strcat(tmp_number, col_value);
    }
  }
  if (-999 == tmp_priority) {
    if (0 == strcmp(tmp_number, number))
      return 1;
  } else if (tmp_priority <= priority) {
    if (0 == strcmp(tmp_number, number))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<evaluate_stmt_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1060 <sqlite3_column_count@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
add    $0x1,%rax
mov    %eax,%edi
call   10a0 <sqlite3_malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12e0 <evaluate_stmt_string+0x160>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <sqlite3_column_name@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1233 <evaluate_stmt_string+0xb3>
mov    -0x38(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x3c(%rbp)
jmp    12cd <evaluate_stmt_string+0x14d>
mov    -0x30(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1263 <evaluate_stmt_string+0xe3>
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <strcat@plt>
jmp    12c8 <evaluate_stmt_string+0x148>
mov    -0x30(%rbp),%rdi
lea    0xda7(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1293 <evaluate_stmt_string+0x113>
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <strcat@plt>
jmp    12c3 <evaluate_stmt_string+0x143>
mov    -0x30(%rbp),%rdi
lea    0xd80(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12be <evaluate_stmt_string+0x13e>
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <strcat@plt>
jmp    12c3 <evaluate_stmt_string+0x143>
jmp    12c8 <evaluate_stmt_string+0x148>
jmp    12cd <evaluate_stmt_string+0x14d>
jmp    12d2 <evaluate_stmt_string+0x152>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d8 <evaluate_stmt_string+0x58>
mov    $0xfffffc19,%eax
cmp    -0x3c(%rbp),%eax
jne    131a <evaluate_stmt_string+0x19a>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1315 <evaluate_stmt_string+0x195>
movl   $0x1,-0x4(%rbp)
jmp    135e <evaluate_stmt_string+0x1de>
jmp    1357 <evaluate_stmt_string+0x1d7>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1352 <evaluate_stmt_string+0x1d2>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    134d <evaluate_stmt_string+0x1cd>
movl   $0x1,-0x4(%rbp)
jmp    135e <evaluate_stmt_string+0x1de>
jmp    1352 <evaluate_stmt_string+0x1d2>
jmp    1357 <evaluate_stmt_string+0x1d7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluate_stmt_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
call   1050 <sqlite3_column_count@plt>
mov    %eax,%ebp
mov    %eax,%edi
shl    $0x4,%edi
or     $0x1,%edi
call   1090 <sqlite3_malloc@plt>
test   %ebp,%ebp
jle    1278 <evaluate_stmt_string+0x108>
mov    %r15d,0x4(%rsp)
mov    %r14,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0xe38(%rip),%r13
xor    %r15d,%r15d
jmp    11e6 <evaluate_stmt_string+0x76>
nopl   (%rax)
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
add    $0x1,%r15d
cmp    %r15d,%ebp
je     125d <evaluate_stmt_string+0xed>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <sqlite3_column_name@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1250 <evaluate_stmt_string+0xe0>
mov    %r12,%rdi
lea    0xded(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d0 <evaluate_stmt_string+0x60>
mov    %r12,%rdi
lea    0xde5(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d0 <evaluate_stmt_string+0x60>
mov    %r12,%rdi
lea    0xdda(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11dd <evaluate_stmt_string+0x6d>
jmp    11d0 <evaluate_stmt_string+0x60>
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %eax,(%rsp)
jmp    11dd <evaluate_stmt_string+0x6d>
mov    (%rsp),%eax
cmp    $0xfffffc19,%eax
mov    0x8(%rsp),%r14
mov    0x4(%rsp),%r15d
je     127f <evaluate_stmt_string+0x10f>
cmp    %r15d,%eax
jle    127f <evaluate_stmt_string+0x10f>
jmp    1291 <evaluate_stmt_string+0x121>
xor    %eax,%eax
cmp    %r15d,%eax
jg     1291 <evaluate_stmt_string+0x121>
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1295 <evaluate_stmt_string+0x125>
xor    %eax,%eax
jmp    129a <evaluate_stmt_string+0x12a>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"priority\00"
@.str.1 = [12 x i8] c"countrycode\00"
@.str.2 = [9 x i8] c"areacode\00"
@.str.3 = [7 x i8] c"number\00"
define i32 @evaluate_stmt_string(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [32 x i8]
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %12
%14 = bitcast [32 x i8]* %13 to i8*
%15 = load i32*, i32** %5
%16 = call i32 @sqlite3_column_count(i32* %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = mul nsw i32 2, %17
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 8
%21 = add i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i8* @sqlite3_malloc(i32 %22)
store i8* %23, i8** %10
store i32 0, i32* %9
br label %24
24: ; preds = %71, %3
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %74
28: ; preds = %24
%29 = load i32*, i32** %5
%30 = load i32, i32* %9
%31 = call i64 @sqlite3_column_name(i32* %29, i32 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %10
%33 = load i32*, i32** %5
%34 = load i32, i32* %9
%35 = call i64 @sqlite3_column_text(i32* %33, i32 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %11
%37 = load i8*, i8** %10
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 0, %38
br i1 %39, label %40, label %43
40: ; preds = %28
%41 = load i8*, i8** %11
%42 = call i32 @atoi(i8* %41)
store i32 %42, i32* %12
br label %70
43: ; preds = %28
%44 = load i8*, i8** %10
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 0, %45
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%49 = load i8*, i8** %11
%50 = call i32 @strcat(i8* %48, i8* %49)
br label %69
51: ; preds = %43
%52 = load i8*, i8** %10
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp eq i64 0, %53
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%57 = load i8*, i8** %11
%58 = call i32 @strcat(i8* %56, i8* %57)
br label %68
59: ; preds = %51
%60 = load i8*, i8** %10
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%62 = icmp eq i64 0, %61
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%65 = load i8*, i8** %11
%66 = call i32 @strcat(i8* %64, i8* %65)
br label %67
67: ; preds = %63, %59
br label %68
68: ; preds = %67, %55
br label %69
69: ; preds = %68, %47
br label %70
70: ; preds = %69, %40
br label %71
71: ; preds = %70
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %24
74: ; preds = %24
%75 = load i32, i32* %12
%76 = icmp eq i32 -999, %75
br i1 %76, label %77, label %84
77: ; preds = %74
%78 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%79 = load i8*, i8** %6
%80 = call i64 @strcmp(i8* %78, i8* %79)
%81 = icmp eq i64 0, %80
br i1 %81, label %82, label %83
82: ; preds = %77
store i32 1, i32* %4
br label %97
83: ; preds = %77
br label %96
84: ; preds = %74
%85 = load i32, i32* %12
%86 = load i32, i32* %7
%87 = icmp sle i32 %85, %86
br i1 %87, label %88, label %95
88: ; preds = %84
%89 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%90 = load i8*, i8** %6
%91 = call i64 @strcmp(i8* %89, i8* %90)
%92 = icmp eq i64 0, %91
br i1 %92, label %93, label %94
93: ; preds = %88
store i32 1, i32* %4
br label %97
94: ; preds = %88
br label %95
95: ; preds = %94, %84
br label %96
96: ; preds = %95, %83
store i32 0, i32* %4
br label %97
97: ; preds = %96, %93, %82
%98 = load i32, i32* %4
ret i32 %98
}

LLVM IR (-O2):
@.str = [9 x i8] c"priority\00"
@.str.1 = [12 x i8] c"countrycode\00"
@.str.2 = [9 x i8] c"areacode\00"
@.str.3 = [7 x i8] c"number\00"
define i32 @evaluate_stmt_string(i32* %0, i8* %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @sqlite3_column_count(i32* %0)
%7 = shl i32 %6, 4
%8 = or i32 %7, 1
%9 = tail call i8* @sqlite3_malloc(i32 %8)
%10 = icmp sgt i32 %6, 0
br i1 %10, label %11, label %46
11: ; preds = %3, %37
%12 = phi i32 [ %38, %37 ], [ 0, %3 ]
%13 = phi i32 [ %39, %37 ], [ 0, %3 ]
%14 = call i64 @sqlite3_column_name(i32* %0, i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = call i64 @sqlite3_column_text(i32* %0, i32 %13)
%17 = inttoptr i64 %16 to i8*
%18 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @atoi(i8* %17)
br label %37
22: ; preds = %11
%23 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @strcat(i8* %5, i8* %17)
br label %37
27: ; preds = %22
%28 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @strcat(i8* %5, i8* %17)
br label %37
32: ; preds = %27
%33 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @strcat(i8* %5, i8* %17)
br label %37
37: ; preds = %20, %30, %35, %32, %25
%38 = phi i32 [ %21, %20 ], [ %12, %25 ], [ %12, %30 ], [ %12, %35 ], [ %12, %32 ]
%39 = add nuw nsw i32 %13, 1
%40 = icmp eq i32 %39, %6
br i1 %40, label %41, label %11
41: ; preds = %37
%42 = icmp eq i32 %38, -999
br i1 %42, label %43, label %46
43: ; preds = %41
%44 = call i64 @strcmp(i8* %5, i8* %1)
%45 = icmp eq i64 %44, 0
br i1 %45, label %53, label %52
46: ; preds = %3, %41
%47 = phi i32 [ %38, %41 ], [ 0, %3 ]
%48 = icmp sgt i32 %47, %2
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = call i64 @strcmp(i8* %5, i8* %1)
%51 = icmp eq i64 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %46, %49, %43
br label %53
53: ; preds = %49, %43, %52
%54 = phi i32 [ 0, %52 ], [ 1, %43 ], [ 1, %49 ]
ret i32 %54
}