#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 *, unsigned long long, ...);
char *game(unsigned long long n) {
  char *result = malloc(30);
  if (n % 2 == 0)
    sprintf(result, "[%lld]", n / 2 * n);
  else
    sprintf(result, "[%lld, %d]", n * n, 2);
  return result;
}


x86 assembly (clang, -O0):
<game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1e,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1170 <game+0x50>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
shr    $0x1,%rdx
imul   -0x8(%rbp),%rdx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1190 <game+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
imul   -0x8(%rbp),%rdx
lea    0xe83(%rip),%rsi
mov    $0x2,%ecx
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<game>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1e,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   $0x1,%bl
jne    1156 <game+0x36>
mov    %rbx,%rdx
shr    %rdx
imul   %rbx,%rdx
lea    0xeb6(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1173 <game+0x53>
imul   %rbx,%rbx
lea    0xea6(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x2,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"[%lld]\00"
@.str.1 = [11 x i8] c"[%lld, %d]\00"
define i8* @game(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = call i8* @malloc(i32 30)
store i8* %4, i8** %3
%5 = load i64, i64* %2
%6 = urem i64 %5, 2
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i64, i64* %2
%11 = udiv i64 %10, 2
%12 = load i64, i64* %2
%13 = mul i64 %11, %12
%14 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %13)
br label %21
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = load i64, i64* %2
%18 = load i64, i64* %2
%19 = mul i64 %17, %18
%20 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %19, i32 2)
br label %21
21: ; preds = %15, %8
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [7 x i8] c"[%lld]\00"
@.str.1 = [11 x i8] c"[%lld, %d]\00"
define noalias i8* @game(i64 %0) {
%2 = tail call dereferenceable_or_null(30) i8* @malloc(i32 30)
%3 = and i64 %0, 1
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = lshr i64 %0, 1
%7 = mul i64 %6, %0
%8 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %7)
br label %12
9: ; preds = %1
%10 = mul i64 %0, %0
%11 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %10, i32 2)
br label %12
12: ; preds = %9, %5
ret i8* %2
}