#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
void write_array(FILE *h_fp, FILE *dbg_fp, char *buf, int len, char *name,
                 int num) {
  int i, j;
  if (len == 0)
    return;
  for (i = 0; i < len;) {
    for (j = 0; (i < len) && (j < 16); j++) {
      fprintf(dbg_fp, "%c", (char)buf[i]);
      i++;
    }
  }
}


x86 assembly (clang, -O0):
<write_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    113e <write_array+0x2e>
jmp    11bb <write_array+0xab>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bb <write_array+0xab>
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x35(%rbp)
jge    1173 <write_array+0x63>
cmpl   $0x10,-0x34(%rbp)
setl   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1183 <write_array+0x73>
jmp    11b6 <write_array+0xa6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
lea    0xe6a(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1158 <write_array+0x48>
jmp    1145 <write_array+0x35>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
test   %ecx,%ecx
jle    1195 <write_array+0x85>
mov    %rsi,%r13
mov    %ecx,%ebp
xor    %r12d,%r12d
mov    %ecx,0xc(%rsp)
jmp    114c <write_array+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
add    %eax,%r12d
mov    0xc(%rsp),%ecx
cmp    %ecx,%r12d
jge    1195 <write_array+0x85>
cmp    %ecx,%r12d
jge    1147 <write_array+0x37>
movslq %r12d,%rbx
mov    0x10(%rsp),%rax
lea    (%rax,%rbx,1),%r14
add    $0x1,%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%r15,1),%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
lea    (%rbx,%r15,1),%rcx
lea    0x1(%r15),%rax
cmp    %rbp,%rcx
jge    1140 <write_array+0x30>
cmp    $0xf,%r15d
mov    %rax,%r15
jb     1170 <write_array+0x60>
jmp    1140 <write_array+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @write_array(i32* %0, i32* %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%15 = load i32, i32* %10
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %6
br label %47
18: ; preds = %6
store i32 0, i32* %13
br label %19
19: ; preds = %46, %18
%20 = load i32, i32* %13
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %47
23: ; preds = %19
store i32 0, i32* %14
br label %24
24: ; preds = %43, %23
%25 = load i32, i32* %13
%26 = load i32, i32* %10
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %14
%30 = icmp slt i32 %29, 16
br label %31
31: ; preds = %28, %24
%32 = phi i1 [ false, %24 ], [ %30, %28 ]
br i1 %32, label %33, label %46
33: ; preds = %31
%34 = load i32*, i32** %8
%35 = load i8*, i8** %9
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %39)
%41 = load i32, i32* %13
%42 = add nsw i32 %41, 1
store i32 %42, i32* %13
br label %43
43: ; preds = %33
%44 = load i32, i32* %14
%45 = add nsw i32 %44, 1
store i32 %45, i32* %14
br label %24
46: ; preds = %31
br label %19
47: ; preds = %17, %19
ret void
}

LLVM IR (-O2):
define void @write_array(i32* nocapture readnone %0, i32* nocapture %1, i8* nocapture %2, i32 %3, i8* nocapture readnone %4, i32 %5) {
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %32
8: ; preds = %6
%9 = zext i32 %3 to i64
br label %15
10: ; preds = %20
%11 = trunc i64 %27 to i32
br label %12
12: ; preds = %10, %15
%13 = phi i32 [ %16, %15 ], [ %11, %10 ]
%14 = icmp slt i32 %13, %3
br i1 %14, label %15, label %32
15: ; preds = %8, %12
%16 = phi i32 [ %13, %12 ], [ 0, %8 ]
%17 = icmp slt i32 %16, %3
br i1 %17, label %18, label %12
18: ; preds = %15
%19 = sext i32 %16 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ %19, %18 ], [ %27, %20 ]
%22 = phi i32 [ 0, %18 ], [ %28, %20 ]
%23 = getelementptr inbounds i8, i8* %2, i64 %21
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = tail call i32 @fputc(i32 %25, i32* %1)
%27 = add nsw i64 %21, 1
%28 = add nuw nsw i32 %22, 1
%29 = icmp slt i64 %27, %9
%30 = icmp ult i32 %22, 15
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %20, label %10
32: ; preds = %12, %6
ret void
}