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

/* Variables and functions */
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
long sqlite3_column_int(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ sqlite3_prepare(int /*<<< orphan*/ *, char *, int,
                                   int /*<<< orphan*/ **, int /*<<< orphan*/);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int traffic_mv() {
  sqlite3 *db;
  char sql[256];
  int rc = 0;
  long data = 0;
  char *errmsg;
  sqlite3_stmt *ppstmt = NULL;
  rc = sqlite3_open("./traffic.db", &db);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Cannot open traffic.db:%s\n", sqlite3_errmsg(db));
    return 0;
  }
  memset(sql, 0, sizeof(sql));
  sprintf(sql, "select count(*) from traffic_info");
  sqlite3_prepare(db, sql, -1, &ppstmt, 0);
  rc = sqlite3_step(ppstmt);
  if (rc == SQLITE_ROW) {
    data = sqlite3_column_int(ppstmt, 0);
    printf("number in traffic.db : %ld\n", data);
  }
  sqlite3_finalize(ppstmt);
  data = 200;
  memset(sql, 0, sizeof(sql));
  sprintf(sql,
          "delete from traffic_info where time in (select time from "
          "traffic_info order by time asc limit 0, %ld)",
          data);
  rc = sqlite3_exec(db, sql, NULL, NULL, &errmsg);
  if (SQLITE_OK == rc) {
    printf("delete traffic.db success!\n");
  } else if (rc != SQLITE_OK) {
    printf("delete traffic.db error:%s\n", errmsg);
  }
  memset(sql, 0, sizeof(sql));
  sprintf(sql, "vacuum traffic_info");
  rc = sqlite3_exec(db, sql, NULL, NULL, &errmsg);
  if (SQLITE_OK == rc) {
    printf("vacuum traffic.db success!\n");
  } else if (rc != SQLITE_OK) {
    printf("vacuum traffic.db error:%s\n", errmsg);
  }
  sqlite3_close(db);
  return 1;
}


