#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 *, char *, int);
char *stringFieldInSubmissionSource(struct sqlConnection *conn, int id,
                                    char *field) {
  char query[512];
  sqlSafef(query, sizeof(query),
           "select submissionSource.%s "
           "from image,imageFile,submissionSet,submissionSource "
           "where image.id = %d "
           "and image.imageFile = imageFile.id "
           "and imageFile.submissionSet = submissionSet.id "
           "and submissionSet.submissionSource = submissionSource.id",
           field, id);
  return sqlQuickString(conn, query);
}


x86 assembly (clang, -O0):
<stringFieldInSubmissionSource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    $0x200,%esi
lea    0xeaf(%rip),%rdx
call   1040 <sqlSafef@plt>
mov    -0x8(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <sqlQuickString@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringFieldInSubmissionSource>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%rcx
mov    %esi,%r8d
mov    %rdi,%rbx
lea    0xec6(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x200,%esi
call   1040 <sqlSafef@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sqlQuickString@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sqlConnection = type { i32 }
@.str = [238 x i8] c"select submissionSource.%s from image,imageFile,submissionSet,submissionSource where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id and submissionSet.submissionSource = submissionSource.id\00"
define i8* @stringFieldInSubmissionSource(%struct.sqlConnection* %0, i32 %1, i8* %2) {
%4 = alloca %struct.sqlConnection*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [512 x i8]
store %struct.sqlConnection* %0, %struct.sqlConnection** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %6
%10 = load i32, i32* %5
%11 = call i32 @sqlSafef(i8* %8, i32 512, i8* getelementptr inbounds ([238 x i8], [238 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
%12 = load %struct.sqlConnection*, %struct.sqlConnection** %4
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%14 = call i8* @sqlQuickString(%struct.sqlConnection* %12, i8* %13)
ret i8* %14
}

LLVM IR (-O2):
%struct.sqlConnection = type { i32 }
@.str = [238 x i8] c"select submissionSource.%s from image,imageFile,submissionSet,submissionSource where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id and submissionSet.submissionSource = submissionSource.id\00"
define i8* @stringFieldInSubmissionSource(%struct.sqlConnection* %0, i32 %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32 @sqlSafef(i8* %5, i32 512, i8* getelementptr inbounds ([238 x i8], [238 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
%7 = call i8* @sqlQuickString(%struct.sqlConnection* %0, i8* %5)
ret i8* %7
}