#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ mysql_close(int /*<<< orphan*/ *);
char *mysql_error(int /*<<< orphan*/ *);
int /*<<< orphan*/ *mysql_init(int /*<<< orphan*/ *);
scalar_t__ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mysql_real_connect(int /*<<< orphan*/ *, char *, char *,
                                      char *, char *, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main() {
  MYSQL *conn;
  char server[] = "localhost";
  char username[] = "root";
  char password[] = "111111";
  char database[] = "listen_his_songs";
  conn = mysql_init(NULL);
  if (!mysql_real_connect(conn, server, username, password, database, 0, NULL,
                          0)) {
    fprintf(stderr, "%s\n", mysql_error(conn));
    exit(-1);
  }
  if (mysql_query(
          conn,
          "UPDATE user_song SET times_30d = (SELECT COUNT(*) FROM "
          "listened_song WHERE listened_song.usid = user_song.id AND "
          "DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= FROM_UNIXTIME(begin_time)), "
          "times_15d = (SELECT COUNT(*) FROM listened_song WHERE "
          "listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL "
          "15 DAY) <= FROM_UNIXTIME(begin_time)), times_10d = (SELECT COUNT(*) "
          "FROM listened_song WHERE listened_song.usid = user_song.id AND "
          "DATE_SUB(CURDATE(), INTERVAL 10 DAY) <= FROM_UNIXTIME(begin_time)), "
          "times_5d = (SELECT COUNT(*) FROM listened_song WHERE "
          "listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL "
          "5 DAY) <= FROM_UNIXTIME(begin_time))")) {
    fprintf(stderr, "%s\n", mysql_error(conn));
    exit(-1);
  }
  mysql_close(conn);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xe77(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xe6f(%rip),%eax
mov    %eax,-0x1f(%rbp)
mov    0xe6a(%rip),%al
mov    %al,-0x1b(%rbp)
mov    0xe62(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe5c(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe54(%rip),%al
mov    %al,-0x20(%rbp)
mov    0x10e5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x10e2(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x10e0(%rip),%al
mov    %al,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <mysql_init@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
lea    -0x1f(%rbp),%rdx
lea    -0x26(%rbp),%rcx
lea    -0x40(%rbp),%r8
xor    %r9d,%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1050 <mysql_real_connect@plt>
cmp    $0x0,%eax
jne    1258 <main+0xe8>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <mysql_error@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xdcd(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   1030 <mysql_query@plt>
cmp    $0x0,%rax
je     12a3 <main+0x133>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <mysql_error@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xd82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1060 <mysql_close@plt>
mov    $0xffffffff,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movabs $0x736f686c61636f6c,%rax
68 6f 73
mov    %rax,0x10(%rsp)
movw   $0x74,0x18(%rsp)
movb   $0x0,0x4(%rsp)
movl   $0x746f6f72,(%rsp)
movl   $0x313131,0xb(%rsp)
movl   $0x31313131,0x8(%rsp)
31
movaps 0x1101(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x30(%rsp)
xor    %edi,%edi
call   1070 <mysql_init@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
lea    0x20(%rsp),%r8
mov    %rax,%rdi
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1050 <mysql_real_connect@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1214 <main+0xa4>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
call   1030 <mysql_query@plt>
test   %rax,%rax
jne    1214 <main+0xa4>
mov    %rbx,%rdi
call   1060 <mysql_close@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2dc5(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1080 <mysql_error@plt>
lea    0xdea(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.main.server = [10 x i8] c"localhost\00"
@__const.main.username = [5 x i8] c"root\00"
@__const.main.password = [7 x i8] c"111111\00"
@__const.main.database = [17 x i8] c"listen_his_songs\00"
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [658 x i8] c"UPDATE user_song SET times_30d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= FROM_UNIXTIME(begin_time)), times_15d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 15 DAY) <= FROM_UNIXTIME(begin_time)), times_10d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 10 DAY) <= FROM_UNIXTIME(begin_time)), times_5d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 5 DAY) <= FROM_UNIXTIME(begin_time))\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [10 x i8]
%4 = alloca [5 x i8]
%5 = alloca [7 x i8]
%6 = alloca [17 x i8]
store i32 0, i32* %1
%7 = bitcast [10 x i8]* %3 to i8*
%8 = bitcast [5 x i8]* %4 to i8*
%9 = bitcast [7 x i8]* %5 to i8*
%10 = bitcast [17 x i8]* %6 to i8*
%11 = call i32* @mysql_init(i32* null)
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%17 = call i32 @mysql_real_connect(i32* %12, i8* %13, i8* %14, i8* %15, i8* %16, i32 0, i32* null, i32 0)
%18 = icmp ne i32 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = load i32*, i32** %2
%22 = call i8* @mysql_error(i32* %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %0
%26 = load i32*, i32** %2
%27 = call i64 @mysql_query(i32* %26, i8* getelementptr inbounds ([658 x i8], [658 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i32*, i32** %2
%32 = call i8* @mysql_error(i32* %31)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %25
%36 = load i32*, i32** %2
%37 = call i32 @mysql_close(i32* %36)
ret i32 -1
}

LLVM IR (-O2):
@__const.main.server = [10 x i8] c"localhost\00"
@__const.main.username = [5 x i8] c"root\00"
@__const.main.password = [7 x i8] c"111111\00"
@__const.main.database = [17 x i8] c"listen_his_songs\00"
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [658 x i8] c"UPDATE user_song SET times_30d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= FROM_UNIXTIME(begin_time)), times_15d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 15 DAY) <= FROM_UNIXTIME(begin_time)), times_10d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 10 DAY) <= FROM_UNIXTIME(begin_time)), times_5d = (SELECT COUNT(*) FROM listened_song WHERE listened_song.usid = user_song.id AND DATE_SUB(CURDATE(), INTERVAL 5 DAY) <= FROM_UNIXTIME(begin_time))\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [5 x i8]
%3 = alloca [7 x i8]
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%9 = tail call i32* @mysql_init(i32* null)
%10 = call i32 @mysql_real_connect(i32* %9, i8* %5, i8* %6, i8* %7, i8* %8, i32 0, i32* null, i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i8* @mysql_error(i32* %9)
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %0
%18 = call i64 @mysql_query(i32* %9, i8* getelementptr inbounds ([658 x i8], [658 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i8* @mysql_error(i32* %9)
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %17
%26 = call i32 @mysql_close(i32* %9)
ret i32 -1
}