#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 */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ putchar(char);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  char pieces[] = "OISZLJT";
  char bag[] = "OISZLJT";
  for (int i = 0; i < 50; i++) {
    char pc = i % 7;
    if (!pc) {
      memcpy(bag, pieces, 7);
    }
    char index = rand() % (7 - pc);
    putchar(bag[index]);
    bag[index] = bag[6 - pc];
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0xe8a(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xe7f(%rip),%rax
mov    %rax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x32,-0x18(%rbp)
jge    1213 <main+0xc3>
mov    -0x18(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x19(%rbp)
cmpb   $0x0,-0x19(%rbp)
jne    11c2 <main+0x72>
lea    -0x14(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x7,%edx
call   1050 <memcpy@plt>
mov    $0x0,%al
call   1070 <rand@plt>
movsbl -0x19(%rbp),%edx
mov    $0x7,%ecx
sub    %edx,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x1a(%rbp)
movsbq -0x1a(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
movsbl -0x19(%rbp),%ecx
mov    $0x6,%eax
sub    %ecx,%eax
cltq
mov    -0x14(%rbp,%rax,1),%cl
movsbq -0x1a(%rbp),%rax
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118c <main+0x3c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movabs $0x544a4c5a53494f,%rax
mov    %rax,0x10(%rsp)
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    11d5 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
xor    $0x7,%ebp
cltd
idiv   %ebp
movsbq %dl,%rbp
movsbl 0x8(%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
add    %r13d,%r12d
movzbl 0x8(%rsp,%r12,1),%eax
mov    %al,0x8(%rsp,%rbp,1)
add    $0x1,%ebx
add    $0xffffffff,%r13d
cmp    $0xffffffce,%r13d
je     121a <main+0xca>
mov    %ebx,%eax
imul   $0x24924925,%rax,%rax
shr    $0x20,%rax
mov    %ebx,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x2,%ecx
lea    0x0(,%rcx,8),%eax
sub    %ecx,%eax
lea    0x6(%rax),%r12d
mov    %ebx,%ebp
sub    %eax,%ebp
add    %r13d,%eax
add    $0x6,%eax
cmp    $0x6,%al
jne    11a0 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x7,%edx
call   1050 <memcpy@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.pieces = [8 x i8] c"OISZLJT\00"
@__const.main.bag = [8 x i8] c"OISZLJT\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
store i32 0, i32* %1
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = bitcast [8 x i8]* %2 to i8*
%10 = bitcast [8 x i8]* %3 to i8*
store i32 0, i32* %4
br label %11
11: ; preds = %45, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 50
br i1 %13, label %14, label %48
14: ; preds = %11
%15 = load i32, i32* %4
%16 = srem i32 %15, 7
%17 = trunc i32 %16 to i8
store i8 %17, i8* %5
%18 = load i8, i8* %5
%19 = icmp ne i8 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%23 = call i32 @memcpy(i8* %21, i8* %22, i32 7)
br label %24
24: ; preds = %20, %14
%25 = call i32 (...) @rand()
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = sub nsw i32 7, %27
%29 = srem i32 %25, %28
%30 = trunc i32 %29 to i8
store i8 %30, i8* %6
%31 = load i8, i8* %6
%32 = sext i8 %31 to i64
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @putchar(i8 signext %34)
%36 = load i8, i8* %5
%37 = sext i8 %36 to i32
%38 = sub nsw i32 6, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = load i8, i8* %6
%43 = sext i8 %42 to i64
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %43
store i8 %41, i8* %44
br label %45
45: ; preds = %24
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %11
48: ; preds = %11
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %2 to [8 x i8]*
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = bitcast i64* %1 to i8*
store i64 23725589837072719, i64* %1
%7 = bitcast i64* %2 to i8*
store i64 23725589837072719, i64* %2
br label %9
8: ; preds = %17
ret i32 0
9: ; preds = %0, %17
%10 = phi i32 [ 0, %0 ], [ %31, %17 ]
%11 = trunc i32 %10 to i8
%12 = urem i8 %11, 7
%13 = zext i8 %12 to i32
%14 = icmp eq i8 %12, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @memcpy(i8* %7, i8* %6, i32 7)
br label %17
17: ; preds = %15, %9
%18 = call i32 (...) @rand()
%19 = xor i32 %13, 7
%20 = srem i32 %18, %19
%21 = zext i32 %20 to i64
%22 = shl i64 %21, 56
%23 = ashr exact i64 %22, 56
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @putchar(i8 signext %25)
%27 = sub nuw nsw i32 6, %13
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
store i8 %30, i8* %24
%31 = add nuw nsw i32 %10, 1
%32 = icmp eq i32 %31, 50
br i1 %32, label %8, label %9
}