#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 */

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sendQuery(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, unsigned char const *);
int db_updateDominoTilemap(char *usr, int index, const unsigned char *tilemap) {
  char string[66 * 1024];
  memset(string, 0, 66 * 1024);
  sprintf(string, "REPLACE INTO domino_tilemap VALUES('%s',%d,'%s')", usr,
          index, tilemap);
  int ret = sendQuery(string);
  if (ret) {
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<db_updateDominoTilemap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x10820(%rbp),%rdi
xor    %esi,%esi
mov    $0x10800,%edx
call   1040 <memset@plt>
lea    -0x10820(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
lea    0xe8e(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x10820(%rbp),%rdi
call   1030 <sendQuery@plt>
mov    %eax,-0x10824(%rbp)
cmpl   $0x0,-0x10824(%rbp)
je     11a2 <db_updateDominoTilemap+0x72>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <db_updateDominoTilemap+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_updateDominoTilemap>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x10808,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10800,%edx
call   1040 <memset@plt>
lea    0xea2(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r14,%r8
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <sendQuery@plt>
cmp    $0x1,%eax
sbb    %eax,%eax
add    $0x10808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"REPLACE INTO domino_tilemap VALUES('%s',%d,'%s')\00"
define i32 @db_updateDominoTilemap(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [67584 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [67584 x i8], [67584 x i8]* %8, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 67584)
%12 = getelementptr inbounds [67584 x i8], [67584 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = load i8*, i8** %7
%16 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14, i8* %15)
%17 = getelementptr inbounds [67584 x i8], [67584 x i8]* %8, i64 0, i64 0
%18 = call i32 @sendQuery(i8* %17)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 0, i32* %4
br label %23
22: ; preds = %3
store i32 -1, i32* %4
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [49 x i8] c"REPLACE INTO domino_tilemap VALUES('%s',%d,'%s')\00"
define i32 @db_updateDominoTilemap(i8* %0, i32 %1, i8* %2) {
%4 = alloca [67584 x i8]
%5 = getelementptr inbounds [67584 x i8], [67584 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 67584)
%7 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %2)
%8 = call i32 @sendQuery(i8* %5)
%9 = icmp eq i32 %8, 0
%10 = sext i1 %9 to i32
ret i32 %10
}