#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, int);
int /*<<< orphan*/ shuffle(char ***, int);
int /*<<< orphan*/ strcmp(char *, char *);
void unit_test() {
  int ones = 0;
  int twos = 0;
  for (int x = 0; x < 1000; x++) {
    char *test[] = {"1", "2"};
    char **ptrtest = test;
    shuffle(&ptrtest, 2);
    if (!strcmp(test[0], "1")) {
      ones++;
    } else {
      twos++;
    }
  }
  printf("ones: %d, twos: %d", ones, twos);
}


x86 assembly (clang, -O0):
<unit_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    11c9 <unit_test+0x99>
mov    0x2caf(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cac(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x2,%esi
call   1030 <shuffle@plt>
mov    -0x20(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ad <unit_test+0x7d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b6 <unit_test+0x86>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bb <unit_test+0x8b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <unit_test+0x1d>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unit_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %r12d,%r12d
mov    $0x3e8,%ebx
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%r14
lea    0xea9(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
movaps 0x2ca9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r13,0x8(%rsp)
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <shuffle@plt>
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
xor    %edx,%edx
test   %eax,%eax
setne  %cl
sete   %dl
add    %edx,%ebp
add    %ecx,%r12d
add    $0xffffffff,%ebx
jne    1160 <unit_test+0x30>
lea    0xe5c(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"2\00"
@__const.unit_test.test = [2 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [19 x i8] c"ones: %d, twos: %d\00"
define void @unit_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8*]
%5 = alloca i8**
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1000
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = bitcast [2 x i8*]* %4 to i8*
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8** %11, i8*** %5
%12 = call i32 @shuffle(i8*** %5, i32 2)
%13 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %23
20: ; preds = %9
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"2\00"
@__const.unit_test.test = [2 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [19 x i8] c"ones: %d, twos: %d\00"
define void @unit_test() {
%1 = alloca [2 x i8*]
%2 = alloca i8**
%3 = bitcast [2 x i8*]* %1 to i8*
%4 = bitcast i8*** %2 to i8*
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
br label %8
6: ; preds = %8
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %20)
ret void
8: ; preds = %0, %8
%9 = phi i32 [ 0, %0 ], [ %21, %8 ]
%10 = phi i32 [ 0, %0 ], [ %20, %8 ]
%11 = phi i32 [ 0, %0 ], [ %17, %8 ]
store i8** %5, i8*** %2
%12 = call i32 @shuffle(i8*** %2, i32 2)
%13 = load i8*, i8** %5
%14 = call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %11, %16
%18 = xor i1 %15, true
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %10, %19
%21 = add nuw nsw i32 %9, 1
%22 = icmp eq i32 %21, 1000
br i1 %22, label %6, label %8
}