#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*/ sprintf(char *, char *, char *, char *, char *, int, char *);
char *strdup(char *);
char *QPokeIdFromName(char name[], int lang) {
  char buf[1024], *query = NULL;
  sprintf(buf, "%s%s%s%d%s",
          "SELECT id, species_id, name, identifier "
          "FROM pokemon P, pokemon_species_names PN "
          "WHERE P.species_id = PN.pokemon_species_id "
          "AND PN.name LIKE '",
          name,
          "' "
          "AND PN.local_language_id = ",
          lang,
          " "
          "ORDER BY P.species_id, P.id;");
  query = strdup(buf);
  return query;
}


x86 assembly (clang, -O0):
<QPokeIdFromName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r9d
lea    0xead(%rip),%rsi
lea    0xeb1(%rip),%rdx
lea    0xf39(%rip),%r8
lea    0xf50(%rip),%rax
mov    %rax,(%rsp)
call   1030 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QPokeIdFromName>:
push   %rbx
sub    $0x410,%rsp
mov    %esi,%r9d
mov    %rdi,%rcx
lea    0xf83(%rip),%rax
mov    %rax,(%rsp)
lea    0xec0(%rip),%rsi
lea    0xec4(%rip),%rdx
lea    0xf4c(%rip),%r8
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s%s%s%d%s\00"
@.str.1 = [143 x i8] c"SELECT id, species_id, name, identifier FROM pokemon P, pokemon_species_names PN WHERE P.species_id = PN.pokemon_species_id AND PN.name LIKE '\00"
@.str.2 = [30 x i8] c"' AND PN.local_language_id = \00"
@.str.3 = [30 x i8] c" ORDER BY P.species_id, P.id;\00"
define i8* @QPokeIdFromName(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* null, i8** %6
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
ret i8* %13
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s%s%s%d%s\00"
@.str.1 = [143 x i8] c"SELECT id, species_id, name, identifier FROM pokemon P, pokemon_species_names PN WHERE P.species_id = PN.pokemon_species_id AND PN.name LIKE '\00"
@.str.2 = [30 x i8] c"' AND PN.local_language_id = \00"
@.str.3 = [30 x i8] c" ORDER BY P.species_id, P.id;\00"
define noalias i8* @QPokeIdFromName(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%6 = call i8* @strdup(i8* %4)
ret i8* %6
}