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


x86 assembly (clang, -O0):
<duergar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    0xea8(%rip),%rsi
lea    0xeb1(%rip),%rdx
call   1060 <nicename@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    120e <duergar+0xce>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x8,%edi
call   1040 <d@plt>
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    -0x14(%rbp),%edx
mov    -0x10(%rbp),%esi
add    %eax,%edx
add    $0x8,%edx
mov    -0x8(%rbp),%edi
mov    %edi,%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
lea    0xe53(%rip),%rcx
lea    0xe41(%rip),%rax
cmp    $0x0,%edi
cmovg  %rax,%rcx
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <duergar+0x2b>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<duergar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %edi,%r14d
lea    0xea8(%rip),%rsi
lea    0xeb1(%rip),%rdx
call   1060 <nicename@plt>
test   %r14d,%r14d
je     1208 <duergar+0xc8>
neg    %r14d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x8,%edi
call   1040 <d@plt>
mov    %eax,%r13d
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>
add    %r13d,%ebp
add    %r15d,%ebp
lea    (%rax,%rbp,1),%edx
add    $0x8,%edx
lea    -0x1(%r12),%ebp
test   %r12d,%r12d
lea    0xe64(%rip),%rcx
lea    0xe52(%rip),%rax
cmovg  %rax,%rcx
lea    0xe3a(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
mov    %ebp,%r12d
cmp    $0x1,%eax
jne    1180 <duergar+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"duergar (dwarf)\00"
@.str.1 = [7 x i8] c"MM 122\00"
@.str.2 = [13 x i8] c"%d: %d hp %s\00"
@.str.3 = [12 x i8] c"(invisible)\00"
@.str.4 = [1 x i8] zeroinitializer
define void @duergar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = call i32 @nicename(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 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* %5
br label %8
8: ; preds = %30, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
%15 = call i32 @d(i32 8)
%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 = call i32 @d(i32 8)
%21 = add nsw i32 %19, %20
%22 = add nsw i32 %21, 8
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
%25 = icmp sgt i32 %23, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %22, i8* %27)
%29 = call i32 @putchar(i8 signext 10)
br label %30
30: ; preds = %12
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %8
33: ; preds = %8
%34 = call i32 @putchar(i8 signext 10)
ret void
}

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