#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*/ bzero(char *, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, char const *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void util_debug_bin2hex(char *label, unsigned char *x, int len, char *file,
                        const char *func, int line) {
  int i;
  int z = 0;
  int l = (len / 4) + len * 2;
  if (len % 4 > 0) {
    ++l;
  }
  char *_utilbuffer = (char *)malloc((l + 1) * sizeof(char));
  bzero(_utilbuffer, l + 1);
  for (i = 0; i < len; i++) {
    sprintf(_utilbuffer + z, "%02x", x[i]);
    z += 2;
    if ((i > 0) && ((i + 1) % 4 == 0)) {
      sprintf(_utilbuffer + z, " ");
      z++;
    }
  }
  if (1)
    printf("[DEBUG][%s:%s:%d] "
           "%20s: %s"
           "\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/daviddpd/cishstubs/refs/heads/master/"
           "problem/test-ok.c",
           func, line, label, _utilbuffer);
  ;
  free(_utilbuffer);
}


x86 assembly (clang, -O0):
<util_debug_bin2hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    11a9 <util_debug_bin2hex+0x59>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
add    $0x1,%esi
call   1060 <bzero@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1266 <util_debug_bin2hex+0x116>
mov    -0x40(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    1253 <util_debug_bin2hex+0x103>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1253 <util_debug_bin2hex+0x103>
mov    -0x40(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1258 <util_debug_bin2hex+0x108>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11d6 <util_debug_bin2hex+0x86>
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xd8b(%rip),%rdi
lea    0xda0(%rip),%rsi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_debug_bin2hex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x4(%rsp)
mov    %r8,0x10(%rsp)
mov    %edx,%ebx
mov    %rsi,%r13
mov    %rdi,0x8(%rsp)
lea    0x3(%rbx),%eax
test   %edx,%edx
cmovns %edx,%eax
sar    $0x2,%eax
xor    %ecx,%ecx
test   $0x80000003,%edx
setg   %cl
lea    (%rax,%rbx,2),%eax
lea    (%rcx,%rax,1),%r14d
add    $0x1,%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14d,%esi
call   1060 <bzero@plt>
test   %ebx,%ebx
jle    11c8 <util_debug_bin2hex+0x78>
movzbl 0x0(%r13),%edx
lea    0xe47(%rip),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
cmp    $0x1,%ebx
jne    1202 <util_debug_bin2hex+0xb2>
lea    0xe36(%rip),%rdi
lea    0xe4b(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%r8
mov    %rbp,%r9
call   1040 <printf@plt>
mov    %rbp,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    %ebx,%eax
mov    $0x1,%ebx
sub    %rax,%rbx
mov    $0x2,%r12d
mov    $0x2,%r15d
jmp    1235 <util_debug_bin2hex+0xe5>
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%r15,1),%rax
add    $0x1,%rax
add    $0x1,%r15
mov    %r14d,%r12d
cmp    $0x2,%rax
je     11c8 <util_debug_bin2hex+0x78>
movslq %r12d,%r14
lea    (%r14,%rbp,1),%rdi
movzbl -0x1(%r13,%r15,1),%edx
lea    0xdb7(%rip),%rsi
xor    %eax,%eax
call   1070 <sprintf@plt>
add    $0x2,%r14
test   $0x3,%r15b
jne    1220 <util_debug_bin2hex+0xd0>
movw   $0x20,0x0(%rbp,%r14,1)
add    $0x3,%r12d
mov    %r12d,%r14d
jmp    1220 <util_debug_bin2hex+0xd0>

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [28 x i8] c"[DEBUG][%s:%s:%d] %20s: %s\0A\00"
@.str.3 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/daviddpd/cishstubs/refs/heads/master/problem/test-ok.c\00"
define void @util_debug_bin2hex(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i32 0, i32* %14
%17 = load i32, i32* %9
%18 = sdiv i32 %17, 4
%19 = load i32, i32* %9
%20 = mul nsw i32 %19, 2
%21 = add nsw i32 %18, %20
store i32 %21, i32* %15
%22 = load i32, i32* %9
%23 = srem i32 %22, 4
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %6
%26 = load i32, i32* %15
%27 = add nsw i32 %26, 1
store i32 %27, i32* %15
br label %28
28: ; preds = %25, %6
%29 = load i32, i32* %15
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 1
%33 = trunc i64 %32 to i32
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %16
%36 = load i8*, i8** %16
%37 = load i32, i32* %15
%38 = add nsw i32 %37, 1
%39 = call i32 @bzero(i8* %36, i32 %38)
store i32 0, i32* %13
br label %40
40: ; preds = %74, %28
%41 = load i32, i32* %13
%42 = load i32, i32* %9
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %77
44: ; preds = %40
%45 = load i8*, i8** %16
%46 = load i32, i32* %14
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8*, i8** %8
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %14
%57 = add nsw i32 %56, 2
store i32 %57, i32* %14
%58 = load i32, i32* %13
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %73
60: ; preds = %44
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
%63 = srem i32 %62, 4
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %73
65: ; preds = %60
%66 = load i8*, i8** %16
%67 = load i32, i32* %14
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%71 = load i32, i32* %14
%72 = add nsw i32 %71, 1
store i32 %72, i32* %14
br label %73
73: ; preds = %65, %60, %44
br label %74
74: ; preds = %73
%75 = load i32, i32* %13
%76 = add nsw i32 %75, 1
store i32 %76, i32* %13
br label %40
77: ; preds = %40
%78 = load i8*, i8** %11
%79 = load i32, i32* %12
%80 = load i8*, i8** %7
%81 = load i8*, i8** %16
%82 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.3, i64 0, i64 0), i8* %78, i32 %79, i8* %80, i8* %81)
%83 = load i8*, i8** %16
%84 = call i32 @free(i8* %83)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@.str.2 = [28 x i8] c"[DEBUG][%s:%s:%d] %20s: %s\0A\00"
@.str.3 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/daviddpd/cishstubs/refs/heads/master/problem/test-ok.c\00"
define void @util_debug_bin2hex(i8* %0, i8* nocapture %1, i32 %2, i8* nocapture readnone %3, i8* %4, i32 %5) {
%7 = sdiv i32 %2, 4
%8 = shl nsw i32 %2, 1
%9 = and i32 %2, -2147483645
%10 = icmp sgt i32 %9, 0
%11 = zext i1 %10 to i32
%12 = or i32 %8, 1
%13 = add i32 %12, %7
%14 = add i32 %13, %11
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = tail call i32 @bzero(i8* %16, i32 %14)
%18 = icmp sgt i32 %2, 0
br i1 %18, label %19, label %46
19: ; preds = %6
%20 = zext i32 %2 to i64
%21 = load i8, i8* %1
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %2, 1
br i1 %24, label %46, label %25
25: ; preds = %19, %43
%26 = phi i64 [ %35, %43 ], [ 1, %19 ]
%27 = phi i32 [ %44, %43 ], [ 2, %19 ]
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %16, i64 %28
%30 = getelementptr inbounds i8, i8* %1, i64 %26
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %29, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = add nsw i32 %27, 2
%35 = add nuw nsw i64 %26, 1
%36 = and i64 %35, 3
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %25
%39 = sext i32 %34 to i64
%40 = getelementptr inbounds i8, i8* %16, i64 %39
%41 = bitcast i8* %40 to i16*
store i16 32, i16* %41
%42 = add nsw i32 %27, 3
br label %43
43: ; preds = %25, %38
%44 = phi i32 [ %34, %25 ], [ %42, %38 ]
%45 = icmp eq i64 %35, %20
br i1 %45, label %46, label %25
46: ; preds = %43, %19, %6
%47 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %5, i8* %0, i8* %16)
%48 = tail call i32 @free(i8* %16)
ret void
}