#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*/ printf(char *);
int /*<<< orphan*/ read(int /*<<< orphan*/, unsigned char *, int);
main() {
  int i, count;
  unsigned char buffer[6];
  read(0, buffer, 6);
  for (i = 0; i < 6; i++)
    buffer[i] = buffer[buffer[i] % 6] ^ buffer[i];
  count = 0;
  for (i = 0; i < 6; i++)
    count += buffer[i];
  if (count == 0x123)
    printf("You won!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x12(%rbp),%rsi
xor    %edi,%edi
mov    $0x6,%edx
call   1040 <read@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    118c <main+0x6c>
movslq -0x8(%rbp),%rax
movzbl -0x12(%rbp,%rax,1),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movzbl -0x12(%rbp,%rax,1),%eax
movslq -0x8(%rbp),%rcx
movzbl -0x12(%rbp,%rcx,1),%ecx
xor    %ecx,%eax
mov    %al,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x26>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11c1 <main+0xa1>
movslq -0x8(%rbp),%rax
movzbl -0x12(%rbp,%rax,1),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119a <main+0x7a>
cmpl   $0x123,-0xc(%rbp)
jne    11da <main+0xba>
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x2(%rsp),%rsi
xor    %edi,%edi
mov    $0x6,%edx
call   1040 <read@plt>
movzbl 0x2(%rsp),%eax
imul   $0xab,%eax,%ecx
shr    $0x9,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %cl,%dl
movzbl %dl,%ecx
mov    0x2(%rsp,%rcx,1),%r10b
xor    %al,%r10b
mov    %r10b,0x2(%rsp)
movzbl 0x3(%rsp),%eax
imul   $0xab,%eax,%ecx
shr    $0x9,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %cl,%dl
movzbl %dl,%ecx
mov    0x2(%rsp,%rcx,1),%dil
xor    %al,%dil
mov    %dil,0x3(%rsp)
movzbl 0x4(%rsp),%eax
imul   $0xab,%eax,%ecx
shr    $0x9,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %cl,%dl
movzbl %dl,%ecx
mov    0x2(%rsp,%rcx,1),%r8b
xor    %al,%r8b
mov    %r8b,0x4(%rsp)
movzbl 0x5(%rsp),%ecx
imul   $0xab,%ecx,%eax
shr    $0x9,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,2),%eax
mov    %ecx,%edx
sub    %al,%dl
movzbl %dl,%eax
mov    0x2(%rsp,%rax,1),%r9b
xor    %cl,%r9b
mov    %r9b,0x5(%rsp)
movzbl 0x6(%rsp),%edx
imul   $0xab,%edx,%ecx
shr    $0x9,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %edx,%eax
sub    %cl,%al
movzbl %al,%eax
mov    0x2(%rsp,%rax,1),%cl
xor    %dl,%cl
mov    %cl,0x6(%rsp)
movzbl 0x7(%rsp),%eax
imul   $0xab,%eax,%edx
shr    $0x9,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,2),%esi
mov    %eax,%edx
sub    %sil,%dl
movzbl %dl,%edx
mov    0x2(%rsp,%rdx,1),%dl
xor    %al,%dl
movzbl %r10b,%eax
movzbl %dil,%esi
add    %eax,%esi
movzbl %r8b,%eax
add    %esi,%eax
movzbl %r9b,%esi
add    %eax,%esi
movzbl %cl,%eax
add    %esi,%eax
movzbl %dl,%ecx
add    %eax,%ecx
cmp    $0x123,%ecx
jne    124d <main+0x12d>
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"You won!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
store i32 0, i32* %1
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%6 = call i32 @read(i32 0, i8* %5, i32 6)
store i32 0, i32* %2
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = srem i32 %15, 6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = xor i32 %20, %25
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %29
store i8 %27, i8* %30
br label %31
31: ; preds = %10
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %7
34: ; preds = %7
store i32 0, i32* %3
store i32 0, i32* %2
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %2
%37 = icmp slt i32 %36, 6
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = load i32, i32* %3
%45 = add nsw i32 %44, %43
store i32 %45, i32* %3
br label %46
46: ; preds = %38
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %35
49: ; preds = %35
%50 = load i32, i32* %3
%51 = icmp eq i32 %50, 291
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"You won!\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @read(i32 0, i8* %2, i32 6)
%4 = load i8, i8* %2
%5 = urem i8 %4, 6
%6 = zext i8 %5 to i64
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = xor i8 %8, %4
store i8 %9, i8* %2
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 1
%11 = load i8, i8* %10
%12 = urem i8 %11, 6
%13 = zext i8 %12 to i64
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = xor i8 %15, %11
store i8 %16, i8* %10
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 2
%18 = load i8, i8* %17
%19 = urem i8 %18, 6
%20 = zext i8 %19 to i64
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = xor i8 %22, %18
store i8 %23, i8* %17
%24 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 3
%25 = load i8, i8* %24
%26 = urem i8 %25, 6
%27 = zext i8 %26 to i64
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = xor i8 %29, %25
store i8 %30, i8* %24
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 4
%32 = load i8, i8* %31
%33 = urem i8 %32, 6
%34 = zext i8 %33 to i64
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = xor i8 %36, %32
store i8 %37, i8* %31
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 5
%39 = load i8, i8* %38
%40 = urem i8 %39, 6
%41 = zext i8 %40 to i64
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = xor i8 %43, %39
%45 = zext i8 %9 to i32
%46 = zext i8 %16 to i32
%47 = add nuw nsw i32 %45, %46
%48 = zext i8 %23 to i32
%49 = add nuw nsw i32 %47, %48
%50 = zext i8 %30 to i32
%51 = add nuw nsw i32 %49, %50
%52 = zext i8 %37 to i32
%53 = add nuw nsw i32 %51, %52
%54 = zext i8 %44 to i32
%55 = add nuw nsw i32 %53, %54
%56 = icmp eq i32 %55, 291
br i1 %56, label %57, label %59
57: ; preds = %0
%58 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %59
59: ; preds = %57, %0
ret i32 0
}