#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 cldrv_serialize(unsigned char arr[80]) {
  int i;
  printf("[");
  for (i = 0; i < 80 - 1; ++i) {
    printf("%d,", !!arr[i]);
  }
  printf("%d]\n", !!arr[80 - 1]);
}


x86 assembly (clang, -O0):
<cldrv_serialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4f,-0xc(%rbp)
jge    116f <cldrv_serialize+0x5f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <cldrv_serialize+0x21>
mov    -0x8(%rbp),%rax
cmpb   $0x0,0x4f(%rax)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cldrv_serialize>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x5b,%edi
call   1030 <putchar@plt>
lea    0xec7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
cmpb   $0x0,(%r15,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x4f,%rbx
jne    1140 <cldrv_serialize+0x20>
xor    %esi,%esi
cmpb   $0x0,0x4f(%r15)
setne  %sil
lea    0xe93(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d,\00"
@.str.2 = [5 x i8] c"%d]\0A\00"
define void @cldrv_serialize(i8* nocapture %0) {
%2 = tail call i32 @putchar(i32 91)
br label %3
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %10, %3 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 79
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = getelementptr inbounds i8, i8* %0, i64 79
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret void
}