int divisible(long n) {
  int i;
  for (i = 2; i < 21; ++i)
    if (n % i != 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<divisible>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
cmpl   $0x15,-0x14(%rbp)
jge    114f <divisible+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     113c <divisible+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1156 <divisible+0x56>
jmp    1141 <divisible+0x41>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <divisible+0xf>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<divisible>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    %ebx,%ecx
and    $0x1,%ecx
movabs $0x5555555555555556,%rdx
55 55 55
mov    %rdi,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
lea    (%rax,%rax,2),%rax
mov    %rdi,%rsi
sub    %rax,%rsi
and    $0x3,%edi
or     %rcx,%rdi
movabs $0x6666666666666667,%rdx
66 66 66
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%r8
or     %rsi,%rdi
mov    %rdx,%rax
sar    %rax
mov    %rdx,%r9
shr    $0x3f,%r9
add    %r9,%rax
lea    (%rax,%rax,4),%rax
mov    %rbx,%rcx
sub    %rax,%rcx
or     %rdi,%rcx
movabs $0x2aaaaaaaaaaaaaab,%rdx
aa aa 2a
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rdi
mov    %rdx,%r11
shr    $0x3f,%r11
lea    (%rdx,%r11,1),%rax
add    %rax,%rax
lea    (%rax,%rax,2),%rax
mov    %rbx,%r15
sub    %rax,%r15
movabs $0x4924924924924925,%rdx
92 24 49
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%r14
mov    %rdx,%rsi
sar    %rsi
mov    %rdx,%r10
shr    $0x3f,%r10
add    %r10,%rsi
lea    0x0(,%rsi,8),%rax
sub    %rax,%rsi
add    %rbx,%rsi
or     %r15,%rsi
or     %rcx,%rsi
mov    %ebx,%ecx
and    $0x7,%ecx
movabs $0x1c71c71c71c71c72,%rdx
c7 71 1c
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
lea    (%rax,%rax,8),%rax
mov    %rbx,%rdx
sub    %rax,%rdx
or     %rcx,%rdx
mov    %r8,%rax
sar    $0x2,%rax
add    %r9,%rax
add    %rax,%rax
lea    (%rax,%rax,4),%rax
mov    %rbx,%rcx
sub    %rax,%rcx
or     %rdx,%rcx
movabs $0x2e8ba2e8ba2e8ba3,%rdx
a2 8b 2e
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    %rdx
add    %rax,%rdx
lea    (%rdx,%rdx,4),%rax
lea    (%rdx,%rax,2),%rax
mov    %rbx,%r15
sub    %rax,%r15
or     %rcx,%r15
or     %rsi,%r15
shr    %rdi
add    %r11,%rdi
shl    $0x2,%rdi
lea    (%rdi,%rdi,2),%rax
mov    %rbx,%rcx
sub    %rax,%rcx
movabs $0x4ec4ec4ec4ec4ec5,%rdx
ec c4 4e
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,2),%rax
lea    (%rdx,%rax,4),%rax
mov    %rbx,%rsi
sub    %rax,%rsi
or     %rcx,%rsi
sar    $0x2,%r14
add    %r10,%r14
mov    %r14,%rax
shl    $0x4,%rax
mov    %r14,%rcx
sub    %rax,%rcx
add    %r14,%rcx
add    %rbx,%rcx
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rbx,%rax
imul   %rdx
or     %rsi,%rcx
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x3,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,4),%rax
lea    (%rax,%rax,2),%rax
mov    %rbx,%rsi
sub    %rax,%rsi
or     %rcx,%rsi
or     %r15,%rsi
mov    %ebx,%ecx
and    $0xf,%ecx
movabs $0x7878787878787879,%rdx
78 78 78
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x3,%rdx
add    %rax,%rdx
mov    %rdx,%rax
shl    $0x4,%rax
add    %rdx,%rax
mov    %rbx,%rdi
sub    %rax,%rdi
or     %rcx,%rdi
movabs $0xe38e38e38e38e39,%rcx
e3 38 0e
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
add    %rax,%rax
lea    (%rax,%rax,8),%rax
mov    %rbx,%rcx
sub    %rax,%rcx
movabs $0xd79435e50d79436,%rdx
43 79 0d
mov    %rbx,%rax
imul   %rdx
or     %rdi,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
lea    (%rax,%rax,8),%rdx
lea    (%rax,%rdx,2),%rax
mov    %rbx,%rdx
sub    %rax,%rdx
or     %rcx,%rdx
or     %rsi,%rdx
sar    $0x3,%r8
add    %r9,%r8
shl    $0x2,%r8
lea    (%r8,%r8,4),%rax
sub    %rax,%rbx
xor    %eax,%eax
or     %rdx,%rbx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @divisible(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 2, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 21
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i64, i64* %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = srem i64 %9, %11
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %8
store i32 0, i32* %2
br label %20
15: ; preds = %8
br label %16
16: ; preds = %15
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %5
19: ; preds = %5
store i32 1, i32* %2
br label %20
20: ; preds = %19, %14
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @divisible(i64 %0) {
%2 = and i64 %0, 1
%3 = srem i64 %0, 3
%4 = or i64 %2, %3
%5 = and i64 %0, 3
%6 = or i64 %4, %5
%7 = srem i64 %0, 5
%8 = or i64 %6, %7
%9 = srem i64 %0, 6
%10 = or i64 %8, %9
%11 = srem i64 %0, 7
%12 = or i64 %10, %11
%13 = and i64 %0, 7
%14 = or i64 %12, %13
%15 = srem i64 %0, 9
%16 = or i64 %14, %15
%17 = srem i64 %0, 10
%18 = or i64 %16, %17
%19 = srem i64 %0, 11
%20 = or i64 %18, %19
%21 = srem i64 %0, 12
%22 = or i64 %20, %21
%23 = srem i64 %0, 13
%24 = or i64 %22, %23
%25 = srem i64 %0, 14
%26 = or i64 %24, %25
%27 = srem i64 %0, 15
%28 = or i64 %26, %27
%29 = and i64 %0, 15
%30 = or i64 %28, %29
%31 = srem i64 %0, 17
%32 = or i64 %30, %31
%33 = srem i64 %0, 18
%34 = or i64 %32, %33
%35 = srem i64 %0, 19
%36 = or i64 %34, %35
%37 = srem i64 %0, 20
%38 = or i64 %36, %37
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
ret i32 %40
}