x86 assembly (clang, -O0):
<traffic_mv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x114(%rbp)
movq   $0x0,-0x120(%rbp)
movq   $0x0,-0x130(%rbp)
lea    0xe0e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%eax
je     124f <traffic_mv+0x8f>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    -0x134(%rbp),%edi
mov    %rax,%rdx
lea    0xdcf(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    145b <traffic_mv+0x29b>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x130(%rbp),%rcx
xor    %r8d,%r8d
call   10c0 <sqlite3_prepare@plt>
mov    -0x130(%rbp),%rdi
call   1090 <sqlite3_step@plt>
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    0x2d1b(%rip),%rcx
cmp    (%rcx),%eax
jne    12e7 <traffic_mv+0x127>
mov    -0x130(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rsi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x130(%rbp),%rdi
call   10d0 <sqlite3_finalize@plt>
movq   $0xc8,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rdx
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x128(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x114(%rbp)
mov    0x2c90(%rip),%rax
mov    (%rax),%eax
cmp    -0x114(%rbp),%eax
jne    1379 <traffic_mv+0x1b9>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13a8 <traffic_mv+0x1e8>
mov    -0x114(%rbp),%eax
mov    0x2c62(%rip),%rcx
cmp    (%rcx),%eax
je     13a3 <traffic_mv+0x1e3>
mov    -0x128(%rbp),%rsi
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13a8 <traffic_mv+0x1e8>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x128(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x114(%rbp)
mov    0x2bed(%rip),%rax
mov    (%rax),%eax
cmp    -0x114(%rbp),%eax
jne    141c <traffic_mv+0x25c>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    144b <traffic_mv+0x28b>
mov    -0x114(%rbp),%eax
mov    0x2bbf(%rip),%rcx
cmp    (%rcx),%eax
je     1446 <traffic_mv+0x286>
mov    -0x128(%rbp),%rsi
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    144b <traffic_mv+0x28b>
mov    -0x10(%rbp),%rdi
call   10b0 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<traffic_mv>:
push   %r14
push   %rbx
sub    $0x128,%rsp
movq   $0x0,0x10(%rsp)
lea    0xe16(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <sqlite3_open@plt>
mov    0x2ded(%rip),%r14
cmp    (%r14),%eax
jne    12e0 <traffic_mv+0x110>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
movups 0xe09(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe0d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movw   $0x6f,0x40(%rsp)
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rcx
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10d0 <sqlite3_prepare@plt>
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_step@plt>
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%eax
jne    1283 <traffic_mv+0xb3>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
call   1080 <sqlite3_column_int@plt>
lea    0xdd1(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%rdi
call   10e0 <sqlite3_finalize@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    0xdbe(%rip),%rsi
mov    $0xc8,%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    0x8(%rsp),%rdi
lea    0x18(%rsp),%r8
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <sqlite3_exec@plt>
cmp    %eax,(%r14)
jne    130b <traffic_mv+0x13b>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
jmp    131e <traffic_mv+0x14e>
mov    0x2cf1(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1090 <sqlite3_errmsg@plt>
lea    0xd13(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10b0 <fprintf@plt>
xor    %eax,%eax
jmp    1391 <traffic_mv+0x1c1>
mov    0x18(%rsp),%rsi
lea    0xdb5(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
movups 0xdaf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x6f666e,0x30(%rsp)
mov    0x8(%rsp),%rdi
lea    0x18(%rsp),%r8
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <sqlite3_exec@plt>
cmp    %eax,(%r14)
jne    136f <traffic_mv+0x19f>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
jmp    1382 <traffic_mv+0x1b2>
mov    0x18(%rsp),%rsi
lea    0xd81(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   10c0 <sqlite3_close@plt>
mov    $0x1,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"./traffic.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"Cannot open traffic.db:%s\0A\00"
@.str.2 = [34 x i8] c"select count(*) from traffic_info\00"
@SQLITE_ROW = global i32 0
@.str.3 = [28 x i8] c"number in traffic.db : %ld\0A\00"
@.str.4 = [102 x i8] c"delete from traffic_info where time in (select time from traffic_info order by time asc limit 0, %ld)\00"
@.str.5 = [28 x i8] c"delete traffic.db success!\0A\00"
@.str.6 = [28 x i8] c"delete traffic.db error:%s\0A\00"
@.str.7 = [20 x i8] c"vacuum traffic_info\00"
@.str.8 = [28 x i8] c"vacuum traffic.db success!\0A\00"
@.str.9 = [28 x i8] c"vacuum traffic.db error:%s\0A\00"
define i32 @traffic_mv() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32*
store i32 0, i32* %4
store i64 0, i64* %5
store i32* null, i32** %7
%8 = call i32 @sqlite3_open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %2)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = load i32, i32* @SQLITE_OK
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = load i32*, i32** %2
%15 = call i8* @sqlite3_errmsg(i32* %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 0, i32* %1
br label %83
17: ; preds = %0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 256)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %2
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = call i32 @sqlite3_prepare(i32* %22, i8* %23, i32 -1, i32** %7, i32 0)
%25 = load i32*, i32** %7
%26 = call i32 @sqlite3_step(i32* %25)
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = load i32, i32* @SQLITE_ROW
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %17
%31 = load i32*, i32** %7
%32 = call i64 @sqlite3_column_int(i32* %31, i32 0)
store i64 %32, i64* %5
%33 = load i64, i64* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i64 %33)
br label %35
35: ; preds = %30, %17
%36 = load i32*, i32** %7
%37 = call i32 @sqlite3_finalize(i32* %36)
store i64 200, i64* %5
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 256)
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%41 = load i64, i64* %5
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.4, i64 0, i64 0), i64 %41)
%43 = load i32*, i32** %2
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%45 = call i32 @sqlite3_exec(i32* %43, i8* %44, i32* null, i32* null, i8** %6)
store i32 %45, i32* %4
%46 = load i32, i32* @SQLITE_OK
%47 = load i32, i32* %4
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %35
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %59
51: ; preds = %35
%52 = load i32, i32* %4
%53 = load i32, i32* @SQLITE_OK
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i8*, i8** %6
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %55, %51
br label %59
59: ; preds = %58, %49
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%61 = call i32 @memset(i8* %60, i32 0, i32 256)
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%63 = call i32 (i8*, i8*, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%64 = load i32*, i32** %2
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%66 = call i32 @sqlite3_exec(i32* %64, i8* %65, i32* null, i32* null, i8** %6)
store i32 %66, i32* %4
%67 = load i32, i32* @SQLITE_OK
%68 = load i32, i32* %4
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %72
70: ; preds = %59
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %80
72: ; preds = %59
%73 = load i32, i32* %4
%74 = load i32, i32* @SQLITE_OK
%75 = icmp ne i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i8*, i8** %6
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %76, %72
br label %80
80: ; preds = %79, %70
%81 = load i32*, i32** %2
%82 = call i32 @sqlite3_close(i32* %81)
store i32 1, i32* %1
br label %83
83: ; preds = %80, %12
%84 = load i32, i32* %1
ret i32 %84
}

LLVM IR (-O2):
@.str = [13 x i8] c"./traffic.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"Cannot open traffic.db:%s\0A\00"
@.str.2 = [34 x i8] c"select count(*) from traffic_info\00"
@SQLITE_ROW = global i32 0
@.str.3 = [28 x i8] c"number in traffic.db : %ld\0A\00"
@.str.4 = [102 x i8] c"delete from traffic_info where time in (select time from traffic_info order by time asc limit 0, %ld)\00"
@.str.6 = [28 x i8] c"delete traffic.db error:%s\0A\00"
@.str.7 = [20 x i8] c"vacuum traffic_info\00"
@.str.9 = [28 x i8] c"vacuum traffic.db error:%s\0A\00"
@str = [27 x i8] c"vacuum traffic.db success!\00"
@str.10 = [27 x i8] c"delete traffic.db success!\00"
define i32 @traffic_mv() {
%1 = alloca i32*
%2 = alloca [256 x i8]
%3 = alloca i8*
%4 = alloca i32*
%5 = bitcast i32** %1 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = bitcast i8** %3 to i8*
%8 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%9 = call i32 @sqlite3_open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %1)
%10 = load i32, i32* @SQLITE_OK
%11 = icmp eq i32 %9, %10
br i1 %11, label %17, label %12
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = load i32*, i32** %1
%15 = call i8* @sqlite3_errmsg(i32* %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %57
17: ; preds = %0
%18 = call i32 @memset(i8* %6, i32 0, i32 256)
%19 = load i32*, i32** %1
%20 = call i32 @sqlite3_prepare(i32* %19, i8* %6, i32 -1, i32** %4, i32 0)
%21 = load i32*, i32** %4
%22 = call i32 @sqlite3_step(i32* %21)
%23 = load i32, i32* @SQLITE_ROW
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i32*, i32** %4
%27 = call i64 @sqlite3_column_int(i32* %26, i32 0)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i64 %27)
br label %29
29: ; preds = %25, %17
%30 = load i32*, i32** %4
%31 = call i32 @sqlite3_finalize(i32* %30)
%32 = call i32 @memset(i8* %6, i32 0, i32 256)
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([102 x i8], [102 x i8]* @.str.4, i64 0, i64 0), i64 200)
%34 = load i32*, i32** %1
%35 = call i32 @sqlite3_exec(i32* %34, i8* %6, i32* null, i32* null, i8** %3)
%36 = load i32, i32* @SQLITE_OK
%37 = icmp eq i32 %36, %35
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
br label %43
40: ; preds = %29
%41 = load i8*, i8** %3
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %38
%44 = call i32 @memset(i8* %6, i32 0, i32 256)
%45 = load i32*, i32** %1
%46 = call i32 @sqlite3_exec(i32* %45, i8* %6, i32* null, i32* null, i8** %3)
%47 = load i32, i32* @SQLITE_OK
%48 = icmp eq i32 %47, %46
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %54
51: ; preds = %43
%52 = load i8*, i8** %3
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %49
%55 = load i32*, i32** %1
%56 = call i32 @sqlite3_close(i32* %55)
br label %57
57: ; preds = %54, %12
%58 = phi i32 [ 0, %12 ], [ 1, %54 ]
ret i32 %58
}