#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;

/* Variables and functions */
int SQLITE_OK;
int /*<<< orphan*/ create_db();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/, char **);
int /*<<< orphan*/ sqlite3_free(char *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int insert(char *name, char *image) {
  create_db();
  char *sql = NULL;
  sqlite3 *db = NULL;
  int rc;
  char *zErrMsg = 0;
  rc = sqlite3_open("DataBase_facificator.db", &db);
  if (rc) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
  } else {
    fprintf(stderr, "Opened database successfully\n");
  }
  sql = "INSERT INTO FACIFICATOR (NAME, PICTURE) VALUES ('";
  char *result = malloc(strlen(sql) + strlen(name) + 1);
  strcpy(result, sql);
  strcat(result, name);
  sql = result;
  char *chaine_tmp = "', '";
  result = malloc(strlen(sql) + strlen(chaine_tmp) + 1);
  strcpy(result, sql);
  strcat(result, chaine_tmp);
  sql = result;
  result = malloc(strlen(sql) + strlen(image) + 1);
  strcpy(result, sql);
  strcat(result, image);
  sql = result;
  chaine_tmp = "');";
  result = malloc(strlen(sql) + strlen(chaine_tmp) + 1);
  strcpy(result, sql);
  strcat(result, chaine_tmp);
  sql = result;
  printf("%s\n", sql);
  rc = sqlite3_exec(db, sql, NULL, 0, &zErrMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
    sqlite3_free(zErrMsg);
  } else {
    fprintf(stdout, "Successfull insert\n\n");
  }
  sqlite3_close(db);
  return 0;
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <create_db@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe0a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <sqlite3_open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     123a <insert+0x7a>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1251 <insert+0x91>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xdf7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xdd2(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x58(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xd34(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xc80(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
lea    -0x30(%rbp),%r8
call   1040 <sqlite3_exec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2c12(%rip),%rcx
cmp    (%rcx),%eax
je     1407 <insert+0x247>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xc98(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <sqlite3_free@plt>
jmp    141e <insert+0x25e>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xc82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   10b0 <create_db@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe10(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <sqlite3_open@plt>
mov    0x2dd7(%rip),%r15
mov    (%r15),%ebp
test   %eax,%eax
je     1227 <insert+0x67>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xdff(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1237 <insert+0x77>
lea    0xe03(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x32(%rax),%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
lea    0xdfd(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x5(%rax),%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x4(%rax),%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xd94(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd2c(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%r8
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <sqlite3_exec@plt>
mov    0x2cc2(%rip),%rcx
cmp    (%rcx),%eax
jne    1343 <insert+0x183>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
lea    0xd5f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1363 <insert+0x1a3>
mov    (%r15),%edi
mov    0x10(%rsp),%rdx
lea    0xd38(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   10e0 <sqlite3_free@plt>
mov    0x8(%rsp),%rdi
call   10a0 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"DataBase_facificator.db\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.2 = [30 x i8] c"Opened database successfully\0A\00"
@.str.3 = [50 x i8] c"INSERT INTO FACIFICATOR (NAME, PICTURE) VALUES ('\00"
@.str.4 = [5 x i8] c"', '\00"
@.str.5 = [4 x i8] c"');\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@SQLITE_OK = global i32 0
@.str.7 = [15 x i8] c"SQL error: %s\0A\00"
@stdout = global i32 0
@.str.8 = [21 x i8] c"Successfull insert\0A\0A\00"
define i32 @insert(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = call i32 (...) @create_db()
store i8* null, i8** %5
store i32* null, i32** %6
store i8* null, i8** %8
%12 = call i32 @sqlite3_open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32** %6)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i32*, i32** %6
%18 = call i8* @sqlite3_errmsg(i32* %17)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %23
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20, %15
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8** %5
%24 = load i8*, i8** %5
%25 = call i64 @strlen(i8* %24)
%26 = load i8*, i8** %3
%27 = call i64 @strlen(i8* %26)
%28 = add nsw i64 %25, %27
%29 = add nsw i64 %28, 1
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = load i8*, i8** %9
%35 = load i8*, i8** %3
%36 = call i32 @strcat(i8* %34, i8* %35)
%37 = load i8*, i8** %9
store i8* %37, i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %10
%38 = load i8*, i8** %5
%39 = call i64 @strlen(i8* %38)
%40 = load i8*, i8** %10
%41 = call i64 @strlen(i8* %40)
%42 = add nsw i64 %39, %41
%43 = add nsw i64 %42, 1
%44 = call i8* @malloc(i64 %43)
store i8* %44, i8** %9
%45 = load i8*, i8** %9
%46 = load i8*, i8** %5
%47 = call i32 @strcpy(i8* %45, i8* %46)
%48 = load i8*, i8** %9
%49 = load i8*, i8** %10
%50 = call i32 @strcat(i8* %48, i8* %49)
%51 = load i8*, i8** %9
store i8* %51, i8** %5
%52 = load i8*, i8** %5
%53 = call i64 @strlen(i8* %52)
%54 = load i8*, i8** %4
%55 = call i64 @strlen(i8* %54)
%56 = add nsw i64 %53, %55
%57 = add nsw i64 %56, 1
%58 = call i8* @malloc(i64 %57)
store i8* %58, i8** %9
%59 = load i8*, i8** %9
%60 = load i8*, i8** %5
%61 = call i32 @strcpy(i8* %59, i8* %60)
%62 = load i8*, i8** %9
%63 = load i8*, i8** %4
%64 = call i32 @strcat(i8* %62, i8* %63)
%65 = load i8*, i8** %9
store i8* %65, i8** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %10
%66 = load i8*, i8** %5
%67 = call i64 @strlen(i8* %66)
%68 = load i8*, i8** %10
%69 = call i64 @strlen(i8* %68)
%70 = add nsw i64 %67, %69
%71 = add nsw i64 %70, 1
%72 = call i8* @malloc(i64 %71)
store i8* %72, i8** %9
%73 = load i8*, i8** %9
%74 = load i8*, i8** %5
%75 = call i32 @strcpy(i8* %73, i8* %74)
%76 = load i8*, i8** %9
%77 = load i8*, i8** %10
%78 = call i32 @strcat(i8* %76, i8* %77)
%79 = load i8*, i8** %9
store i8* %79, i8** %5
%80 = load i8*, i8** %5
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %80)
%82 = load i32*, i32** %6
%83 = load i8*, i8** %5
%84 = call i32 @sqlite3_exec(i32* %82, i8* %83, i32* null, i32 0, i8** %8)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = load i32, i32* @SQLITE_OK
%87 = icmp ne i32 %85, %86
br i1 %87, label %88, label %94
88: ; preds = %23
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %8
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %90)
%92 = load i8*, i8** %8
%93 = call i32 @sqlite3_free(i8* %92)
br label %97
94: ; preds = %23
%95 = load i32, i32* @stdout
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %97
97: ; preds = %94, %88
%98 = load i32*, i32** %6
%99 = call i32 @sqlite3_close(i32* %98)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"DataBase_facificator.db\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.2 = [30 x i8] c"Opened database successfully\0A\00"
@.str.3 = [50 x i8] c"INSERT INTO FACIFICATOR (NAME, PICTURE) VALUES ('\00"
@.str.4 = [5 x i8] c"', '\00"
@.str.5 = [4 x i8] c"');\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@SQLITE_OK = global i32 0
@.str.7 = [15 x i8] c"SQL error: %s\0A\00"
@stdout = global i32 0
@.str.8 = [21 x i8] c"Successfull insert\0A\0A\00"
define i32 @insert(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = tail call i32 (...) @create_db()
%6 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = call i32 @sqlite3_open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32** %3)
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @stderr
br i1 %9, label %15, label %11
11: ; preds = %2
%12 = load i32*, i32** %3
%13 = call i8* @sqlite3_errmsg(i32* %12)
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %2
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = call i64 @strlen(i8* dereferenceable(1) %0)
%19 = add nsw i64 %18, 50
%20 = call i8* @malloc(i64 %19)
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @strcat(i8* %20, i8* %0)
%23 = call i64 @strlen(i8* dereferenceable(1) %20)
%24 = add nsw i64 %23, 5
%25 = call i8* @malloc(i64 %24)
%26 = call i32 @strcpy(i8* %25, i8* %20)
%27 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%28 = call i64 @strlen(i8* dereferenceable(1) %25)
%29 = call i64 @strlen(i8* dereferenceable(1) %1)
%30 = add i64 %28, 1
%31 = add i64 %30, %29
%32 = call i8* @malloc(i64 %31)
%33 = call i32 @strcpy(i8* %32, i8* %25)
%34 = call i32 @strcat(i8* %32, i8* %1)
%35 = call i64 @strlen(i8* dereferenceable(1) %32)
%36 = add nsw i64 %35, 4
%37 = call i8* @malloc(i64 %36)
%38 = call i32 @strcpy(i8* %37, i8* %32)
%39 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%41 = load i32*, i32** %3
%42 = call i32 @sqlite3_exec(i32* %41, i8* %37, i32* null, i32 0, i8** %4)
%43 = load i32, i32* @SQLITE_OK
%44 = icmp eq i32 %42, %43
br i1 %44, label %51, label %45
45: ; preds = %17
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %4
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %4
%50 = call i32 @sqlite3_free(i8* %49)
br label %54
51: ; preds = %17
%52 = load i32, i32* @stdout
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %54
54: ; preds = %51, %45
%55 = load i32*, i32** %3
%56 = call i32 @sqlite3_close(i32* %55)
ret i32 0
}