#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 drv_CF_scan_DOW(int);
int /*<<< orphan*/ drv_CF_send(int, int, unsigned char *);
void drv_CF_start_2(void) {
  int i;
  unsigned long mask;
  unsigned char buffer[4];
  drv_CF_send(6, 0, NULL);
  buffer[0] = 0;
  drv_CF_send(12, 1, buffer);
  buffer[0] = 15;
  drv_CF_send(16, 1, buffer);
  buffer[0] = buffer[1] = buffer[2] = buffer[3] = 100;
  drv_CF_send(17, 4, buffer);
  mask = 0;
  for (i = 0; i < 32; i++) {
    if (drv_CF_scan_DOW(i) == 1) {
      mask |= 1 << i;
    }
  }
  buffer[0] = mask & 0xff;
  buffer[1] = (mask >> 8) & 0xff;
  buffer[2] = (mask >> 16) & 0xff;
  buffer[3] = (mask >> 24) & 0xff;
  drv_CF_send(19, 4, buffer);
}


x86 assembly (clang, -O0):
<drv_CF_start_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x6,%edi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <drv_CF_send@plt>
movb   $0x0,-0x14(%rbp)
lea    -0x14(%rbp),%rdx
mov    $0xc,%edi
mov    $0x1,%esi
call   1040 <drv_CF_send@plt>
movb   $0xf,-0x14(%rbp)
lea    -0x14(%rbp),%rdx
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <drv_CF_send@plt>
movb   $0x64,-0x11(%rbp)
movb   $0x64,-0x12(%rbp)
movb   $0x64,-0x13(%rbp)
movb   $0x64,-0x14(%rbp)
lea    -0x14(%rbp),%rdx
mov    $0x11,%edi
mov    $0x4,%esi
call   1040 <drv_CF_send@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    11da <drv_CF_start_2+0xba>
mov    -0x4(%rbp),%edi
call   1030 <drv_CF_scan_DOW@plt>
cmp    $0x1,%eax
jne    11c7 <drv_CF_start_2+0xa7>
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11cc <drv_CF_start_2+0xac>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <drv_CF_start_2+0x78>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x14(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,-0x11(%rbp)
lea    -0x14(%rbp),%rdx
mov    $0x13,%edi
mov    $0x4,%esi
call   1040 <drv_CF_send@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_CF_start_2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
mov    $0x6,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <drv_CF_send@plt>
movb   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    $0xc,%edi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <drv_CF_send@plt>
movb   $0xf,0xc(%rsp)
mov    $0x10,%edi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <drv_CF_send@plt>
movl   $0x64646464,0xc(%rsp)
64
mov    $0x11,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1040 <drv_CF_send@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <drv_CF_scan_DOW@plt>
mov    $0x1,%edx
mov    %ebx,%ecx
shl    %cl,%edx
cmp    $0x1,%eax
cmovne %r14d,%edx
or     %rdx,%r15
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1190 <drv_CF_start_2+0x70>
mov    %r15d,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    $0x13,%edi
mov    $0x4,%esi
call   1040 <drv_CF_send@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @drv_CF_start_2() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [4 x i8]
%4 = call i32 @drv_CF_send(i32 6, i32 0, i8* null)
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 0, i8* %5
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = call i32 @drv_CF_send(i32 12, i32 1, i8* %6)
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 15, i8* %8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%10 = call i32 @drv_CF_send(i32 16, i32 1, i8* %9)
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 100, i8* %11
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 100, i8* %12
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 100, i8* %13
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 100, i8* %14
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%16 = call i32 @drv_CF_send(i32 17, i32 4, i8* %15)
store i64 0, i64* %2
store i32 0, i32* %1
br label %17
17: ; preds = %31, %0
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i32, i32* %1
%22 = call i32 @drv_CF_scan_DOW(i32 %21)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %1
%26 = shl i32 1, %25
%27 = sext i32 %26 to i64
%28 = load i64, i64* %2
%29 = or i64 %28, %27
store i64 %29, i64* %2
br label %30
30: ; preds = %24, %20
br label %31
31: ; preds = %30
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %17
34: ; preds = %17
%35 = load i64, i64* %2
%36 = and i64 %35, 255
%37 = trunc i64 %36 to i8
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 %37, i8* %38
%39 = load i64, i64* %2
%40 = lshr i64 %39, 8
%41 = and i64 %40, 255
%42 = trunc i64 %41 to i8
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %42, i8* %43
%44 = load i64, i64* %2
%45 = lshr i64 %44, 16
%46 = and i64 %45, 255
%47 = trunc i64 %46 to i8
%48 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %47, i8* %48
%49 = load i64, i64* %2
%50 = lshr i64 %49, 24
%51 = and i64 %50, 255
%52 = trunc i64 %51 to i8
%53 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %52, i8* %53
%54 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%55 = call i32 @drv_CF_send(i32 19, i32 4, i8* %54)
ret void
}

LLVM IR (-O2):
define void @drv_CF_start_2() {
%1 = alloca i32
%2 = bitcast i32* %1 to [4 x i8]*
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @drv_CF_send(i32 6, i32 0, i8* null)
store i8 0, i8* %3
%5 = call i32 @drv_CF_send(i32 12, i32 1, i8* %3)
store i8 15, i8* %3
%6 = call i32 @drv_CF_send(i32 16, i32 1, i8* %3)
store i32 1684300900, i32* %1
%7 = call i32 @drv_CF_send(i32 17, i32 4, i8* %3)
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %16, %8 ]
%10 = phi i32 [ 0, %0 ], [ %17, %8 ]
%11 = call i32 @drv_CF_scan_DOW(i32 %10)
%12 = icmp eq i32 %11, 1
%13 = shl nuw i32 1, %10
%14 = select i1 %12, i32 %13, i32 0
%15 = zext i32 %14 to i64
%16 = or i64 %9, %15
%17 = add nuw nsw i32 %10, 1
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %8
19: ; preds = %8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%23 = trunc i64 %16 to i8
store i8 %23, i8* %3
%24 = lshr i64 %16, 8
%25 = trunc i64 %24 to i8
store i8 %25, i8* %20
%26 = lshr i64 %16, 16
%27 = trunc i64 %26 to i8
store i8 %27, i8* %21
%28 = lshr i64 %16, 24
%29 = trunc i64 %28 to i8
store i8 %29, i8* %22
%30 = call i32 @drv_CF_send(i32 19, i32 4, i8* %3)
ret void
}