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

/* Variables and functions */
int SQLITE_OK;
scalar_t__ SQLITE_ROW;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_int(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
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 sqlite3_prepare(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                    int /*<<< orphan*/ *);
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  sqlite3 *db;
  char *errMsg = 0;
  int rc;
  sqlite3_stmt *result;
  rc = sqlite3_open("BDPrueba.sqlite", &db);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "No se puede acceder a la base de datos: %s.\n",
            sqlite3_errmsg(db));
    sqlite3_close(db);
    return (1);
  }
  rc = sqlite3_exec(db, "DROP TABLE IF EXISTS Empresa", NULL, NULL, &errMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Error al borrar la tabla: %s.\n", errMsg);
    sqlite3_free(errMsg);
    sqlite3_close(db);
    return (2);
  }
  rc = sqlite3_exec(
      db,
      "CREATE TABLE Empresa (IdEmpresa INTEGER PRIMARY KEY, Nombre CHAR[250])",
      NULL, NULL, &errMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Error al crear la tabla: %s.\n", errMsg);
    sqlite3_free(errMsg);
    sqlite3_close(db);
    return (2);
  }
  rc = sqlite3_exec(db, "INSERT INTO Empresa VALUES( 1, 'Empresa A')", NULL,
                    NULL, &errMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Error al crear el primer registro: %s.\n", errMsg);
    sqlite3_free(errMsg);
    sqlite3_close(db);
    return (2);
  }
  rc = sqlite3_exec(db, "INSERT INTO Empresa VALUES( 2, 'Empresa B')", NULL,
                    NULL, &errMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Error al crear el segundo registro: %s.\n", errMsg);
    sqlite3_free(errMsg);
    sqlite3_close(db);
    return (2);
  }
  rc = sqlite3_prepare(db, "SELECT idEmpresa,Nombre FROM Empresa", -1, &result,
                       NULL);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Error en la consulta: %s.\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return (3);
  }
  while (sqlite3_step(result) == SQLITE_ROW) {
    fprintf(stderr, "El Id y nombre de la empresa son:  %i - %s.\n",
            sqlite3_column_int(result, 0), sqlite3_column_text(result, 1));
  }
  sqlite3_close(db);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe3b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e0d(%rip),%rcx
