#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 *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *compose_get_game_info(char *a, char *b) {
  char u1[50];
  char u2[50];
  if (strcmp(a, b) < 0) {
    strcpy(u1, a);
    strcpy(u2, b);
  } else {
    strcpy(u1, b);
    strcpy(u2, a);
  }
  char *execStr = malloc(400 * sizeof(char *));
  strcat(execStr, "SELECT * FROM game_data WHERE u1=\"");
  strcat(execStr, u1);
  strcat(execStr, "\" and u2=\"");
  strcat(execStr, u2);
  strcat(execStr, "\";");
  return execStr;
}


x86 assembly (clang, -O0):
<compose_get_game_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    118c <compose_get_game_info+0x4c>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a9 <compose_get_game_info+0x69>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    $0xc80,%edi
call   1050 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x98(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x98(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x98(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x98(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x98(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compose_get_game_info>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strcmp@plt>
test   %rax,%rax
mov    %r14,%rsi
cmovs  %rbx,%rsi
cmovs  %r14,%rbx
lea    0x40(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0xc80,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe6c(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"SELECT * FROM game_data WHERE u1=\22\00"
@.str.1 = [11 x i8] c"\22 and u2=\22\00"
@.str.2 = [3 x i8] c"\22;\00"
define i8* @compose_get_game_info(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [50 x i8]
%6 = alloca [50 x i8]
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i64 @strcmp(i8* %8, i8* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %16, i8* %17)
br label %26
19: ; preds = %2
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %26
26: ; preds = %19, %12
%27 = call i8* @malloc(i32 3200)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %7
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%35 = load i8*, i8** %7
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%37 = call i32 @strcat(i8* %35, i8* %36)
%38 = load i8*, i8** %7
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = load i8*, i8** %7
ret i8* %40
}

LLVM IR (-O2):
@.str = [35 x i8] c"SELECT * FROM game_data WHERE u1=\22\00"
@.str.1 = [11 x i8] c"\22 and u2=\22\00"
@.str.2 = [3 x i8] c"\22;\00"
define i8* @compose_get_game_info(i8* %0, i8* %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%7 = tail call i64 @strcmp(i8* %0, i8* %1)
%8 = icmp slt i64 %7, 0
%9 = select i1 %8, i8* %0, i8* %1
%10 = select i1 %8, i8* %1, i8* %0
%11 = call i32 @strcpy(i8* %5, i8* %9)
%12 = call i32 @strcpy(i8* %6, i8* %10)
%13 = call dereferenceable_or_null(3200) i8* @malloc(i32 3200)
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @strcat(i8* %13, i8* %5)
%16 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @strcat(i8* %13, i8* %6)
%18 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i8* %13
}