#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 rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int initial_rand_pos(int max) {
  int b;
  srand((unsigned int)(time(NULL) + (rand() % 100)));
  b = (rand() % max) + 1;
  while (b == max || b == max - 1 || b == 0 || b == max / 2 ||
         b == (max + 1) / 2) {
    b = (rand() % max) + 1;
  }
  return b;
}


x86 assembly (clang, -O0):
<initial_rand_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq %edx,%rcx
add    %rcx,%rax
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x4(%rbp)
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0x11(%rbp)
je     11ed <initial_rand_pos+0xbd>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%edx
sub    $0x1,%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
je     11ed <initial_rand_pos+0xbd>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ed <initial_rand_pos+0xbd>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
je     11ed <initial_rand_pos+0xbd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11fd <initial_rand_pos+0xcd>
jmp    1213 <initial_rand_pos+0xe3>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x4(%rbp)
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
jmp    1179 <initial_rand_pos+0x49>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_rand_pos>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%r14d
mov    %r14d,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x1(%rbx),%ecx
shr    $0x1f,%ecx
lea    (%rbx,%rcx,1),%r14d
add    $0x1,%r14d
sar    %r14d
lea    -0x1(%rbx),%r15d
mov    %ebx,%ebp
shr    $0x1f,%ebp
add    %ebx,%ebp
sar    %ebp
jmp    11a7 <initial_rand_pos+0x77>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebx
add    $0x1,%edx
cmp    %ebx,%edx
je     11a0 <initial_rand_pos+0x70>
cmp    %ebp,%edx
je     11a0 <initial_rand_pos+0x70>
cmp    %r15d,%edx
je     11a0 <initial_rand_pos+0x70>
test   %edx,%edx
je     11a0 <initial_rand_pos+0x70>
cmp    %r14d,%edx
je     11a0 <initial_rand_pos+0x70>
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @initial_rand_pos(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i64 @time(i32* null)
%5 = call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = sext i32 %6 to i64
%8 = add nsw i64 %4, %7
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = load i32, i32* %2
%13 = srem i32 %11, %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %15
15: ; preds = %40, %1
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp eq i32 %16, %17
br i1 %18, label %38, label %19
19: ; preds = %15
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br i1 %23, label %38, label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %38, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = sdiv i32 %29, 2
%31 = icmp eq i32 %28, %30
br i1 %31, label %38, label %32
32: ; preds = %27
%33 = load i32, i32* %3
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
%36 = sdiv i32 %35, 2
%37 = icmp eq i32 %33, %36
br label %38
38: ; preds = %32, %27, %24, %19, %15
%39 = phi i1 [ true, %27 ], [ true, %24 ], [ true, %19 ], [ true, %15 ], [ %37, %32 ]
br i1 %39, label %40, label %45
40: ; preds = %38
%41 = call i32 (...) @rand()
%42 = load i32, i32* %2
%43 = srem i32 %41, %42
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %15
45: ; preds = %38
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @initial_rand_pos(i32 %0) {
%2 = tail call i64 @time(i32* null)
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100
%5 = trunc i64 %2 to i32
%6 = add i32 %4, %5
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 (...) @rand()
%9 = add nsw i32 %0, 1
%10 = sdiv i32 %9, 2
%11 = add nsw i32 %0, -1
%12 = sdiv i32 %0, 2
br label %13
13: ; preds = %26, %1
%14 = phi i32 [ %8, %1 ], [ %27, %26 ]
%15 = srem i32 %14, %0
%16 = add nsw i32 %15, 1
%17 = icmp eq i32 %16, %0
br i1 %17, label %26, label %18
18: ; preds = %13
%19 = icmp eq i32 %16, %11
%20 = icmp eq i32 %16, 0
%21 = or i1 %19, %20
%22 = icmp eq i32 %16, %12
%23 = or i1 %22, %21
%24 = icmp eq i32 %16, %10
%25 = select i1 %23, i1 true, i1 %24
br i1 %25, label %26, label %28
26: ; preds = %13, %18
%27 = tail call i32 (...) @rand()
br label %13
28: ; preds = %18
ret i32 %16
}