#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*/ BIO;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, ...);
int BN_bn2bin(int /*<<< orphan*/ *, unsigned char *);
scalar_t__ BN_is_zero(int /*<<< orphan*/ *);
int ecparam_print_var(BIO *out, BIGNUM *in, const char *var, int len,
                      unsigned char *buffer) {
  BIO_printf(out, "static unsigned char %s_%d[] = {", var, len);
  if (BN_is_zero(in))
    BIO_printf(out, "\n\t0x00");
  else {
    int i, l;
    l = BN_bn2bin(in, buffer);
    for (i = 0; i < l - 1; i++) {
      if ((i % 12) == 0)
        BIO_printf(out, "\n\t");
      BIO_printf(out, "0x%02X,", buffer[i]);
    }
    if ((i % 12) == 0)
      BIO_printf(out, "\n\t");
    BIO_printf(out, "0x%02X", buffer[i]);
  }
  BIO_printf(out, "\n\t};\n\n");
  return 1;
}


x86 assembly (clang, -O0):
<ecparam_print_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <BN_is_zero@plt>
cmp    $0x0,%rax
je     118e <ecparam_print_var+0x5e>
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
jmp    124c <ecparam_print_var+0x11c>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <BN_bn2bin@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1208 <ecparam_print_var+0xd8>
mov    -0x2c(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11dc <ecparam_print_var+0xac>
mov    -0x8(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a5 <ecparam_print_var+0x75>
mov    -0x2c(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    122e <ecparam_print_var+0xfe>
mov    -0x8(%rbp),%rdi
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecparam_print_var>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb5(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <BIO_printf@plt>
mov    %r15,%rdi
call   1040 <BN_is_zero@plt>
test   %rax,%rax
je     1177 <ecparam_print_var+0x47>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
jmp    122a <ecparam_print_var+0xfa>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <BN_bn2bin@plt>
cmp    $0x2,%eax
jl     1201 <ecparam_print_var+0xd1>
add    $0xffffffff,%eax
mov    %eax,0x4(%rsp)
mov    %eax,%ebp
lea    0xe94(%rip),%r12
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    11bf <ecparam_print_var+0x8f>
nop
movzbl (%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
add    $0x1,%r15
add    $0xffffffff,%r13d
cmp    %r15,%rbp
je     11ed <ecparam_print_var+0xbd>
mov    %r15d,%eax
mov    $0xaaaaaaab,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,2),%eax
shl    $0x2,%eax
add    %r13d,%eax
jne    11a0 <ecparam_print_var+0x70>
mov    %rbx,%rdi
lea    0xe44(%rip),%rsi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
jmp    11a0 <ecparam_print_var+0x70>
mov    0x4(%rsp),%ebp
imul   $0xaaaaaaab,%ebp,%eax
ror    $0x2,%eax
cmp    $0x15555555,%eax
ja     1212 <ecparam_print_var+0xe2>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
mov    %ebp,%eax
movzbl (%r14,%rax,1),%edx
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
lea    0xe09(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [33 x i8] c"static unsigned char %s_%d[] = {\00"
@.str.1 = [7 x i8] c"\0A\090x00\00"
@.str.2 = [3 x i8] c"\0A\09\00"
@.str.3 = [8 x i8] c"0x%02X,\00"
@.str.4 = [7 x i8] c"0x%02X\00"
@.str.5 = [7 x i8] c"\0A\09};\0A\0A\00"
define i32 @ecparam_print_var(i32* %0, i32* %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3)
%7 = tail call i64 @BN_is_zero(i32* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %44
11: ; preds = %5
%12 = tail call i32 @BN_bn2bin(i32* %1, i8* %4)
%13 = add i32 %12, -1
%14 = icmp sgt i32 %12, 1
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = zext i32 %13 to i64
br label %17
17: ; preds = %15, %24
%18 = phi i64 [ 0, %15 ], [ %29, %24 ]
%19 = trunc i64 %18 to i32
%20 = urem i32 %19, 12
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %17
%25 = getelementptr inbounds i8, i8* %4, i64 %18
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %18, 1
%30 = icmp eq i64 %29, %16
br i1 %30, label %31, label %17
31: ; preds = %24
%32 = urem i32 %13, 12
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %11, %31
%35 = phi i32 [ %13, %31 ], [ 0, %11 ]
%36 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %34, %31
%38 = phi i32 [ %35, %34 ], [ %13, %31 ]
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %4, i64 %39
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %37, %9
%45 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
ret i32 1
}