#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*/ fprintf(int /*<<< orphan*/, char *, unsigned long);
int /*<<< orphan*/ stderr;
void runtest(void (*func)(unsigned long, unsigned long *, unsigned long *,
                          unsigned int *)) {
  unsigned long bitpos, modval, value;
  unsigned int cc;
  int i;
  value = 0;
  func(value, &bitpos, &modval, &cc);
  if (modval != 0)
    fprintf(stderr, "modval is wrong for %lx\n", value);
  if (bitpos != 64)
    fprintf(stderr, "bitpos is wrong for %lx\n", value);
  if (cc != 0)
    fprintf(stderr, "cc is wrong for %lx\n", value);
  for (i = 0; i < 64; ++i) {
    value = 1ull << i;
    func(value, &bitpos, &modval, &cc);
    if (modval != 0)
      fprintf(stderr, "modval is wrong for %lx\n", value);
    if (bitpos != 63 - i)
      fprintf(stderr, "bitpos is wrong for %lx\n", value);
    if (cc != 2)
      fprintf(stderr, "cc is wrong for %lx\n", value);
  }
  for (i = 1; i < 64; ++i) {
    value = 1ull << i;
    value = value | (value - 1);
    func(value, &bitpos, &modval, &cc);
    if (modval != (value >> 1))
      fprintf(stderr, "modval is wrong for %lx\n", value);
    if (bitpos != 63 - i)
      fprintf(stderr, "bitpos is wrong for %lx\n", value);
    if (cc != 2)
      fprintf(stderr, "cc is wrong for %lx\n", value);
  }
}


