#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 */
size_t rand();
size_t strlen(char *);
int __lets_play(char *param) {
  int i = 0;
  char buffer[2];
  for (i = 0; i < strlen(param); i++) {
    if (i % 2)
      buffer[i] = param[rand() % strlen(param)];
    else
      buffer[i] = '\0';
  }
  if ((int)buffer < 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<__lets_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    11c7 <__lets_play+0xa7>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ab <__lets_play+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    -0x28(%rbp),%rax
mov    (%rax,%rdx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
jmp    11b4 <__lets_play+0x94>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x16(%rbp,%rax,1)
jmp    11b9 <__lets_play+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <__lets_play+0x1a>
lea    -0x16(%rbp),%rax
cmp    $0x0,%eax
jge    11e0 <__lets_play+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <__lets_play+0xc7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__lets_play>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmpb   $0x0,(%rdi)
je     1195 <__lets_play+0x75>
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1157 <__lets_play+0x37>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
mov    %al,0xe(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rbx,%rax
jbe    1195 <__lets_play+0x75>
test   $0x1,%bl
je     1140 <__lets_play+0x20>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    %r15,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1187 <__lets_play+0x67>
mov    %r15,%rax
xor    %edx,%edx
div    %rcx
jmp    118e <__lets_play+0x6e>
mov    %r15d,%eax
xor    %edx,%edx
div    %ecx
movzbl (%r14,%rdx,1),%eax
jmp    1142 <__lets_play+0x22>
lea    0xe(%rsp),%rax
not    %eax
shr    $0x1f,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @__lets_play(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [2 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %4
br label %6
6: ; preds = %32, %1
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = icmp ult i64 %8, %10
br i1 %11, label %12, label %35
12: ; preds = %6
%13 = load i32, i32* %4
%14 = srem i32 %13, 2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i64 (...) @rand()
%19 = load i8*, i8** %3
%20 = call i64 @strlen(i8* %19)
%21 = urem i64 %18, %20
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 %25
store i8 %23, i8* %26
br label %31
27: ; preds = %12
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %27, %16
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %6
35: ; preds = %6
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%37 = ptrtoint i8* %36 to i32
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 0, i32* %2
br label %41
40: ; preds = %35
store i32 1, i32* %2
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @__lets_play(i8* nocapture %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %1, %16
%7 = phi i64 [ %19, %16 ], [ 0, %1 ]
%8 = and i64 %7, 1
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = tail call i64 (...) @rand()
%12 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%13 = urem i64 %11, %12
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
br label %16
16: ; preds = %6, %10
%17 = phi i8 [ %15, %10 ], [ 0, %6 ]
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 %7
store i8 %17, i8* %18
%19 = add nuw i64 %7, 1
%20 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%21 = icmp ugt i64 %20, %19
br i1 %21, label %6, label %22
22: ; preds = %16, %1
%23 = ptrtoint [2 x i8]* %2 to i64
%24 = trunc i64 %23 to i32
%25 = xor i32 %24, -1
%26 = lshr i32 %25, 31
ret i32 %26
}