#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 *, ...);
int dump_it(FILE *fd, char *s, char *cnam, int s_len) {
  int i = 0, j = 1, count = 0;
  if (cnam) {
    fprintf(fd, "char %s[] =\n\"", cnam);
  }
  for (; i < s_len; i++) {
    count++;
    if (cnam) {
      fprintf(fd, "\\x%02x", (unsigned char)s[i]);
    } else {
      fprintf(fd, "%c", s[i]);
    }
    if (!(j % 15) && cnam) {
      fprintf(fd, "\"\n\"");
      j = 0;
    }
    j++;
  }
  if (j != 1 && cnam) {
    fprintf(fd, "\"");
  }
  if (cnam) {
    fprintf(fd, ";");
    fprintf(fd, "int %sLEN = %d;\n", cnam, count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<dump_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115d <dump_it+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1162 <dump_it+0x52>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1212 <dump_it+0x102>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a5 <dump_it+0x95>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c3 <dump_it+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11fb <dump_it+0xeb>
cmpq   $0x0,-0x18(%rbp)
je     11fb <dump_it+0xeb>
mov    -0x8(%rbp),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <dump_it+0x52>
cmpl   $0x1,-0x24(%rbp)
je     1239 <dump_it+0x129>
cmpq   $0x0,-0x18(%rbp)
je     1239 <dump_it+0x129>
mov    -0x8(%rbp),%rdi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     126f <dump_it+0x15f>
mov    -0x8(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_it>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
test   %rdx,%rdx
je     1160 <dump_it+0x30>
lea    0xead(%rip),%rsi
mov    %rbp,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r14d,%r14d
jle    120d <dump_it+0xdd>
mov    %r14d,0x4(%rsp)
mov    %r14d,%r14d
mov    $0x1,%r12d
xor    %r13d,%r13d
jmp    1194 <dump_it+0x64>
nopl   0x0(%rax)
mov    %rbp,%rsi
call   1030 <fputc@plt>
mov    %r12d,%eax
lea    0x1(%rax),%r12d
cmp    %r13,%r14
je     11ec <dump_it+0xbc>
movsbl (%rbx,%r13,1),%edi
add    $0x1,%r13
test   %r15,%r15
je     1180 <dump_it+0x50>
movzbl %dil,%edx
mov    %rbp,%rdi
lea    0xe5e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
imul   $0xeeeeeeef,%r12d,%ecx
add    $0x8888888,%ecx
mov    %r12d,%eax
cmp    $0x11111110,%ecx
ja     118b <dump_it+0x5b>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe35(%rip),%rdi
mov    %rbp,%rcx
call   1050 <fwrite@plt>
xor    %eax,%eax
jmp    118b <dump_it+0x5b>
test   %r15,%r15
je     1248 <dump_it+0x118>
test   %eax,%eax
mov    0x4(%rsp),%ebx
je     120f <dump_it+0xdf>
mov    $0x22,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
test   %r15,%r15
jne    1214 <dump_it+0xe4>
jmp    1237 <dump_it+0x107>
xor    %ebx,%ebx
test   %r15,%r15
je     1237 <dump_it+0x107>
mov    $0x3b,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
lea    0xdf1(%rip),%rsi
mov    %rbp,%rdi
mov    %r15,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%ebx
test   %r15,%r15
jne    1214 <dump_it+0xe4>
jmp    1237 <dump_it+0x107>

LLVM IR (-O0):
@.str = [14 x i8] c"char %s[] =\0A\22\00"
@.str.1 = [7 x i8] c"\\x%02x\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [4 x i8] c"\22\0A\22\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [2 x i8] c";\00"
@.str.6 = [17 x i8] c"int %sLEN = %d;\0A\00"
define i32 @dump_it(i32* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
store i32 0, i32* %11
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = load i32*, i32** %5
%16 = load i8*, i8** %7
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %4
br label %19
19: ; preds = %59, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %62
23: ; preds = %19
%24 = load i32, i32* %11
%25 = add nsw i32 %24, 1
store i32 %25, i32* %11
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i32*, i32** %5
%30 = load i8*, i8** %6
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %46
37: ; preds = %23
%38 = load i32*, i32** %5
%39 = load i8*, i8** %6
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %37, %28
%47 = load i32, i32* %10
%48 = srem i32 %47, 15
%49 = icmp ne i32 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %46
%51 = load i8*, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32*, i32** %5
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %56
56: ; preds = %53, %50, %46
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %59
59: ; preds = %56
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %19
62: ; preds = %19
%63 = load i32, i32* %10
%64 = icmp ne i32 %63, 1
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i8*, i8** %7
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i32*, i32** %5
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %68, %65, %62
%72 = load i8*, i8** %7
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %81
74: ; preds = %71
%75 = load i32*, i32** %5
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%77 = load i32*, i32** %5
%78 = load i8*, i8** %7
%79 = load i32, i32* %11
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %78, i32 %79)
br label %81
81: ; preds = %74, %71
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"char %s[] =\0A\22\00"
@.str.1 = [7 x i8] c"\\x%02x\00"
@.str.3 = [4 x i8] c"\22\0A\22\00"
@.str.6 = [17 x i8] c"int %sLEN = %d;\0A\00"
define i32 @dump_it(i32* nocapture %0, i8* nocapture %1, i8* %2, i32 %3) {
%5 = icmp ne i8* %2, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %8
8: ; preds = %6, %4
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %37
10: ; preds = %8
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %10, %28
%13 = phi i64 [ 0, %10 ], [ %15, %28 ]
%14 = phi i32 [ 1, %10 ], [ %30, %28 ]
%15 = add nuw nsw i64 %13, 1
%16 = getelementptr inbounds i8, i8* %1, i64 %13
%17 = load i8, i8* %16
br i1 %5, label %21, label %18
18: ; preds = %12
%19 = sext i8 %17 to i32
%20 = tail call i32 @fputc(i32 %19, i32* %0)
br label %28
21: ; preds = %12
%22 = zext i8 %17 to i32
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = srem i32 %14, 15
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %28
28: ; preds = %18, %26, %21
%29 = phi i32 [ 0, %26 ], [ %14, %21 ], [ %14, %18 ]
%30 = add nsw i32 %29, 1
%31 = icmp eq i64 %15, %11
br i1 %31, label %32, label %12
32: ; preds = %28
%33 = icmp ne i32 %29, 0
%34 = and i1 %5, %33
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 @fputc(i32 34, i32* %0)
br label %37
37: ; preds = %8, %35, %32
%38 = phi i32 [ %3, %35 ], [ %3, %32 ], [ 0, %8 ]
br i1 %5, label %39, label %42
39: ; preds = %37
%40 = tail call i32 @fputc(i32 59, i32* %0)
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %2, i32 %38)
br label %42
42: ; preds = %39, %37
ret i32 0
}