#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*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_bn2bin(int /*<<< orphan*/ *, unsigned char *);
int BN_num_bytes(int /*<<< orphan*/ *);
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_hexbuf(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void dump_wireshark(char *c_hex, BIGNUM *mt) {
  unsigned char bin[256] = {0};
  BN_bn2bin(mt, bin + 256 - BN_num_bytes(mt));
  if (!(bin[0] == 0)) {
    fprintf(stderr, "ERROR : "
                    "decrypted message is not properly padded"
                    "\n");
    exit(EXIT_FAILURE);
  };
  if (!(bin[1] == 2)) {
    fprintf(stderr, "ERROR : "
                    "decrypted message is not properly padded"
                    "\n");
    exit(EXIT_FAILURE);
  };
  int i = 2;
  while (bin[i]) {
    i++;
    if (!(i < 256)) {
      fprintf(stderr, "ERROR : "
                      "decrypted message is not properly padded"
                      "\n");
      exit(EXIT_FAILURE);
    };
  }
  i++;
  printf("RSA ");
  printf("%.16s ", c_hex);
  print_hexbuf(&bin[i], 256 - i);
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_wireshark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <BN_num_bytes@plt>
mov    -0x128(%rbp),%rsi
mov    -0x120(%rbp),%rdi
movslq %eax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rsi
call   1080 <BN_bn2bin@plt>
movzbl -0x110(%rbp),%eax
cmp    $0x0,%eax
je     120f <dump_wireshark+0x9f>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movzbl -0x10f(%rbp),%eax
cmp    $0x2,%eax
je     1242 <dump_wireshark+0xd2>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x2,-0x114(%rbp)
movslq -0x114(%rbp),%rax
cmpb   $0x0,-0x110(%rbp,%rax,1)
je     12a8 <dump_wireshark+0x138>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jl     12a3 <dump_wireshark+0x133>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xd70(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    124c <dump_wireshark+0xdc>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x114(%rbp),%rax
lea    -0x110(%rbp),%rdi
add    %rax,%rdi
mov    $0x100,%esi
sub    -0x114(%rbp),%esi
call   1030 <print_hexbuf@plt>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_wireshark>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsi,%rdi
call   1070 <BN_num_bytes@plt>
cltq
neg    %rax
lea    (%rsp,%rax,1),%rsi
add    $0x100,%rsi
mov    %rbx,%rdi
call   1080 <BN_bn2bin@plt>
cmpb   $0x0,(%rsp)
jne    123a <dump_wireshark+0xca>
cmpb   $0x2,0x1(%rsp)
jne    123a <dump_wireshark+0xca>
mov    $0x3,%ebx
xchg   %ax,%ax
cmpb   $0x0,-0x1(%rsp,%rbx,1)
je     125d <dump_wireshark+0xed>
cmpb   $0x0,(%rsp,%rbx,1)
je     1261 <dump_wireshark+0xf1>
add    $0x2,%rbx
cmp    $0x101,%rbx
jne    1220 <dump_wireshark+0xb0>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
add    $0xffffffffffffffff,%rbx
lea    0x1(%rbx),%r15d
lea    0xdc6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdbd(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rsp,%r15,1),%rdi
mov    $0xff,%esi
sub    %ebx,%esi
call   1040 <print_hexbuf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"ERROR : decrypted message is not properly padded\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"RSA \00"
@.str.2 = [7 x i8] c"%.16s \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @dump_wireshark(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = bitcast [256 x i8]* %5 to i8*
%8 = load i32*, i32** %4
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds i8, i8* %9, i64 256
%11 = load i32*, i32** %4
%12 = call i32 @BN_num_bytes(i32* %11)
%13 = sext i32 %12 to i64
%14 = sub i64 0, %13
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = call i32 @BN_bn2bin(i32* %8, i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = icmp eq i32 %29, 2
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %26
store i32 2, i32* %6
br label %37
37: ; preds = %53, %36
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %37
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = icmp slt i32 %46, 256
br i1 %47, label %53, label %48
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %43
br label %37
54: ; preds = %37
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%58 = load i8*, i8** %3
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %58)
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %61
%63 = load i32, i32* %6
%64 = sub nsw i32 256, %63
%65 = call i32 @print_hexbuf(i8* %62, i32 %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"ERROR : decrypted message is not properly padded\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"RSA \00"
@.str.2 = [7 x i8] c"%.16s \00"
define void @dump_wireshark(i8* %0, i32* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 256
%6 = tail call i32 @BN_num_bytes(i32* %1)
%7 = sext i32 %6 to i64
%8 = sub nsw i64 0, %7
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = call i32 @BN_bn2bin(i32* %1, i8* %9)
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 2
br i1 %21, label %27, label %22
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %18, %37
%28 = phi i64 [ %38, %37 ], [ 2, %18 ]
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %45, label %32
32: ; preds = %27
%33 = or i64 %28, 1
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %45, label %37
37: ; preds = %32
%38 = add nuw nsw i64 %28, 2
%39 = icmp eq i64 %38, 256
br i1 %39, label %40, label %27
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %32, %27
%46 = phi i64 [ %28, %27 ], [ %33, %32 ]
%47 = trunc i64 %46 to i32
%48 = add nuw i64 %46, 1
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%51 = and i64 %48, 4294967295
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %51
%53 = sub nuw nsw i32 255, %47
%54 = call i32 @print_hexbuf(i8* %52, i32 %53)
%55 = call i32 @putchar(i32 10)
ret void
}