#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 d(int);
int /*<<< orphan*/ nicename(unsigned int, char *, char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ putchar(char);
void quipper(unsigned count) {
  int i;
  int hp = d(8) + d(8) + d(8) + d(8) + d(8) + d(8) + d(8) + d(8) - 8;
  nicename(count, "swarm of quippers", "MM 284");
  for (i = 0; i < count; i++) {
    printf("%d: %d hp", i + 1, (hp > 0) ? hp : 1);
    (void)putchar('\n');
  }
  (void)putchar('\n');
}


x86 assembly (clang, -O0):
<quipper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,-0x28(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
sub    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
lea    0xe0f(%rip),%rsi
lea    0xe1a(%rip),%rdx
call   1060 <nicename@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1265 <quipper+0x125>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    122e <quipper+0xee>
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    123b <quipper+0xfb>
mov    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    123b <quipper+0xfb>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1204 <quipper+0xc4>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quipper>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r13d
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,0x14(%rsp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%r14d
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,0x10(%rsp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,0xc(%rsp)
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ebp
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%r15d
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%ebx
lea    0xe3f(%rip),%rsi
lea    0xe4a(%rip),%rdx
mov    %r13d,%edi
call   1060 <nicename@plt>
test   %r13d,%r13d
je     1239 <quipper+0xf9>
add    0x14(%rsp),%r14d
add    0x10(%rsp),%r14d
add    0xc(%rsp),%r14d
add    %ebp,%r14d
add    %r15d,%r14d
add    %r12d,%r14d
add    %ebx,%r14d
lea    -0x8(%r14),%ebp
cmp    $0x9,%r14d
mov    $0x1,%ebx
cmovl  %ebx,%ebp
neg    %r13d
lea    0xe0f(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1210 <quipper+0xd0>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"swarm of quippers\00"
@.str.1 = [7 x i8] c"MM 284\00"
@.str.2 = [10 x i8] c"%d: %d hp\00"
define void @quipper(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @d(i32 8)
%6 = call i32 @d(i32 8)
%7 = add nsw i32 %5, %6
%8 = call i32 @d(i32 8)
%9 = add nsw i32 %7, %8
%10 = call i32 @d(i32 8)
%11 = add nsw i32 %9, %10
%12 = call i32 @d(i32 8)
%13 = add nsw i32 %11, %12
%14 = call i32 @d(i32 8)
%15 = add nsw i32 %13, %14
%16 = call i32 @d(i32 8)
%17 = add nsw i32 %15, %16
%18 = call i32 @d(i32 8)
%19 = add nsw i32 %17, %18
%20 = sub nsw i32 %19, 8
store i32 %20, i32* %4
%21 = load i32, i32* %2
%22 = call i32 @nicename(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %23
23: ; preds = %39, %1
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = load i32, i32* %4
br label %35
34: ; preds = %27
br label %35
35: ; preds = %34, %32
%36 = phi i32 [ %33, %32 ], [ 1, %34 ]
%37 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %36)
%38 = call i32 @putchar(i8 signext 10)
br label %39
39: ; preds = %35
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %23
42: ; preds = %23
%43 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"swarm of quippers\00"
@.str.1 = [7 x i8] c"MM 284\00"
@.str.2 = [10 x i8] c"%d: %d hp\00"
define void @quipper(i32 %0) {
%2 = tail call i32 @d(i32 8)
%3 = tail call i32 @d(i32 8)
%4 = add nsw i32 %3, %2
%5 = tail call i32 @d(i32 8)
%6 = add nsw i32 %4, %5
%7 = tail call i32 @d(i32 8)
%8 = add nsw i32 %6, %7
%9 = tail call i32 @d(i32 8)
%10 = add nsw i32 %8, %9
%11 = tail call i32 @d(i32 8)
%12 = add nsw i32 %10, %11
%13 = tail call i32 @d(i32 8)
%14 = add nsw i32 %12, %13
%15 = tail call i32 @d(i32 8)
%16 = add nsw i32 %14, %15
%17 = tail call i32 @nicename(i32 %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32 %0, 0
br i1 %18, label %29, label %19
19: ; preds = %1
%20 = add nsw i32 %16, -8
%21 = icmp sgt i32 %16, 8
%22 = select i1 %21, i32 %20, i32 1
br label %23
23: ; preds = %19, %23
%24 = phi i32 [ 0, %19 ], [ %25, %23 ]
%25 = add nuw nsw i32 %24, 1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %22)
%27 = tail call i32 @putchar(i8 signext 10)
%28 = icmp eq i32 %25, %0
br i1 %28, label %29, label %23
29: ; preds = %23, %1
%30 = tail call i32 @putchar(i8 signext 10)
ret void
}