#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 *sqlQuickNonemptyString(struct sqlConnection *, char *);
int /*<<< orphan*/ sqlSafef(char *, int, char *, int);
char *visiGeneStrain(struct sqlConnection *conn, int id) {
  char query[256];
  sqlSafef(query, sizeof(query),
           "select strain.name from image,specimen,genotype,strain "
           "where image.id = %d "
           "and image.specimen = specimen.id "
           "and specimen.genotype = genotype.id "
           "and genotype.strain = strain.id",
           id);
  return sqlQuickNonemptyString(conn, query);
}


x86 assembly (clang, -O0):
<visiGeneStrain>:
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   1030 <sqlSafef@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <sqlQuickNonemptyString@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<visiGeneStrain>:
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   1030 <sqlSafef@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sqlQuickNonemptyString@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sqlConnection = type { i32 }
@.str = [176 x i8] c"select strain.name from image,specimen,genotype,strain where image.id = %d and image.specimen = specimen.id and specimen.genotype = genotype.id and genotype.strain = strain.id\00"
define i8* @visiGeneStrain(%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 ([176 x i8], [176 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* @sqlQuickNonemptyString(%struct.sqlConnection* %9, i8* %10)
ret i8* %11
}

LLVM IR (-O2):
%struct.sqlConnection = type { i32 }
@.str = [176 x i8] c"select strain.name from image,specimen,genotype,strain where image.id = %d and image.specimen = specimen.id and specimen.genotype = genotype.id and genotype.strain = strain.id\00"
define i8* @visiGeneStrain(%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 ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 %1)
%6 = call i8* @sqlQuickNonemptyString(%struct.sqlConnection* %0, i8* %4)
ret i8* %6
}