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


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

x86 assembly (clang, -O2):
<stringFieldInSubmissionSet>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%rcx
mov    %esi,%r8d
mov    %rdi,%rbx
lea    0xec6(%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 = [162 x i8] c"select submissionSet.%s from image,imageFile,submissionSet where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id\00"
define i8* @stringFieldInSubmissionSet(%struct.sqlConnection* %0, i32 %1, i8* %2) {
%4 = alloca %struct.sqlConnection*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [256 x i8]
store %struct.sqlConnection* %0, %struct.sqlConnection** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %6
%10 = load i32, i32* %5
%11 = call i32 @sqlSafef(i8* %8, i32 256, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
%12 = load %struct.sqlConnection*, %struct.sqlConnection** %4
%13 = getelementptr inbounds [256 x i8], [256 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 = [162 x i8] c"select submissionSet.%s from image,imageFile,submissionSet where image.id = %d and image.imageFile = imageFile.id and imageFile.submissionSet = submissionSet.id\00"
define i8* @stringFieldInSubmissionSet(%struct.sqlConnection* %0, i32 %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @sqlSafef(i8* %5, i32 256, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
%7 = call i8* @sqlQuickString(%struct.sqlConnection* %0, i8* %5)
ret i8* %7
}