#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int length;
  unsigned char *data;
};
typedef int /*<<< orphan*/ BIO;
typedef TYPE_1__ ASN1_STRING;

/* Variables and functions */
scalar_t__ BIO_indent(int /*<<< orphan*/ *, int, int);
scalar_t__ BIO_printf(int /*<<< orphan*/ *, char *, unsigned char const,
                      char *);
int BIO_write(int /*<<< orphan*/ *, char *, int);
int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) {
  const unsigned char *s;
  int i, n;
  n = sig->length;
  s = sig->data;
  for (i = 0; i < n; i++) {
    if ((i % 18) == 0) {
      if (BIO_write(bp, "\n", 1) <= 0)
        return 0;
      if (BIO_indent(bp, indent, indent) <= 0)
        return 0;
    }
    if (BIO_printf(bp, "%02x%s", s[i], ((i + 1) == n) ? "" : ":") <= 0)
      return 0;
  }
  if (BIO_write(bp, "\n", 1) != 1)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<X509_signature_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1239 <X509_signature_dump+0x109>
mov    -0x2c(%rbp),%eax
mov    $0x12,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d3 <X509_signature_dump+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
cmp    $0x0,%eax
jg     11a9 <X509_signature_dump+0x79>
movl   $0x0,-0x4(%rbp)
jmp    126a <X509_signature_dump+0x13a>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <BIO_indent@plt>
cmp    $0x0,%rax
jg     11ce <X509_signature_dump+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    126a <X509_signature_dump+0x13a>
jmp    11d3 <X509_signature_dump+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%r8d
lea    0xe16(%rip),%rcx
lea    0xe07(%rip),%rdx
cmp    %r8d,%esi
cmove  %rdx,%rcx
lea    0xdfa(%rip),%rsi
movzbl %al,%edx
call   1040 <BIO_printf@plt>
cmp    $0x0,%rax
jg     1226 <X509_signature_dump+0xf6>
movl   $0x0,-0x4(%rbp)
jmp    126a <X509_signature_dump+0x13a>
jmp    122b <X509_signature_dump+0xfb>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115f <X509_signature_dump+0x2f>
mov    -0x10(%rbp),%rdi
lea    0xdbc(%rip),%rsi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
cmp    $0x1,%eax
je     1263 <X509_signature_dump+0x133>
movl   $0x0,-0x4(%rbp)
jmp    126a <X509_signature_dump+0x13a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_signature_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
mov    %rdi,%rbx
mov    (%rsi),%r13d
mov    0x8(%rsi),%r14
xor    %r12d,%r12d
test   %r13d,%r13d
mov    $0x0,%r15d
cmovg  %r13d,%r15d
add    $0xffffffffffffffff,%r13
jmp    1196 <X509_signature_dump+0x66>
nop
movzbl (%r14,%r12,1),%edx
lea    0x1(%r12),%rbp
cmp    %r12,%r13
lea    0xe95(%rip),%rcx
lea    0xe86(%rip),%rax
cmove  %rax,%rcx
mov    %rbx,%rdi
lea    0xe79(%rip),%rsi
call   1040 <BIO_printf@plt>
mov    %rbp,%r12
test   %rax,%rax
jle    11e8 <X509_signature_dump+0xb8>
cmp    %r12,%r15
je     11ec <X509_signature_dump+0xbc>
mov    %r12d,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%eax
neg    %eax
add    %r12d,%eax
jne    1160 <X509_signature_dump+0x30>
mov    %rbx,%rdi
lea    0xe41(%rip),%rsi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    1209 <X509_signature_dump+0xd9>
mov    %rbx,%rdi
mov    0x4(%rsp),%edx
mov    %edx,%esi
call   1030 <BIO_indent@plt>
test   %rax,%rax
jg     1160 <X509_signature_dump+0x30>
jmp    1209 <X509_signature_dump+0xd9>
xor    %ebp,%ebp
jmp    1209 <X509_signature_dump+0xd9>
lea    0xe0d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8* }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [7 x i8] c"%02x%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c":\00"
define i32 @X509_signature_dump(i32* %0, %struct.TYPE_3__* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.TYPE_3__*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %6
store i32 %2, i32* %7
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %12
store i32 %13, i32* %10
%14 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 1
%16 = load i8*, i8** %15
store i8* %16, i8** %8
store i32 0, i32* %9
br label %17
17: ; preds = %55, %3
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %17
%22 = load i32, i32* %9
%23 = srem i32 %22, 18
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = call i32 @BIO_write(i32* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%28 = icmp sle i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 0, i32* %4
br label %64
30: ; preds = %25
%31 = load i32*, i32** %5
%32 = load i32, i32* %7
%33 = load i32, i32* %7
%34 = call i64 @BIO_indent(i32* %31, i32 %32, i32 %33)
%35 = icmp sle i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 0, i32* %4
br label %64
37: ; preds = %30
br label %38
38: ; preds = %37, %21
%39 = load i32*, i32** %5
%40 = load i8*, i8** %8
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
%47 = load i32, i32* %10
%48 = icmp eq i32 %46, %47
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%51 = call i64 @BIO_printf(i32* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %44, i8* %50)
%52 = icmp sle i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %38
store i32 0, i32* %4
br label %64
54: ; preds = %38
br label %55
55: ; preds = %54
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %17
58: ; preds = %17
%59 = load i32*, i32** %5
%60 = call i32 @BIO_write(i32* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%61 = icmp ne i32 %60, 1
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 0, i32* %4
br label %64
63: ; preds = %58
store i32 1, i32* %4
br label %64
64: ; preds = %63, %62, %53, %36, %29
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8* }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [7 x i8] c"%02x%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c":\00"
define i32 @X509_signature_dump(i32* %0, %struct.TYPE_3__* nocapture %1, i32 %2) {
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%7 = load i8*, i8** %6
%8 = zext i32 %5 to i64
%9 = call i32 @llvm.smax.i32(i32 %5, i32 0)
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %24, %3
%12 = phi i64 [ %27, %24 ], [ 0, %3 ]
%13 = icmp eq i64 %12, %10
br i1 %13, label %32, label %14
14: ; preds = %11
%15 = trunc i64 %12 to i32
%16 = urem i32 %15, 18
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = tail call i32 @BIO_write(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = icmp slt i32 %19, 1
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = tail call i64 @BIO_indent(i32* %0, i32 %2, i32 %2)
%23 = icmp slt i64 %22, 1
br i1 %23, label %36, label %24
24: ; preds = %21, %14
%25 = getelementptr inbounds i8, i8* %7, i64 %12
%26 = load i8, i8* %25
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %8
%29 = select i1 %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%30 = tail call i64 @BIO_printf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %26, i8* %29)
%31 = icmp slt i64 %30, 1
br i1 %31, label %36, label %11
32: ; preds = %11
%33 = tail call i32 @BIO_write(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %24, %21, %18, %32
%37 = phi i32 [ %35, %32 ], [ 0, %18 ], [ 0, %21 ], [ 0, %24 ]
ret i32 %37
}