#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *compose_update_wins(char *u1, char *u2, int u1wins, int u2wins,
                          int last) {
  char *execStr = malloc(200);
  strcpy(execStr, "UPDATE game_data SET u1wins=\"");
  char c[20];
  sprintf(c, "%d", u1wins);
  strcat(execStr, c);
  strcat(execStr, "\", u2wins=\"");
  sprintf(c, "%d", u2wins);
  strcat(execStr, c);
  strcat(execStr, "\" WHERE u1=\"");
  strcat(execStr, u1);
  strcat(execStr, "\" and u2=\"");
  strcat(execStr, u2);
  strcat(execStr, "\";");
  return execStr;
}


x86 assembly (clang, -O0):
<compose_update_wins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    $0xc8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe98(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe68(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compose_update_wins>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r15
mov    $0xc8,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xe91(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xea0(%rip),%r13
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
call   1050 <strcat@plt>
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"UPDATE game_data SET u1wins=\22\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"\22, u2wins=\22\00"
@.str.3 = [13 x i8] c"\22 WHERE u1=\22\00"
@.str.4 = [11 x i8] c"\22 and u2=\22\00"
@.str.5 = [3 x i8] c"\22;\00"
define i8* @compose_update_wins(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [20 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = call i8* @malloc(i32 200)
store i8* %13, i8** %11
%14 = load i8*, i8** %11
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%17 = load i32, i32* %8
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %11
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%21 = call i32 @strcat(i8* %19, i8* %20)
%22 = load i8*, i8** %11
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%25 = load i32, i32* %9
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %11
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %11
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%32 = load i8*, i8** %11
%33 = load i8*, i8** %6
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = load i8*, i8** %11
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%37 = load i8*, i8** %11
%38 = load i8*, i8** %7
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = load i8*, i8** %11
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%42 = load i8*, i8** %11
ret i8* %42
}

LLVM IR (-O2):
@.str = [30 x i8] c"UPDATE game_data SET u1wins=\22\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"\22, u2wins=\22\00"
@.str.3 = [13 x i8] c"\22 WHERE u1=\22\00"
@.str.4 = [11 x i8] c"\22 and u2=\22\00"
@.str.5 = [3 x i8] c"\22;\00"
define i8* @compose_update_wins(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [20 x i8]
%7 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%11 = call i32 @strcat(i8* %7, i8* %9)
%12 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%14 = call i32 @strcat(i8* %7, i8* %9)
%15 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @strcat(i8* %7, i8* %0)
%17 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @strcat(i8* %7, i8* %1)
%19 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret i8* %7
}