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

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ free(char *);
char *generateRandomSizeString(int);
int mysql_errno(int /*<<< orphan*/ *);
char *mysql_error(int /*<<< orphan*/ *);
scalar_t__ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *, char *,
                            char *);
int /*<<< orphan*/ strcat(char *, char *);
void insertRandomRecord(MYSQL *connection, char *tableName) {
  char *message = calloc(11000, sizeof(char));
  char query[11000];
  char *stat = "INSERT INTO benchmark.%s ("
               "name, "
               "email, "
               "password, "
               "text "
               ") VALUES ("
               "\'%s\', "
               "\'%s\', "
               "\'%s\', "
               "\'%s\' "
               ");";
  char *name = generateRandomSizeString(100);
  char *email = generateRandomSizeString(100);
  char *password = generateRandomSizeString(100);
  char *text = generateRandomSizeString(10000);
  strcat(message, name);
  strcat(message, email);
  strcat(message, password);
  strcat(message, text);
  snprintf(query, 11000, stat, tableName, name, email, password, text);
  if (mysql_query(connection, query)) {
    printf("I1R::Error %u: %s\n", mysql_errno(connection),
           mysql_error(connection));
  }
  free(message);
  free(name);
  free(email);
  free(password);
  free(text);
}


x86 assembly (clang, -O0):
<insertRandomRecord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2af8,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x2b18(%rbp)
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,-0x2b20(%rbp)
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,-0x2b28(%rbp)
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,-0x2b30(%rbp)
mov    $0x2710,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,-0x2b38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2b20(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2b28(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2b30(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2b38(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x2b10(%rbp),%rdi
mov    -0x2b18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x2b20(%rbp),%r8
mov    -0x2b28(%rbp),%r9
mov    -0x2b30(%rbp),%r10
mov    -0x2b38(%rbp),%rax
mov    $0x2af8,%esi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x2b10(%rbp),%rsi
call   1040 <mysql_query@plt>
cmp    $0x0,%rax
je     12d0 <insertRandomRecord+0x140>
mov    -0x8(%rbp),%rdi
call   1080 <mysql_errno@plt>
mov    %eax,-0x2b3c(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <mysql_error@plt>
mov    -0x2b3c(%rbp),%esi
mov    %rax,%rdx
lea    0xd8f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2b20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2b28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2b30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2b38(%rbp),%rdi
call   1030 <free@plt>
add    $0x2b50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertRandomRecord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2b08,%rsp
mov    %rsi,(%rsp)
mov    %rdi,0x8(%rsp)
mov    $0x2af8,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r13
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,%rbp
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,%rbx
mov    $0x64,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,%r15
mov    $0x2710,%edi
call   10b0 <generateRandomSizeString@plt>
mov    %rax,%r14
mov    %r13,%rdi
mov    %rbp,%rsi
call   10a0 <strcat@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   10a0 <strcat@plt>
lea    0xddd(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x2af8,%esi
mov    (%rsp),%rcx
mov    %rbp,%r8
mov    %rbx,(%rsp)
mov    %rbx,%r9
mov    %r15,%rbx
push   %r14
push   %r15
call   1060 <snprintf@plt>
add    $0x10,%rsp
mov    0x8(%rsp),%rdi
mov    %rdi,%r15
mov    %r12,%rsi
call   1040 <mysql_query@plt>
test   %rax,%rax
je     128c <insertRandomRecord+0xfc>
mov    %r15,%rdi
call   1080 <mysql_errno@plt>
mov    %rbp,%r12
mov    %eax,%ebp
mov    %r15,%rdi
call   1090 <mysql_error@plt>
lea    0xddb(%rip),%rdi
mov    %ebp,%esi
mov    %r12,%rbp
mov    %rax,%rdx
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x2b08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [90 x i8] c"INSERT INTO benchmark.%s (name, email, password, text ) VALUES ('%s', '%s', '%s', '%s' );\00"
@.str.1 = [19 x i8] c"I1R::Error %u: %s\0A\00"
define void @insertRandomRecord(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [11000 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%12 = call i8* @calloc(i32 11000, i32 1)
store i8* %12, i8** %5
store i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0), i8** %7
%13 = call i8* @generateRandomSizeString(i32 100)
store i8* %13, i8** %8
%14 = call i8* @generateRandomSizeString(i32 100)
store i8* %14, i8** %9
%15 = call i8* @generateRandomSizeString(i32 100)
store i8* %15, i8** %10
%16 = call i8* @generateRandomSizeString(i32 10000)
store i8* %16, i8** %11
%17 = load i8*, i8** %5
%18 = load i8*, i8** %8
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = load i8*, i8** %5
%21 = load i8*, i8** %9
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = load i8*, i8** %5
%24 = load i8*, i8** %10
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = load i8*, i8** %11
%28 = call i32 @strcat(i8* %26, i8* %27)
%29 = getelementptr inbounds [11000 x i8], [11000 x i8]* %6, i64 0, i64 0
%30 = load i8*, i8** %7
%31 = load i8*, i8** %4
%32 = load i8*, i8** %8
%33 = load i8*, i8** %9
%34 = load i8*, i8** %10
%35 = load i8*, i8** %11
%36 = call i32 @snprintf(i8* %29, i32 11000, i8* %30, i8* %31, i8* %32, i8* %33, i8* %34, i8* %35)
%37 = load i32*, i32** %3
%38 = getelementptr inbounds [11000 x i8], [11000 x i8]* %6, i64 0, i64 0
%39 = call i64 @mysql_query(i32* %37, i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %2
%42 = load i32*, i32** %3
%43 = call i32 @mysql_errno(i32* %42)
%44 = load i32*, i32** %3
%45 = call i8* @mysql_error(i32* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %43, i8* %45)
br label %47
47: ; preds = %41, %2
%48 = load i8*, i8** %5
%49 = call i32 @free(i8* %48)
%50 = load i8*, i8** %8
%51 = call i32 @free(i8* %50)
%52 = load i8*, i8** %9
%53 = call i32 @free(i8* %52)
%54 = load i8*, i8** %10
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %11
%57 = call i32 @free(i8* %56)
ret void
}

LLVM IR (-O2):
@.str = [90 x i8] c"INSERT INTO benchmark.%s (name, email, password, text ) VALUES ('%s', '%s', '%s', '%s' );\00"
@.str.1 = [19 x i8] c"I1R::Error %u: %s\0A\00"
define void @insertRandomRecord(i32* %0, i8* %1) {
%3 = alloca [11000 x i8]
%4 = tail call dereferenceable_or_null(11000) i8* @calloc(i32 11000, i32 1)
%5 = getelementptr inbounds [11000 x i8], [11000 x i8]* %3, i64 0, i64 0
%6 = tail call i8* @generateRandomSizeString(i32 100)
%7 = tail call i8* @generateRandomSizeString(i32 100)
%8 = tail call i8* @generateRandomSizeString(i32 100)
%9 = tail call i8* @generateRandomSizeString(i32 10000)
%10 = tail call i32 @strcat(i8* %4, i8* %6)
%11 = tail call i32 @strcat(i8* %4, i8* %7)
%12 = tail call i32 @strcat(i8* %4, i8* %8)
%13 = tail call i32 @strcat(i8* %4, i8* %9)
%14 = call i32 @snprintf(i8* %5, i32 11000, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %6, i8* %7, i8* %8, i8* %9)
%15 = call i64 @mysql_query(i32* %0, i8* %5)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = call i32 @mysql_errno(i32* %0)
%19 = call i8* @mysql_error(i32* %0)
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %19)
br label %21
21: ; preds = %17, %2
%22 = call i32 @free(i8* %4)
%23 = call i32 @free(i8* %6)
%24 = call i32 @free(i8* %7)
%25 = call i32 @free(i8* %8)
%26 = call i32 @free(i8* %9)
ret void
}