#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 */
struct sqlConnection {
  int dummy;
};
typedef int /*<<< orphan*/ query;

/* Variables and functions */
char *sqlQuickString(struct sqlConnection *, char *);
int /*<<< orphan*/ sqlSafef(char *, int, char *, int);
char *visiGeneCopyright(struct sqlConnection *conn, int id) {
  char query[256];
  sqlSafef(
      query, sizeof(query),
      "select copyright.notice from image,imageFile,submissionSet,copyright "
      "where image.id = %d "
      "and image.imageFile = imageFile.id "
      "and imageFile.submissionSet = submissionSet.id "
      "and submissionSet.copyright = copyright.id",
      id);
  return sqlQuickString(conn, query);
}


x86 assembly (clang, -O0):
<visiGeneCopyright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    $0x100,%esi
lea    0xeb8(%rip),%rdx
call   1040 <sqlSafef@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <sqlQuickString@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<visiGeneCopyright>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ecx
mov    %rdi,%rbx
lea    0xeca(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1040 <sqlSafef@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sqlQuickString@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sqlConnection = type { i32 }
@.str = [214 x i8] c"select copyright.notice from image,imageFile,submissionSet,copyright where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id and submissionSet.copyright = copyright.id\00"
define i8* @visiGeneCopyright(%struct.sqlConnection* %0, i32 %1) {
%3 = alloca %struct.sqlConnection*
%4 = alloca i32
%5 = alloca [256 x i8]
store %struct.sqlConnection* %0, %struct.sqlConnection** %3
store i32 %1, i32* %4
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* %4
%8 = call i32 @sqlSafef(i8* %6, i32 256, i8* getelementptr inbounds ([214 x i8], [214 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load %struct.sqlConnection*, %struct.sqlConnection** %3
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i8* @sqlQuickString(%struct.sqlConnection* %9, i8* %10)
ret i8* %11
}

LLVM IR (-O2):
%struct.sqlConnection = type { i32 }
@.str = [214 x i8] c"select copyright.notice from image,imageFile,submissionSet,copyright where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id and submissionSet.copyright = copyright.id\00"
define i8* @visiGeneCopyright(%struct.sqlConnection* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @sqlSafef(i8* %4, i32 256, i8* getelementptr inbounds ([214 x i8], [214 x i8]* @.str, i64 0, i64 0), i32 %1)
%6 = call i8* @sqlQuickString(%struct.sqlConnection* %0, i8* %4)
ret i8* %6
}