#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 mod(int, int);
int diatonic(int p) {
  int s[7] = {0, 2, 4, 5, 7, 9, 11}, i;
  for (i = 0; i < 7; i++)
    if (mod(p, 12) == s[i])
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<diatonic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed6(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x7,-0x34(%rbp)
jge    1190 <diatonic+0x80>
mov    -0x8(%rbp),%edi
mov    $0xc,%esi
call   1030 <mod@plt>
movslq -0x34(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jne    117d <diatonic+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    1197 <diatonic+0x87>
jmp    1182 <diatonic+0x72>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114c <diatonic+0x3c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diatonic>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0xc,%esi
call   1030 <mod@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
cmp    $0x2,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
cmp    $0x4,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
cmp    $0x5,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
cmp    $0x7,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
cmp    $0x9,%eax
je     1191 <diatonic+0x81>
mov    %ebp,%edi
mov    $0xc,%esi
call   1030 <mod@plt>
xor    %ebx,%ebx
cmp    $0xb,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.diatonic.s = [7 x i32] [i32 0, i32 2, i32 4, i32 5, i32 7, i32 9, i32 11]
define i32 @diatonic(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i32]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [7 x i32]* %4 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 7
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i32, i32* %3
%12 = call i32 @mod(i32 %11, i32 12)
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %12, %16
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 1, i32* %2
br label %24
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %7
23: ; preds = %7
store i32 0, i32* %2
br label %24
24: ; preds = %23, %18
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @diatonic(i32 %0) {
%2 = tail call i32 @mod(i32 %0, i32 12)
%3 = icmp eq i32 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = tail call i32 @mod(i32 %0, i32 12)
%6 = icmp eq i32 %5, 2
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = tail call i32 @mod(i32 %0, i32 12)
%9 = icmp eq i32 %8, 4
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i32 @mod(i32 %0, i32 12)
%12 = icmp eq i32 %11, 5
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i32 @mod(i32 %0, i32 12)
%15 = icmp eq i32 %14, 7
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i32 @mod(i32 %0, i32 12)
%18 = icmp eq i32 %17, 9
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i32 @mod(i32 %0, i32 12)
%21 = icmp eq i32 %20, 11
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ %22, %19 ]
ret i32 %24
}