#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*/ setbits(unsigned int, unsigned int, int, int);
int main() {
  unsigned int x, y;
  int p, n;
  for (x = 0; x < 30000; x += 511) {
    for (y = 0; y < 1000; y += 37) {
      for (p = 0; p < 16; p++) {
        for (n = 1; n <= p + 1; n++) {
          setbits(x, y, p, n);
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x7530,-0x8(%rbp)
jae    11ca <main+0xba>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jae    11b5 <main+0xa5>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    11a2 <main+0x92>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     118f <main+0x7f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <setbits@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <main+0x4f>
jmp    1194 <main+0x84>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <main+0x3e>
jmp    11a7 <main+0x97>
mov    -0xc(%rbp),%eax
add    $0x25,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <main+0x2a>
jmp    11ba <main+0xaa>
mov    -0x8(%rbp),%eax
add    $0x1ff,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r12d,%r12d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <setbits@plt>
lea    (%r12,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x2,%eax
jne    1150 <main+0x40>
add    $0x1,%ebp
add    $0xffffffff,%r12d
cmp    $0x10,%ebp
jne    1140 <main+0x30>
lea    0x25(%r15),%eax
cmp    $0x3c3,%r15d
mov    %eax,%r15d
jb     1130 <main+0x20>
lea    0x1ff(%r14),%eax
cmp    $0x7331,%r14d
mov    %eax,%r14d
jb     1120 <main+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %41, %0
%7 = load i32, i32* %2
%8 = icmp ult i32 %7, 30000
br i1 %8, label %9, label %44
9: ; preds = %6
store i32 0, i32* %3
br label %10
10: ; preds = %37, %9
%11 = load i32, i32* %3
%12 = icmp ult i32 %11, 1000
br i1 %12, label %13, label %40
13: ; preds = %10
store i32 0, i32* %4
br label %14
14: ; preds = %33, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 16
br i1 %16, label %17, label %36
17: ; preds = %14
store i32 1, i32* %5
br label %18
18: ; preds = %29, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 @setbits(i32 %24, i32 %25, i32 %26, i32 %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %18
32: ; preds = %18
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %14
36: ; preds = %14
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add i32 %38, 37
store i32 %39, i32* %3
br label %10
40: ; preds = %10
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add i32 %42, 511
store i32 %43, i32* %2
br label %6
44: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %20
%2 = phi i32 [ 0, %0 ], [ %21, %20 ]
br label %3
3: ; preds = %1, %17
%4 = phi i32 [ 0, %1 ], [ %18, %17 ]
br label %9
5: ; preds = %12
%6 = add nuw nsw i32 %11, 1
%7 = add nuw nsw i32 %10, 1
%8 = icmp eq i32 %6, 16
br i1 %8, label %17, label %9
9: ; preds = %3, %5
%10 = phi i32 [ 2, %3 ], [ %7, %5 ]
%11 = phi i32 [ 0, %3 ], [ %6, %5 ]
br label %12
12: ; preds = %9, %12
%13 = phi i32 [ 1, %9 ], [ %15, %12 ]
%14 = tail call i32 @setbits(i32 %2, i32 %4, i32 %11, i32 %13)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, %10
br i1 %16, label %5, label %12
17: ; preds = %5
%18 = add nuw nsw i32 %4, 37
%19 = icmp ult i32 %4, 963
br i1 %19, label %3, label %20
20: ; preds = %17
%21 = add nuw nsw i32 %2, 511
%22 = icmp ult i32 %2, 29489
br i1 %22, label %1, label %23
23: ; preds = %20
ret i32 0
}