#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 */
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *compose_validate_user(char *user, char *passwd) {
  char *execStr = malloc(200);
  strcpy(execStr, "SELECT * FROM users WHERE username=\"");
  strcat(execStr, user);
  strcat(execStr, "\" and password=\"");
  strcat(execStr, passwd);
  strcat(execStr, "\";");
  return execStr;
}


x86 assembly (clang, -O0):
<compose_validate_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compose_validate_user>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xc8,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb1(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"SELECT * FROM users WHERE username=\22\00"
@.str.1 = [17 x i8] c"\22 and password=\22\00"
@.str.2 = [3 x i8] c"\22;\00"
define i8* @compose_validate_user(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i8* @malloc(i32 200)
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %5
%10 = load i8*, i8** %3
%11 = call i32 @strcat(i8* %9, i8* %10)
%12 = load i8*, i8** %5
%13 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = load i8*, i8** %5
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** %5
ret i8* %19
}

LLVM IR (-O2):
@.str = [37 x i8] c"SELECT * FROM users WHERE username=\22\00"
@.str.1 = [17 x i8] c"\22 and password=\22\00"
@.str.2 = [3 x i8] c"\22;\00"
define i8* @compose_validate_user(i8* %0, i8* %1) {
%3 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcat(i8* %3, i8* %0)
%6 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @strcat(i8* %3, i8* %1)
%8 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i8* %3
}