cmp    (%rcx),%eax
je     1221 <main+0x81>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <sqlite3_errmsg@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14a8 <main+0x308>
mov    -0x18(%rbp),%rdi
lea    0xe11(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d9f(%rip),%rcx
cmp    (%rcx),%eax
je     128a <main+0xea>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <sqlite3_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x2,-0x4(%rbp)
jmp    14a8 <main+0x308>
mov    -0x18(%rbp),%rdi
lea    0xde4(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d36(%rip),%rcx
cmp    (%rcx),%eax
je     12f3 <main+0x153>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <sqlite3_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x2,-0x4(%rbp)
jmp    14a8 <main+0x308>
mov    -0x18(%rbp),%rdi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2ccd(%rip),%rcx
cmp    (%rcx),%eax
je     135c <main+0x1bc>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <sqlite3_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x2,-0x4(%rbp)
jmp    14a8 <main+0x308>
mov    -0x18(%rbp),%rdi
lea    0xdcb(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2c64(%rip),%rcx
cmp    (%rcx),%eax
je     13c5 <main+0x225>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <sqlite3_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x2,-0x4(%rbp)
jmp    14a8 <main+0x308>
mov    -0x18(%rbp),%rdi
lea    0xdb7(%rip),%rsi
mov    $0xffffffff,%edx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10b0 <sqlite3_prepare@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2bf8(%rip),%rcx
cmp    (%rcx),%eax
je     1436 <main+0x296>
mov    0x2bd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <sqlite3_errmsg@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x3,-0x4(%rbp)
jmp    14a8 <main+0x308>
jmp    143b <main+0x29b>
mov    -0x30(%rbp),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2b85(%rip),%rcx
cmp    (%rcx),%rax
jne    1498 <main+0x2f8>
mov    0x2b7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1050 <sqlite3_column_int@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%edx
mov    %rax,%rcx
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    143b <main+0x29b>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
lea    0xe43(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <sqlite3_open@plt>
mov    0x2e1a(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    12fa <main+0x15a>
mov    0x8(%rsp),%rdi
lea    0xe5a(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%eax
jne    1327 <main+0x187>
mov    0x8(%rsp),%rdi
lea    0xe75(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%eax
jne    133d <main+0x19d>
mov    0x8(%rsp),%rdi
lea    0xeb9(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%eax
jne    1353 <main+0x1b3>
mov    0x8(%rsp),%rdi
lea    0xeec(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%eax
jne    1369 <main+0x1c9>
mov    0x8(%rsp),%rdi
lea    0xf20(%rip),%rsi
xor    %ebx,%ebx
lea    0x10(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10b0 <sqlite3_prepare@plt>
cmp    0x0(%rbp),%eax
jne    13ad <main+0x20d>
mov    0x10(%rsp),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2d3b(%rip),%r12
cmp    (%r12),%rax
jne    1392 <main+0x1f2>
mov    0x2d32(%rip),%r13
lea    0xf1a(%rip),%r14
nopl   (%rax)
mov    0x0(%r13),%r15d
mov    0x10(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <sqlite3_column_int@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   1070 <sqlite3_step@plt>
cmp    (%r12),%rax
je     12b0 <main+0x110>
jmp    1392 <main+0x1f2>
mov    0x2cd7(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_errmsg@plt>
lea    0xcfc(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    1392 <main+0x1f2>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xd1f(%rip),%rsi
jmp    137d <main+0x1dd>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xd6f(%rip),%rsi
jmp    137d <main+0x1dd>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xda3(%rip),%rsi
jmp    137d <main+0x1dd>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xde1(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rsp),%rdi
call   10c0 <sqlite3_free@plt>
mov    $0x2,%ebx
mov    0x8(%rsp),%rdi
call   1090 <sqlite3_close@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c24(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_errmsg@plt>
lea    0xde5(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x3,%ebx
jmp    1392 <main+0x1f2>

LLVM IR (-O0):
@.str = [16 x i8] c"BDPrueba.sqlite\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [45 x i8] c"No se puede acceder a la base de datos: %s.\0A\00"
@.str.2 = [29 x i8] c"DROP TABLE IF EXISTS Empresa\00"
@.str.3 = [31 x i8] c"Error al borrar la tabla: %s.\0A\00"
@.str.4 = [71 x i8] c"CREATE TABLE Empresa (IdEmpresa INTEGER PRIMARY KEY, Nombre CHAR[250])\00"
@.str.5 = [30 x i8] c"Error al crear la tabla: %s.\0A\00"
@.str.6 = [44 x i8] c"INSERT INTO Empresa VALUES( 1, 'Empresa A')\00"
@.str.7 = [40 x i8] c"Error al crear el primer registro: %s.\0A\00"
@.str.8 = [44 x i8] c"INSERT INTO Empresa VALUES( 2, 'Empresa B')\00"
@.str.9 = [41 x i8] c"Error al crear el segundo registro: %s.\0A\00"
@.str.10 = [37 x i8] c"SELECT idEmpresa,Nombre FROM Empresa\00"
@.str.11 = [27 x i8] c"Error en la consulta: %s.\0A\00"
@SQLITE_ROW = global i64 0
@.str.12 = [45 x i8] c"El Id y nombre de la empresa son: %i - %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%10 = call i32 @sqlite3_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32** %6)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = load i32, i32* @SQLITE_OK
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32*, i32** %6
%17 = call i8* @sqlite3_errmsg(i32* %16)
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32*, i32** %6
%20 = call i32 @sqlite3_close(i32* %19)
store i32 1, i32* %3
br label %106
21: ; preds = %2
%22 = load i32*, i32** %6
%23 = call i32 @sqlite3_exec(i32* %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null, i8** %7)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = load i32, i32* @SQLITE_OK
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %7
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %7
%32 = call i32 @sqlite3_free(i8* %31)
%33 = load i32*, i32** %6
%34 = call i32 @sqlite3_close(i32* %33)
store i32 2, i32* %3
br label %106
35: ; preds = %21
%36 = load i32*, i32** %6
%37 = call i32 @sqlite3_exec(i32* %36, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null, i8** %7)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = load i32, i32* @SQLITE_OK
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %49
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %7
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @sqlite3_free(i8* %45)
%47 = load i32*, i32** %6
%48 = call i32 @sqlite3_close(i32* %47)
store i32 2, i32* %3
br label %106
49: ; preds = %35
%50 = load i32*, i32** %6
%51 = call i32 @sqlite3_exec(i32* %50, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32* null, i32* null, i8** %7)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = load i32, i32* @SQLITE_OK
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %63
55: ; preds = %49
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %7
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %57)
%59 = load i8*, i8** %7
%60 = call i32 @sqlite3_free(i8* %59)
%61 = load i32*, i32** %6
%62 = call i32 @sqlite3_close(i32* %61)
store i32 2, i32* %3
br label %106
63: ; preds = %49
%64 = load i32*, i32** %6
%65 = call i32 @sqlite3_exec(i32* %64, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null, i8** %7)
store i32 %65, i32* %8
%66 = load i32, i32* %8
%67 = load i32, i32* @SQLITE_OK
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %77
69: ; preds = %63
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %7
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** %7
%74 = call i32 @sqlite3_free(i8* %73)
%75 = load i32*, i32** %6
%76 = call i32 @sqlite3_close(i32* %75)
store i32 2, i32* %3
br label %106
77: ; preds = %63
%78 = load i32*, i32** %6
%79 = call i32 @sqlite3_prepare(i32* %78, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32 -1, i32** %9, i32* null)
store i32 %79, i32* %8
%80 = load i32, i32* %8
%81 = load i32, i32* @SQLITE_OK
%82 = icmp ne i32 %80, %81
br i1 %82, label %83, label %90
83: ; preds = %77
%84 = load i32, i32* @stderr
%85 = load i32*, i32** %6
%86 = call i8* @sqlite3_errmsg(i32* %85)
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %86)
%88 = load i32*, i32** %6
%89 = call i32 @sqlite3_close(i32* %88)
store i32 3, i32* %3
br label %106
90: ; preds = %77
br label %91
91: ; preds = %96, %90
%92 = load i32*, i32** %9
%93 = call i64 @sqlite3_step(i32* %92)
%94 = load i64, i64* @SQLITE_ROW
%95 = icmp eq i64 %93, %94
br i1 %95, label %96, label %103
96: ; preds = %91
%97 = load i32, i32* @stderr
%98 = load i32*, i32** %9
%99 = call i32 @sqlite3_column_int(i32* %98, i32 0)
%100 = load i32*, i32** %9
%101 = call i8* @sqlite3_column_text(i32* %100, i32 1)
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i32 %99, i8* %101)
br label %91
103: ; preds = %91
%104 = load i32*, i32** %6
%105 = call i32 @sqlite3_close(i32* %104)
store i32 0, i32* %3
br label %106
106: ; preds = %103, %83, %69, %55, %41, %27, %14
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@.str = [16 x i8] c"BDPrueba.sqlite\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [45 x i8] c"No se puede acceder a la base de datos: %s.\0A\00"
@.str.2 = [29 x i8] c"DROP TABLE IF EXISTS Empresa\00"
@.str.3 = [31 x i8] c"Error al borrar la tabla: %s.\0A\00"
@.str.4 = [71 x i8] c"CREATE TABLE Empresa (IdEmpresa INTEGER PRIMARY KEY, Nombre CHAR[250])\00"
@.str.5 = [30 x i8] c"Error al crear la tabla: %s.\0A\00"
@.str.6 = [44 x i8] c"INSERT INTO Empresa VALUES( 1, 'Empresa A')\00"
@.str.7 = [40 x i8] c"Error al crear el primer registro: %s.\0A\00"
@.str.8 = [44 x i8] c"INSERT INTO Empresa VALUES( 2, 'Empresa B')\00"
@.str.9 = [41 x i8] c"Error al crear el segundo registro: %s.\0A\00"
@.str.10 = [37 x i8] c"SELECT idEmpresa,Nombre FROM Empresa\00"
@.str.11 = [27 x i8] c"Error en la consulta: %s.\0A\00"
@SQLITE_ROW = global i64 0
@.str.12 = [45 x i8] c"El Id y nombre de la empresa son: %i - %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = bitcast i32** %3 to i8*
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i32** %5 to i8*
%9 = call i32 @sqlite3_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32** %3)
%10 = load i32, i32* @SQLITE_OK
%11 = icmp eq i32 %9, %10
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32*, i32** %3
%15 = call i8* @sqlite3_errmsg(i32* %14)
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %87
17: ; preds = %2
%18 = load i32*, i32** %3
%19 = call i32 @sqlite3_exec(i32* %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null, i8** %4)
%20 = load i32, i32* @SQLITE_OK
%21 = icmp eq i32 %19, %20
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %4
%27 = call i32 @sqlite3_free(i8* %26)
br label %87
28: ; preds = %17
%29 = load i32*, i32** %3
%30 = call i32 @sqlite3_exec(i32* %29, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null, i8** %4)
%31 = load i32, i32* @SQLITE_OK
%32 = icmp eq i32 %30, %31
br i1 %32, label %39, label %33
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %4
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %4
%38 = call i32 @sqlite3_free(i8* %37)
br label %87
39: ; preds = %28
%40 = load i32*, i32** %3
%41 = call i32 @sqlite3_exec(i32* %40, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32* null, i32* null, i8** %4)
%42 = load i32, i32* @SQLITE_OK
%43 = icmp eq i32 %41, %42
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %4
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %4
%49 = call i32 @sqlite3_free(i8* %48)
br label %87
50: ; preds = %39
%51 = load i32*, i32** %3
%52 = call i32 @sqlite3_exec(i32* %51, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null, i8** %4)
%53 = load i32, i32* @SQLITE_OK
%54 = icmp eq i32 %52, %53
br i1 %54, label %61, label %55
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %4
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %57)
%59 = load i8*, i8** %4
%60 = call i32 @sqlite3_free(i8* %59)
br label %87
61: ; preds = %50
%62 = load i32*, i32** %3
%63 = call i32 @sqlite3_prepare(i32* %62, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32 -1, i32** %5, i32* null)
%64 = load i32, i32* @SQLITE_OK
%65 = icmp eq i32 %63, %64
br i1 %65, label %66, label %71
66: ; preds = %61
%67 = load i32*, i32** %5
%68 = call i64 @sqlite3_step(i32* %67)
%69 = load i64, i64* @SQLITE_ROW
%70 = icmp eq i64 %68, %69
br i1 %70, label %76, label %87
71: ; preds = %61
%72 = load i32, i32* @stderr
%73 = load i32*, i32** %3
%74 = call i8* @sqlite3_errmsg(i32* %73)
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %74)
br label %87
76: ; preds = %66, %76
%77 = load i32, i32* @stderr
%78 = load i32*, i32** %5
%79 = call i32 @sqlite3_column_int(i32* %78, i32 0)
%80 = load i32*, i32** %5
%81 = call i8* @sqlite3_column_text(i32* %80, i32 1)
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i32 %79, i8* %81)
%83 = load i32*, i32** %5
%84 = call i64 @sqlite3_step(i32* %83)
%85 = load i64, i64* @SQLITE_ROW
%86 = icmp eq i64 %84, %85
br i1 %86, label %76, label %87
87: ; preds = %76, %66, %71, %55, %44, %33, %22, %12
%88 = phi i32 [ 1, %12 ], [ 2, %22 ], [ 2, %33 ], [ 2, %44 ], [ 2, %55 ], [ 3, %71 ], [ 0, %66 ], [ 0, %76 ]
%89 = load i32*, i32** %3
%90 = call i32 @sqlite3_close(i32* %89)
ret i32 %88
}