#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 *, ...);
unsigned char *out_C_format(unsigned char *data, int len, char *out_title,
                            int align) {
  int i;
  printf("\n%s\n\"", out_title);
  for (i = 0; i < len; i++) {
    printf("\\x%02x", data[i]);
    if ((i + 1) % align == 0 && (i + 1) != len) {
      printf("\"\n\"");
    }
  }
  printf("\";\n");
  return NULL;
}


x86 assembly (clang, -O0):
<out_C_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <out_C_format+0x98>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x1c(%rbp)
cmp    $0x0,%edx
jne    1195 <out_C_format+0x85>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cmp    -0xc(%rbp),%eax
je     1195 <out_C_format+0x85>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <out_C_format+0x8a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <out_C_format+0x2f>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<out_C_format>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %esi,%ebp
mov    %rdi,%r13
lea    0xec6(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11b0 <out_C_format+0x90>
mov    %ebp,%ebx
neg    %rbx
mov    $0x1,%ebp
lea    0xead(%rip),%r15
lea    0xead(%rip),%r12
jmp    1182 <out_C_format+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     11b0 <out_C_format+0x90>
movzbl -0x1(%r13,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
cltd
idiv   %r14d
mov    %rbx,%rax
add    %rbp,%rax
je     1170 <out_C_format+0x50>
test   %edx,%edx
jne    1170 <out_C_format+0x50>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <out_C_format+0x50>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"\0A%s\0A\22\00"
@.str.1 = [7 x i8] c"\\x%02x\00"
@.str.2 = [4 x i8] c"\22\0A\22\00"
@str = [3 x i8] c"\22;\00"
define noalias i8* @out_C_format(i8* nocapture %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %23
%10 = phi i64 [ 0, %7 ], [ %15, %23 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i64 %10, 1
%16 = trunc i64 %15 to i32
%17 = srem i32 %16, %3
%18 = icmp ne i32 %17, 0
%19 = icmp eq i64 %15, %8
%20 = or i1 %19, %18
br i1 %20, label %23, label %21
21: ; preds = %9
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %9, %21
%24 = icmp eq i64 %15, %8
br i1 %24, label %25, label %9
25: ; preds = %23, %4
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i8* null
}