#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 */

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, ...);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int strlen(char *);
char *get_update_query(float pchange, float p3qrt, float p3qvr, float p3smq,
                       float pnote, float ppause) {
  char *local, *out;
  int i;
  asprintf(&local,
           "UPDATE semiquaver SET pchange= %f"
           ", pchange_3qrt = %f"
           ", pchange_3qvr = %f"
           ", pchange_3smq = %f"
           ", pnote = '{ ",
           pchange, p3qrt, p3qvr, p3smq);
  for (i = 0; i < 12; i++)
    asprintf(&local, "%s%f,", local, pnote);
  asprintf(&local,
           "%s%f}' WHERE id in "
           "(SELECT sq.id FROM semiquaver AS sq,"
           " quarter AS q WHERE q.id = sq.quarter"
           " AND solo = 't');",
           local, ppause);
  out = malloc((strlen(local) + 1) * sizeof(char));
  if (!out)
    return NULL;
  if (!memcpy(out, local, (strlen(local) + 1) * sizeof(char)))
    return NULL;
  return out;
}


x86 assembly (clang, -O0):
<get_update_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  %xmm4,-0x1c(%rbp)
movss  %xmm5,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x18(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    -0x28(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x4,%al
call   1060 <asprintf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xc,-0x34(%rbp)
jge    11da <get_update_query+0x9a>
mov    -0x28(%rbp),%rdx
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0x28(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a3 <get_update_query+0x63>
mov    -0x28(%rbp),%rdx
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0x28(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    122e <get_update_query+0xee>
movq   $0x0,-0x8(%rbp)
jmp    127d <get_update_query+0x13d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
cmp    $0x0,%eax
jne    1275 <get_update_query+0x135>
movq   $0x0,-0x8(%rbp)
jmp    127d <get_update_query+0x13d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_update_query>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  %xmm5,0x14(%rsp)
movss  %xmm4,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
cvtss2sd %xmm3,%xmm3
lea    0xe96(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x4,%al
call   1060 <asprintf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    (%rsp),%rdx
lea    0xed6(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdx
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbd(%rip),%rsi
mov    %r14,%rdi
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    (%rsp),%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     12fa <get_update_query+0x1ba>
mov    %rax,%rbx
mov    (%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <memcpy@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovne %rbx,%rax
jmp    12fc <get_update_query+0x1bc>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [104 x i8] c"UPDATE semiquaver SET pchange= %f, pchange_3qrt = %f, pchange_3qvr = %f, pchange_3smq = %f, pnote = '{ \00"
@.str.1 = [6 x i8] c"%s%f,\00"
@.str.2 = [110 x i8] c"%s%f}' WHERE id in (SELECT sq.id FROM semiquaver AS sq, quarter AS q WHERE q.id = sq.quarter AND solo = 't');\00"
define i8* @get_update_query(float %0, float %1, float %2, float %3, float %4, float %5) {
%7 = alloca i8*
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
store float %0, float* %8
store float %1, float* %9
store float %2, float* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
%17 = load float, float* %8
%18 = fpext float %17 to double
%19 = load float, float* %9
%20 = fpext float %19 to double
%21 = load float, float* %10
%22 = fpext float %21 to double
%23 = load float, float* %11
%24 = fpext float %23 to double
%25 = call i32 (i8**, i8*, ...) @asprintf(i8** %14, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0), double %18, double %20, double %22, double %24)
store i32 0, i32* %16
br label %26
26: ; preds = %34, %6
%27 = load i32, i32* %16
%28 = icmp slt i32 %27, 12
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i8*, i8** %14
%31 = load float, float* %12
%32 = fpext float %31 to double
%33 = call i32 (i8**, i8*, ...) @asprintf(i8** %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %30, double %32)
br label %34
34: ; preds = %29
%35 = load i32, i32* %16
%36 = add nsw i32 %35, 1
store i32 %36, i32* %16
br label %26
37: ; preds = %26
%38 = load i8*, i8** %14
%39 = load float, float* %13
%40 = fpext float %39 to double
%41 = call i32 (i8**, i8*, ...) @asprintf(i8** %14, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0), i8* %38, double %40)
%42 = load i8*, i8** %14
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = mul i64 %45, 1
%47 = trunc i64 %46 to i32
%48 = call i8* @malloc(i32 %47)
store i8* %48, i8** %15
%49 = load i8*, i8** %15
%50 = icmp ne i8* %49, null
br i1 %50, label %52, label %51
51: ; preds = %37
store i8* null, i8** %7
br label %66
52: ; preds = %37
%53 = load i8*, i8** %15
%54 = load i8*, i8** %14
%55 = load i8*, i8** %14
%56 = call i32 @strlen(i8* %55)
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 1
%60 = trunc i64 %59 to i32
%61 = call i32 @memcpy(i8* %53, i8* %54, i32 %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %52
store i8* null, i8** %7
br label %66
64: ; preds = %52
%65 = load i8*, i8** %15
store i8* %65, i8** %7
br label %66
66: ; preds = %64, %63, %51
%67 = load i8*, i8** %7
ret i8* %67
}

LLVM IR (-O2):
@.str = [104 x i8] c"UPDATE semiquaver SET pchange= %f, pchange_3qrt = %f, pchange_3qvr = %f, pchange_3smq = %f, pnote = '{ \00"
@.str.1 = [6 x i8] c"%s%f,\00"
@.str.2 = [110 x i8] c"%s%f}' WHERE id in (SELECT sq.id FROM semiquaver AS sq, quarter AS q WHERE q.id = sq.quarter AND solo = 't');\00"
define i8* @get_update_query(float %0, float %1, float %2, float %3, float %4, float %5) {
%7 = alloca i8*
%8 = bitcast i8** %7 to i8*
%9 = fpext float %0 to double
%10 = fpext float %1 to double
%11 = fpext float %2 to double
%12 = fpext float %3 to double
%13 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0), double %9, double %10, double %11, double %12)
%14 = fpext float %4 to double
%15 = load i8*, i8** %7
%16 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %15, double %14)
%17 = load i8*, i8** %7
%18 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17, double %14)
%19 = load i8*, i8** %7
%20 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %19, double %14)
%21 = load i8*, i8** %7
%22 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %21, double %14)
%23 = load i8*, i8** %7
%24 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %23, double %14)
%25 = load i8*, i8** %7
%26 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %25, double %14)
%27 = load i8*, i8** %7
%28 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %27, double %14)
%29 = load i8*, i8** %7
%30 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29, double %14)
%31 = load i8*, i8** %7
%32 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %31, double %14)
%33 = load i8*, i8** %7
%34 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %33, double %14)
%35 = load i8*, i8** %7
%36 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %35, double %14)
%37 = load i8*, i8** %7
%38 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %37, double %14)
%39 = load i8*, i8** %7
%40 = fpext float %5 to double
%41 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.2, i64 0, i64 0), i8* %39, double %40)
%42 = load i8*, i8** %7
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %43, 1
%45 = call i8* @malloc(i32 %44)
%46 = icmp eq i8* %45, null
br i1 %46, label %54, label %47
47: ; preds = %6
%48 = load i8*, i8** %7
%49 = call i32 @strlen(i8* %48)
%50 = add nsw i32 %49, 1
%51 = call i32 @memcpy(i8* %45, i8* %48, i32 %50)
%52 = icmp eq i32 %51, 0
%53 = select i1 %52, i8* null, i8* %45
br label %54
54: ; preds = %47, %6
%55 = phi i8* [ null, %6 ], [ %53, %47 ]
ret i8* %55
}