#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 */
typedef int GLuint;
typedef int GLfloat;

/* Variables and functions */
long random();
void create_stipple_pattern(GLuint *pat, GLfloat opacity) {
  int x, y;
  long threshold = (float)0x7fffffff * (1. - opacity);
  for (y = 0; y < 32; y++) {
    pat[y] = 0;
    for (x = 0; x < 32; x++) {
      if (random() > threshold)
        pat[y] |= (1 << x);
    }
  }
}


x86 assembly (clang, -O0):
<create_stipple_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xedc(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xec8(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11c5 <create_stipple_pattern+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    11b2 <create_stipple_pattern+0xa2>
mov    $0x0,%al
call   1030 <random@plt>
cmp    -0x20(%rbp),%rax
jle    119f <create_stipple_pattern+0x8f>
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
jmp    11a4 <create_stipple_pattern+0x94>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <create_stipple_pattern+0x5c>
jmp    11b7 <create_stipple_pattern+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <create_stipple_pattern+0x3c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_stipple_pattern>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cvtsi2sd %esi,%xmm0
movsd  0xedd(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xed9(%rip),%xmm1
mov    %rdi,%r14
cvttsd2si %xmm1,%rbx
xor    %r15d,%r15d
jmp    114a <create_stipple_pattern+0x3a>
nopl   0x0(%rax)
add    $0x1,%r15
cmp    $0x20,%r15
je     1183 <create_stipple_pattern+0x73>
movl   $0x0,(%r14,%r15,4)
xor    %ebp,%ebp
jmp    1168 <create_stipple_pattern+0x58>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x20,%ebp
je     1140 <create_stipple_pattern+0x30>
xor    %eax,%eax
call   1030 <random@plt>
cmp    %rbx,%rax
jle    1160 <create_stipple_pattern+0x50>
mov    $0x1,%eax
mov    %ebp,%ecx
shl    %cl,%eax
or     %eax,(%r14,%r15,4)
jmp    1160 <create_stipple_pattern+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @create_stipple_pattern(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = fsub double 1.000000e+00, %9
%11 = fmul double 0x41E0000000000000, %10
%12 = fptosi double %11 to i64
store i64 %12, i64* %7
store i32 0, i32* %6
br label %13
13: ; preds = %42, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 32
br i1 %15, label %16, label %45
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 0, i32* %20
store i32 0, i32* %5
br label %21
21: ; preds = %38, %16
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 32
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = call i64 (...) @random()
%26 = load i64, i64* %7
%27 = icmp sgt i64 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %5
%30 = shl i32 1, %29
%31 = load i32*, i32** %3
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = or i32 %35, %30
store i32 %36, i32* %34
br label %37
37: ; preds = %28, %24
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %21
41: ; preds = %21
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %13
45: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @create_stipple_pattern(i32* nocapture %0, i32 %1) {
%3 = sitofp i32 %1 to double
%4 = fsub double 1.000000e+00, %3
%5 = fmul double %4, 0x41E0000000000000
%6 = fptosi double %5 to i64
br label %7
7: ; preds = %2, %21
%8 = phi i64 [ 0, %2 ], [ %22, %21 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 0, i32* %9
br label %10
10: ; preds = %7, %18
%11 = phi i32 [ 0, %7 ], [ %19, %18 ]
%12 = tail call i64 (...) @random()
%13 = icmp sgt i64 %12, %6
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = shl nuw i32 1, %11
%16 = load i32, i32* %9
%17 = or i32 %16, %15
store i32 %17, i32* %9
br label %18
18: ; preds = %10, %14
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %10
21: ; preds = %18
%22 = add nuw nsw i64 %8, 1
%23 = icmp eq i64 %22, 32
br i1 %23, label %24, label %7
24: ; preds = %21
ret void
}