#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 */
struct file {
  int dummy;
};

/* Variables and functions */
unsigned long getnum(char const *);
int /*<<< orphan*/ op_sync();
int /*<<< orphan*/ prep(unsigned int, unsigned int *, unsigned int, int,
                        struct file **);
int random();
scalar_t__ randop(unsigned int, unsigned int *, unsigned int, int,
                  struct file **);
int /*<<< orphan*/ srandom(unsigned long);
void wl_genseq(const char *seed) {
  unsigned testcode = 358;
  unsigned numfiles = 27;
  unsigned exists[27];
  struct file *files[27];
  unsigned ct, numops;
  unsigned long seednum = getnum(seed);
  srandom(seednum);
  prep(testcode, exists, numfiles, 1, files);
  op_sync();
  numops = random() % 100 + 100;
  ct = 0;
  while (ct < numops) {
    if (randop(testcode, exists, numfiles, 1, files)) {
      ct++;
    }
  }
}


x86 assembly (clang, -O0):
<wl_genseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x166,-0xc(%rbp)
movl   $0x1b,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getnum@plt>
mov    %rax,-0x170(%rbp)
mov    -0x170(%rbp),%rdi
call   1050 <srandom@plt>
mov    -0xc(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    -0x10(%rbp),%edx
lea    -0x160(%rbp),%r8
mov    $0x1,%ecx
call   1060 <prep@plt>
mov    $0x0,%al
call   1070 <op_sync@plt>
mov    $0x0,%al
call   1080 <random@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0x168(%rbp)
movl   $0x0,-0x164(%rbp)
mov    -0x164(%rbp),%eax
cmp    -0x168(%rbp),%eax
jae    1228 <wl_genseq+0xc8>
mov    -0xc(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    -0x10(%rbp),%edx
lea    -0x160(%rbp),%r8
mov    $0x1,%ecx
call   1040 <randop@plt>
cmp    $0x0,%rax
je     1223 <wl_genseq+0xc3>
mov    -0x164(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x164(%rbp)
jmp    11dd <wl_genseq+0x7d>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wl_genseq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x148,%rsp
call   1030 <getnum@plt>
mov    %rax,%rdi
call   1050 <srandom@plt>
mov    %rsp,%r14
lea    0x70(%rsp),%r15
mov    $0x166,%edi
mov    %r14,%rsi
mov    $0x1b,%edx
mov    $0x1,%ecx
mov    %r15,%r8
call   1060 <prep@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <op_sync@plt>
xor    %eax,%eax
call   1080 <random@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x64,%ebx
nopl   (%rax)
mov    $0x166,%edi
mov    %r14,%rsi
mov    $0x1b,%edx
mov    $0x1,%ecx
mov    %r15,%r8
call   1040 <randop@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
cmp    %ebx,%ebp
jb     11d0 <wl_genseq+0x70>
add    $0x148,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.file = type { i32 }
define void @wl_genseq(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [27 x i32]
%6 = alloca [27 x %struct.file*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i8* %0, i8** %2
store i32 358, i32* %3
store i32 27, i32* %4
%10 = load i8*, i8** %2
%11 = call i64 @getnum(i8* %10)
store i64 %11, i64* %9
%12 = load i64, i64* %9
%13 = call i32 @srandom(i64 %12)
%14 = load i32, i32* %3
%15 = getelementptr inbounds [27 x i32], [27 x i32]* %5, i64 0, i64 0
%16 = load i32, i32* %4
%17 = getelementptr inbounds [27 x %struct.file*], [27 x %struct.file*]* %6, i64 0, i64 0
%18 = call i32 @prep(i32 %14, i32* %15, i32 %16, i32 1, %struct.file** %17)
%19 = call i32 (...) @op_sync()
%20 = call i32 (...) @random()
%21 = srem i32 %20, 100
%22 = add nsw i32 %21, 100
store i32 %22, i32* %8
store i32 0, i32* %7
br label %23
23: ; preds = %37, %1
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %3
%29 = getelementptr inbounds [27 x i32], [27 x i32]* %5, i64 0, i64 0
%30 = load i32, i32* %4
%31 = getelementptr inbounds [27 x %struct.file*], [27 x %struct.file*]* %6, i64 0, i64 0
%32 = call i64 @randop(i32 %28, i32* %29, i32 %30, i32 1, %struct.file** %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* %7
%36 = add i32 %35, 1
store i32 %36, i32* %7
br label %37
37: ; preds = %34, %27
br label %23
38: ; preds = %23
ret void
}

LLVM IR (-O2):
%struct.file = type { i32 }
define void @wl_genseq(i8* %0) {
%2 = alloca [27 x i32]
%3 = alloca [27 x %struct.file*]
%4 = bitcast [27 x i32]* %2 to i8*
%5 = bitcast [27 x %struct.file*]* %3 to i8*
%6 = tail call i64 @getnum(i8* %0)
%7 = tail call i32 @srandom(i64 %6)
%8 = getelementptr inbounds [27 x i32], [27 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [27 x %struct.file*], [27 x %struct.file*]* %3, i64 0, i64 0
%10 = call i32 @prep(i32 358, i32* %8, i32 27, i32 1, %struct.file** %9)
%11 = call i32 (...) @op_sync()
%12 = call i32 (...) @random()
%13 = srem i32 %12, 100
%14 = add nsw i32 %13, 100
br label %15
15: ; preds = %1, %15
%16 = phi i32 [ %20, %15 ], [ 0, %1 ]
%17 = call i64 @randop(i32 358, i32* %8, i32 27, i32 1, %struct.file** %9)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = add nuw i32 %16, %19
%21 = icmp ult i32 %20, %14
br i1 %21, label %15, label %22
22: ; preds = %15
ret void
}