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

/* Variables and functions */
double sqlite3_value_double(int /*<<< orphan*/ *);
int sqlite3_value_int(int /*<<< orphan*/ *);
int /*<<< orphan*/ update_stat_db(int, int, int, int, double);
void update_stat(sqlite3_context *context, int argc, sqlite3_value **argv) {
  if (argc != 5)
    return;
  int y = sqlite3_value_int(argv[0]);
  int m = sqlite3_value_int(argv[1]);
  int d = sqlite3_value_int(argv[2]);
  int h = sqlite3_value_int(argv[3]);
  double kwh = sqlite3_value_double(argv[4]);
  update_stat_db(y, m, d, h, kwh);
}


x86 assembly (clang, -O0):
<update_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x5,-0xc(%rbp)
je     1152 <update_stat+0x22>
jmp    11b9 <update_stat+0x89>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <sqlite3_value_double@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
movsd  -0x30(%rbp),%xmm0
call   1040 <update_stat_db@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_stat>:
cmp    $0x5,%esi
jne    118f <update_stat+0x5f>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    (%rdx),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,%r12d
mov    0x18(%rbx),%rdi
call   1030 <sqlite3_value_int@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rdi
call   1050 <sqlite3_value_double@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <update_stat_db@plt>
ret

LLVM IR (-O0):
define void @update_stat(i32* %0, i32 %1, i32** %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32** %2, i32*** %6
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %15
14: ; preds = %3
br label %42
15: ; preds = %3
%16 = load i32**, i32*** %6
%17 = getelementptr inbounds i32*, i32** %16, i64 0
%18 = load i32*, i32** %17
%19 = call i32 @sqlite3_value_int(i32* %18)
store i32 %19, i32* %7
%20 = load i32**, i32*** %6
%21 = getelementptr inbounds i32*, i32** %20, i64 1
%22 = load i32*, i32** %21
%23 = call i32 @sqlite3_value_int(i32* %22)
store i32 %23, i32* %8
%24 = load i32**, i32*** %6
%25 = getelementptr inbounds i32*, i32** %24, i64 2
%26 = load i32*, i32** %25
%27 = call i32 @sqlite3_value_int(i32* %26)
store i32 %27, i32* %9
%28 = load i32**, i32*** %6
%29 = getelementptr inbounds i32*, i32** %28, i64 3
%30 = load i32*, i32** %29
%31 = call i32 @sqlite3_value_int(i32* %30)
store i32 %31, i32* %10
%32 = load i32**, i32*** %6
%33 = getelementptr inbounds i32*, i32** %32, i64 4
%34 = load i32*, i32** %33
%35 = call double @sqlite3_value_double(i32* %34)
store double %35, double* %11
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = load double, double* %11
%41 = call i32 @update_stat_db(i32 %36, i32 %37, i32 %38, i32 %39, double %40)
br label %42
42: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
define void @update_stat(i32* nocapture readnone %0, i32 %1, i32** nocapture %2) {
%4 = icmp eq i32 %1, 5
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = load i32*, i32** %2
%7 = tail call i32 @sqlite3_value_int(i32* %6)
%8 = getelementptr inbounds i32*, i32** %2, i64 1
%9 = load i32*, i32** %8
%10 = tail call i32 @sqlite3_value_int(i32* %9)
%11 = getelementptr inbounds i32*, i32** %2, i64 2
%12 = load i32*, i32** %11
%13 = tail call i32 @sqlite3_value_int(i32* %12)
%14 = getelementptr inbounds i32*, i32** %2, i64 3
%15 = load i32*, i32** %14
%16 = tail call i32 @sqlite3_value_int(i32* %15)
%17 = getelementptr inbounds i32*, i32** %2, i64 4
%18 = load i32*, i32** %17
%19 = tail call double @sqlite3_value_double(i32* %18)
%20 = tail call i32 @update_stat_db(i32 %7, i32 %10, i32 %13, i32 %16, double %19)
br label %21
21: ; preds = %3, %5
ret void
}