#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*/ printf(char *, ...);
void annoying(int n) {
  for (int i = 1; i <= n; i++) {
    if (i % 15 == 0) {
      printf("catdog\n");
    } else if (i % 5 == 0) {
      printf("cat\n");
    } else if (i % 3 == 0) {
      printf("dog\n");
    } else {
      printf("%i\n", i);
    }
  }
}


x86 assembly (clang, -O0):
<annoying>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11d1 <annoying+0xc1>
mov    -0x8(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1155 <annoying+0x45>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <annoying+0xae>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117c <annoying+0x6c>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <annoying+0xa9>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a3 <annoying+0x93>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <annoying+0xa4>
mov    -0x8(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <annoying+0xa9>
jmp    11be <annoying+0xae>
jmp    11c3 <annoying+0xb3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <annoying+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<annoying>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11ff <annoying+0xdf>
mov    %edi,%r14d
neg    %r14d
mov    $0x1,%ebx
mov    $0x88888889,%r13d
mov    $0xcccccccd,%ebp
lea    0xeb8(%rip),%r15
lea    0xead(%rip),%r12
jmp    117f <annoying+0x5f>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     11ff <annoying+0xdf>
mov    %ebx,%eax
mov    %rax,%rcx
imul   %r13,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
cmp    %ecx,%ebx
je     1160 <annoying+0x40>
mov    %rax,%rcx
imul   %rbp,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%ecx
mov    $0x1,%edx
sub    %ecx,%edx
add    %ebx,%edx
cmp    $0x1,%edx
jne    11c0 <annoying+0xa0>
mov    %r12,%rdi
jmp    1163 <annoying+0x43>
nopw   0x0(%rax,%rax,1)
mov    $0xaaaaaaab,%ecx
imul   %rcx,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
mov    $0x1,%ecx
sub    %eax,%ecx
add    %ebx,%ecx
cmp    $0x1,%ecx
jne    11ea <annoying+0xca>
lea    0xe26(%rip),%rdi
jmp    1163 <annoying+0x43>
lea    0xe0f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <annoying+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"catdog\0A\00"
@.str.1 = [5 x i8] c"cat\0A\00"
@.str.2 = [5 x i8] c"dog\0A\00"
@.str.3 = [4 x i8] c"%i\0A\00"
define void @annoying(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %32, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp sle i32 %5, %6
br i1 %7, label %8, label %35
8: ; preds = %4
%9 = load i32, i32* %3
%10 = srem i32 %9, 15
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %31
14: ; preds = %8
%15 = load i32, i32* %3
%16 = srem i32 %15, 5
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %30
20: ; preds = %14
%21 = load i32, i32* %3
%22 = srem i32 %21, 3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
26: ; preds = %20
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %24
br label %30
30: ; preds = %29, %18
br label %31
31: ; preds = %30, %12
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %4
35: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%i\0A\00"
@str = [4 x i8] c"dog\00"
@str.4 = [4 x i8] c"cat\00"
@str.5 = [7 x i8] c"catdog\00"
define void @annoying(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %4
3: ; preds = %22, %1
ret void
4: ; preds = %1, %22
%5 = phi i32 [ %23, %22 ], [ 1, %1 ]
%6 = urem i32 %5, 15
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %22
10: ; preds = %4
%11 = urem i32 %5, 5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0))
br label %22
15: ; preds = %10
%16 = urem i32 %5, 3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %22
22: ; preds = %8, %18, %20, %13
%23 = add nuw i32 %5, 1
%24 = icmp eq i32 %5, %0
br i1 %24, label %3, label %4
}