x86 assembly (clang, -O0):
<runtest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   *%rax
cmpq   $0x0,-0x18(%rbp)
je     115e <runtest+0x4e>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xea7(%rip),%rsi
call   1030 <fprintf@plt>
cmpq   $0x40,-0x10(%rbp)
je     1182 <runtest+0x72>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe9c(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     11a5 <runtest+0x95>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe92(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x40,-0x28(%rbp)
jge    1268 <runtest+0x158>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   *%rax
cmpq   $0x0,-0x18(%rbp)
je     1201 <runtest+0xf1>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe04(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    $0x3f,%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
je     1232 <runtest+0x122>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdec(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x2,-0x24(%rbp)
je     1255 <runtest+0x145>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xde2(%rip),%rsi
call   1030 <fprintf@plt>
jmp    125a <runtest+0x14a>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ac <runtest+0x9c>
movl   $0x1,-0x28(%rbp)
cmpl   $0x40,-0x28(%rbp)
jge    1348 <runtest+0x238>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   *%rax
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
je     12e1 <runtest+0x1d1>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd24(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    $0x3f,%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
je     1312 <runtest+0x202>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd0c(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x2,-0x24(%rbp)
je     1335 <runtest+0x225>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd02(%rip),%rsi
call   1030 <fprintf@plt>
jmp    133a <runtest+0x22a>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    126f <runtest+0x15f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runtest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %edi,%edi
call   *%r14
cmpq   $0x0,0x8(%rsp)
je     1154 <runtest+0x44>
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
xor    %edx,%edx
call   1030 <fprintf@plt>
cmpq   $0x40,0x10(%rsp)
je     1173 <runtest+0x63>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
xor    %edx,%edx
call   1030 <fprintf@plt>
cmpl   $0x0,0x4(%rsp)
je     1191 <runtest+0x81>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
xor    %edx,%edx
call   1030 <fprintf@plt>
mov    $0x3f,%r12d
xor    %ebx,%ebx
lea    0x4(%rsp),%r13
mov    0x2e3b(%rip),%r15
jmp    11ba <runtest+0xaa>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r12
jae    1225 <runtest+0x115>
mov    $0x1,%ebp
mov    %ebx,%ecx
shl    %cl,%rbp
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r13,%rcx
call   *%r14
cmpq   $0x0,0x8(%rsp)
je     11f1 <runtest+0xe1>
mov    (%r15),%edi
lea    0xe17(%rip),%rsi
mov    %rbp,%rdx
call   1030 <fprintf@plt>
cmp    0x10(%rsp),%r12
je     120a <runtest+0xfa>
mov    (%r15),%edi
lea    0xe17(%rip),%rsi
mov    %rbp,%rdx
call   1030 <fprintf@plt>
cmpl   $0x2,0x4(%rsp)
je     11b0 <runtest+0xa0>
mov    (%r15),%edi
lea    0xe17(%rip),%rsi
mov    %rbp,%rdx
call   1030 <fprintf@plt>
jmp    11b0 <runtest+0xa0>
mov    $0x3e,%ebx
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%rbp
jmp    124a <runtest+0x13a>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
jae    12dd <runtest+0x1cd>
mov    $0xffffffffffffffff,%r13
mov    %ebx,%ecx
shr    %cl,%r13
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
call   *%r14
mov    %r13,%rax
shr    %rax
cmp    %rax,0x8(%rsp)
jne    1290 <runtest+0x180>
cmp    0x10(%rsp),%rbx
jne    12a9 <runtest+0x199>
cmpl   $0x2,0x4(%rsp)
je     1240 <runtest+0x130>
jmp    12c6 <runtest+0x1b6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
lea    0xd66(%rip),%rsi
mov    %r13,%rdx
call   1030 <fprintf@plt>
cmp    0x10(%rsp),%rbx
je     127b <runtest+0x16b>
mov    (%r15),%edi
lea    0xd66(%rip),%rsi
mov    %r13,%rdx
call   1030 <fprintf@plt>
cmpl   $0x2,0x4(%rsp)
je     1240 <runtest+0x130>
mov    (%r15),%edi
lea    0xd62(%rip),%rsi
mov    %r13,%rdx
call   1030 <fprintf@plt>
jmp    1240 <runtest+0x130>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"modval is wrong for %lx\0A\00"
@.str.1 = [25 x i8] c"bitpos is wrong for %lx\0A\00"
@.str.2 = [21 x i8] c"cc is wrong for %lx\0A\00"
define void @runtest(void (i64, i64*, i64*, i32*)* %0) {
%2 = alloca void (i64, i64*, i64*, i32*)*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store void (i64, i64*, i64*, i32*)* %0, void (i64, i64*, i64*, i32*)** %2
store i64 0, i64* %5
%8 = load void (i64, i64*, i64*, i32*)*, void (i64, i64*, i64*, i32*)** %2
%9 = load i64, i64* %5
%10 = load i64, i64* %4
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i64, i64* %5
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %14)
br label %16
16: ; preds = %12, %1
%17 = load i64, i64* %3
%18 = icmp ne i64 %17, 64
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = load i64, i64* %5
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %21)
br label %23
23: ; preds = %19, %16
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i64, i64* %5
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %28)
br label %30
30: ; preds = %26, %23
store i32 0, i32* %7
br label %31
31: ; preds = %64, %30
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 64
br i1 %33, label %34, label %67
34: ; preds = %31
%35 = load i32, i32* %7
%36 = zext i32 %35 to i64
%37 = shl i64 1, %36
store i64 %37, i64* %5
%38 = load void (i64, i64*, i64*, i32*)*, void (i64, i64*, i64*, i32*)** %2
%39 = load i64, i64* %5
%40 = load i64, i64* %4
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = load i64, i64* %5
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %44)
br label %46
46: ; preds = %42, %34
%47 = load i64, i64* %3
%48 = load i32, i32* %7
%49 = sub nsw i32 63, %48
%50 = sext i32 %49 to i64
%51 = icmp ne i64 %47, %50
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i32, i32* @stderr
%54 = load i64, i64* %5
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %54)
br label %56
56: ; preds = %52, %46
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 2
br i1 %58, label %59, label %63
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = load i64, i64* %5
%62 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %61)
br label %63
63: ; preds = %59, %56
br label %64
64: ; preds = %63
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %31
67: ; preds = %31
store i32 1, i32* %7
br label %68
68: ; preds = %107, %67
%69 = load i32, i32* %7
%70 = icmp slt i32 %69, 64
br i1 %70, label %71, label %110
71: ; preds = %68
%72 = load i32, i32* %7
%73 = zext i32 %72 to i64
%74 = shl i64 1, %73
store i64 %74, i64* %5
%75 = load i64, i64* %5
%76 = load i64, i64* %5
%77 = sub i64 %76, 1
%78 = or i64 %75, %77
store i64 %78, i64* %5
%79 = load void (i64, i64*, i64*, i32*)*, void (i64, i64*, i64*, i32*)** %2
%80 = load i64, i64* %5
%81 = load i64, i64* %4
%82 = load i64, i64* %5
%83 = lshr i64 %82, 1
%84 = icmp ne i64 %81, %83
br i1 %84, label %85, label %89
85: ; preds = %71
%86 = load i32, i32* @stderr
%87 = load i64, i64* %5
%88 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %87)
br label %89
89: ; preds = %85, %71
%90 = load i64, i64* %3
%91 = load i32, i32* %7
%92 = sub nsw i32 63, %91
%93 = sext i32 %92 to i64
%94 = icmp ne i64 %90, %93
br i1 %94, label %95, label %99
95: ; preds = %89
%96 = load i32, i32* @stderr
%97 = load i64, i64* %5
%98 = call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %97)
br label %99
99: ; preds = %95, %89
%100 = load i32, i32* %6
%101 = icmp ne i32 %100, 2
br i1 %101, label %102, label %106
102: ; preds = %99
%103 = load i32, i32* @stderr
%104 = load i64, i64* %5
%105 = call i32 @fprintf(i32 %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %104)
br label %106
106: ; preds = %102, %99
br label %107
107: ; preds = %106
%108 = load i32, i32* %7
%109 = add nsw i32 %108, 1
store i32 %109, i32* %7
br label %68
110: ; preds = %68
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"modval is wrong for %lx\0A\00"
@.str.1 = [25 x i8] c"bitpos is wrong for %lx\0A\00"
@.str.2 = [21 x i8] c"cc is wrong for %lx\0A\00"
define void @runtest(void (i64, i64*, i64*, i32*)* nocapture %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 0)
br label %13
13: ; preds = %10, %1
%14 = load i64, i64* %2
%15 = icmp eq i64 %14, 64
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 0)
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 0)
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25, %47
%27 = phi i64 [ %48, %47 ], [ 0, %25 ]
%28 = shl nuw i64 1, %27
%29 = load i64, i64* %3
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %28)
br label %34
34: ; preds = %31, %26
%35 = load i64, i64* %2
%36 = sub nuw nsw i64 63, %27
%37 = icmp eq i64 %35, %36
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %28)
br label %41
41: ; preds = %38, %34
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 2
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %28)
br label %47
47: ; preds = %41, %44
%48 = add nuw nsw i64 %27, 1
%49 = icmp eq i64 %48, 64
br i1 %49, label %50, label %26
50: ; preds = %47, %72
%51 = phi i64 [ %73, %72 ], [ 1, %47 ]
%52 = sub nuw nsw i64 63, %51
%53 = lshr i64 -1, %52
%54 = load i64, i64* %3
%55 = lshr i64 %53, 1
%56 = icmp eq i64 %54, %55
br i1 %56, label %60, label %57
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %53)
br label %60
60: ; preds = %57, %50
%61 = load i64, i64* %2
%62 = icmp eq i64 %61, %52
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %53)
br label %66
66: ; preds = %63, %60
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 2
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %53)
br label %72
72: ; preds = %66, %69
%73 = add nuw nsw i64 %51, 1
%74 = icmp eq i64 %73, 64
br i1 %74, label %75, label %50
75: ; preds = %72
ret void
}