#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 dump_labeling(char *labeling, int c) {
  int i;
  printf("labeling dump:\n");
  if (labeling == NULL) {
    printf("NULL\n");
    return;
  }
  for (i = 1; i <= c; i++) {
    printf("%c", labeling[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_labeling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
jne    114b <dump_labeling+0x3b>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <dump_labeling+0x84>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1186 <dump_labeling+0x76>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <dump_labeling+0x42>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_labeling>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
test   %r14,%r14
je     1172 <dump_labeling+0x52>
test   %r15d,%r15d
jle    1163 <dump_labeling+0x43>
add    $0x1,%r15d
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <dump_labeling+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
lea    0xe96(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@str = [15 x i8] c"labeling dump:\00"
@str.4 = [5 x i8] c"NULL\00"
define void @dump_labeling(i8* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i8* %0, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = icmp slt i32 %1, 1
br i1 %6, label %20, label %7
7: ; preds = %5
%8 = add nuw i32 %1, 1
%9 = zext i32 %8 to i64
br label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %22
12: ; preds = %7, %12
%13 = phi i64 [ 1, %7 ], [ %18, %12 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = tail call i32 @putchar(i32 %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %12
20: ; preds = %12, %5
%21 = tail call i32 @putchar(i32 10)
br label %22
22: ; preds = %20, %10
ret void
}