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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char *, char *);
int /*<<< orphan*/ BIO_reset(int /*<<< orphan*/ *);
int /*<<< orphan*/ CMS_ContentInfo_free(int /*<<< orphan*/ *);
int CMS_PARTIAL;
int CMS_STREAM;
int /*<<< orphan*/ CMS_add1_signer(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ *CMS_sign(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ EVP_PKEY_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
int /*<<< orphan*/ *PEM_read_bio_PrivateKey(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ *PEM_read_bio_X509(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ SMIME_write_CMS(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  BIO *in = NULL, *out = NULL, *tbio = NULL;
  X509 *scert = NULL, *scert2 = NULL;
  EVP_PKEY *skey = NULL, *skey2 = NULL;
  CMS_ContentInfo *cms = NULL;
  int ret = 1;
  OpenSSL_add_all_algorithms();
  ERR_load_crypto_strings();
  tbio = BIO_new_file("signer.pem", "r");
  if (!tbio)
    goto err;
  scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
  BIO_reset(tbio);
  skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
  BIO_free(tbio);
  tbio = BIO_new_file("signer2.pem", "r");
  if (!tbio)
    goto err;
  scert2 = PEM_read_bio_X509(tbio, NULL, 0, NULL);
  BIO_reset(tbio);
  skey2 = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
  if (!scert2 || !skey2)
    goto err;
  in = BIO_new_file("sign.txt", "r");
  if (!in)
    goto err;
  cms = CMS_sign(NULL, NULL, NULL, in, CMS_STREAM | CMS_PARTIAL);
  if (!cms)
    goto err;
  if (!CMS_add1_signer(cms, scert, skey, NULL, 0))
    goto err;
  if (!CMS_add1_signer(cms, scert2, skey2, NULL, 0))
    goto err;
  out = BIO_new_file("smout.txt", "w");
  if (!out)
    goto err;
  if (!SMIME_write_CMS(out, cms, in, CMS_STREAM))
    goto err;
  ret = 0;
err:
  if (ret) {
    fprintf(stderr, "Error Signing Data\n");
    ERR_print_errors_fp(stderr);
  }
  CMS_ContentInfo_free(cms);
  X509_free(scert);
  EVP_PKEY_free(skey);
  X509_free(scert2);
  EVP_PKEY_free(skey2);
  BIO_free(in);
  BIO_free(out);
  BIO_free(tbio);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
mov    $0x0,%al
call   1060 <OpenSSL_add_all_algorithms@plt>
mov    $0x0,%al
call   10b0 <ERR_load_crypto_strings@plt>
lea    0xd9e(%rip),%rdi
lea    0xda2(%rip),%rsi
call   1100 <BIO_new_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1282 <main+0x92>
jmp    143b <main+0x24b>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rsi
call   10e0 <PEM_read_bio_X509@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <BIO_reset@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rsi
call   10d0 <PEM_read_bio_PrivateKey@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <BIO_free@plt>
lea    0xd46(%rip),%rdi
lea    0xd3d(%rip),%rsi
call   1100 <BIO_new_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12e7 <main+0xf7>
jmp    143b <main+0x24b>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rsi
call   10e0 <PEM_read_bio_X509@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <BIO_reset@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rsi
call   10d0 <PEM_read_bio_PrivateKey@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1332 <main+0x142>
cmpq   $0x0,-0x48(%rbp)
jne    1337 <main+0x147>
jmp    143b <main+0x24b>
lea    0xcdb(%rip),%rdi
lea    0xcc6(%rip),%rsi
call   1100 <BIO_new_file@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    135e <main+0x16e>
jmp    143b <main+0x24b>
mov    -0x18(%rbp),%rcx
mov    0x2c7f(%rip),%rax
mov    (%rax),%r8d
mov    0x2c55(%rip),%rax
or     (%rax),%r8d
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1080 <CMS_sign@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1399 <main+0x1a9>
jmp    143b <main+0x24b>
mov    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   1040 <CMS_add1_signer@plt>
cmp    $0x0,%eax
jne    13bf <main+0x1cf>
jmp    143b <main+0x24b>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x48(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   1040 <CMS_add1_signer@plt>
cmp    $0x0,%eax
jne    13e5 <main+0x1f5>
jmp    143b <main+0x24b>
lea    0xc36(%rip),%rdi
lea    0xc39(%rip),%rsi
call   1100 <BIO_new_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    140c <main+0x21c>
jmp    143b <main+0x24b>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x2bc9(%rip),%rax
mov    (%rax),%ecx
call   1070 <SMIME_write_CMS@plt>
cmp    $0x0,%eax
jne    1434 <main+0x244>
jmp    143b <main+0x24b>
movl   $0x0,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     1468 <main+0x278>
mov    0x2b8c(%rip),%rax
mov    (%rax),%edi
lea    0xbd9(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
call   10f0 <ERR_print_errors_fp@plt>
mov    -0x50(%rbp),%rdi
call   1110 <CMS_ContentInfo_free@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <X509_free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <EVP_PKEY_free@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <X509_free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <EVP_PKEY_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    -0x20(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    -0x28(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %r12d,%r12d
xor    %eax,%eax
call   1060 <OpenSSL_add_all_algorithms@plt>
xor    %eax,%eax
call   10b0 <ERR_load_crypto_strings@plt>
lea    0xdea(%rip),%rdi
lea    0xdee(%rip),%rsi
call   1100 <BIO_new_file@plt>
test   %rax,%rax
je     13b0 <main+0x1c0>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10e0 <PEM_read_bio_X509@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   10c0 <BIO_reset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10d0 <PEM_read_bio_PrivateKey@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1090 <BIO_free@plt>
lea    0xda3(%rip),%rdi
lea    0xd9a(%rip),%rsi
call   1100 <BIO_new_file@plt>
test   %rax,%rax
mov    %r13,0x20(%rsp)
je     13cc <main+0x1dc>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10e0 <PEM_read_bio_X509@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   10c0 <BIO_reset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10d0 <PEM_read_bio_PrivateKey@plt>
mov    %rax,%rcx
mov    %rbp,%rax
mov    %rbp,0x18(%rsp)
test   %rbp,%rbp
mov    %rcx,0x10(%rsp)
je     13e1 <main+0x1f1>
test   %rcx,%rcx
je     13e1 <main+0x1f1>
lea    0xd3f(%rip),%rdi
lea    0xd2a(%rip),%rsi
call   1100 <BIO_new_file@plt>
test   %rax,%rax
je     13e6 <main+0x1f6>
mov    %rax,%r14
mov    %r15,0x8(%rsp)
mov    0x2cea(%rip),%rcx
mov    0x2cc3(%rip),%rax
mov    (%rax),%r8d
or     (%rcx),%r8d
xor    %r15d,%r15d
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %r14,%rcx
call   1080 <CMS_sign@plt>
test   %rax,%rax
je     146c <main+0x27c>
mov    %rax,%r12
xor    %r15d,%r15d
mov    %rax,%rdi
mov    0x8(%rsp),%rbp
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <CMS_add1_signer@plt>
test   %eax,%eax
je     1479 <main+0x289>
xor    %r15d,%r15d
mov    %r12,%rdi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <CMS_add1_signer@plt>
test   %eax,%eax
je     1481 <main+0x291>
mov    0x8(%rsp),%r13
lea    0xca9(%rip),%rdi
lea    0xcac(%rip),%rsi
call   1100 <BIO_new_file@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     148b <main+0x29b>
mov    %rax,%r15
mov    0x2c4e(%rip),%rax
mov    (%rax),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1070 <SMIME_write_CMS@plt>
test   %eax,%eax
jne    1415 <main+0x225>
jmp    13f2 <main+0x202>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    13ec <main+0x1fc>
mov    %r15,%r13
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %ebx,%ebx
jmp    13ec <main+0x1fc>
mov    %r15,%r13
jmp    13ec <main+0x1fc>
mov    %r15,%r13
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    0x2bdf(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc2b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
call   10f0 <ERR_print_errors_fp@plt>
mov    $0x1,%ebp
mov    %r12,%rdi
call   1110 <CMS_ContentInfo_free@plt>
mov    %r13,%rdi
call   10a0 <X509_free@plt>
mov    0x20(%rsp),%rdi
call   1030 <EVP_PKEY_free@plt>
mov    0x18(%rsp),%rdi
call   10a0 <X509_free@plt>
mov    0x10(%rsp),%rdi
call   1030 <EVP_PKEY_free@plt>
mov    %r14,%rdi
call   1090 <BIO_free@plt>
mov    %r15,%rdi
call   1090 <BIO_free@plt>
mov    %rbx,%rdi
call   1090 <BIO_free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%r13
xor    %r12d,%r12d
jmp    13f2 <main+0x202>
mov    %rbp,%r13
jmp    13f2 <main+0x202>
mov    0x8(%rsp),%r13
jmp    13f2 <main+0x202>
xor    %r15d,%r15d
jmp    13f2 <main+0x202>

LLVM IR (-O0):
@.str = [11 x i8] c"signer.pem\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"signer2.pem\00"
@.str.3 = [9 x i8] c"sign.txt\00"
@CMS_STREAM = global i32 0
@CMS_PARTIAL = global i32 0
@.str.4 = [10 x i8] c"smout.txt\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [20 x i8] c"Error Signing Data\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32* null, i32** %8
store i32* null, i32** %9
store i32* null, i32** %10
store i32* null, i32** %11
store i32* null, i32** %12
store i32* null, i32** %13
store i32 1, i32* %14
%15 = call i32 (...) @OpenSSL_add_all_algorithms()
%16 = call i32 (...) @ERR_load_crypto_strings()
%17 = call i32* @BIO_new_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp ne i32* %18, null
br i1 %19, label %21, label %20
20: ; preds = %2
br label %89
21: ; preds = %2
%22 = load i32*, i32** %8
%23 = call i32* @PEM_read_bio_X509(i32* %22, i32* null, i32 0, i32* null)
store i32* %23, i32** %9
%24 = load i32*, i32** %8
%25 = call i32 @BIO_reset(i32* %24)
%26 = load i32*, i32** %8
%27 = call i32* @PEM_read_bio_PrivateKey(i32* %26, i32* null, i32 0, i32* null)
store i32* %27, i32** %11
%28 = load i32*, i32** %8
%29 = call i32 @BIO_free(i32* %28)
%30 = call i32* @BIO_new_file(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %8
%31 = load i32*, i32** %8
%32 = icmp ne i32* %31, null
br i1 %32, label %34, label %33
33: ; preds = %21
br label %89
34: ; preds = %21
%35 = load i32*, i32** %8
%36 = call i32* @PEM_read_bio_X509(i32* %35, i32* null, i32 0, i32* null)
store i32* %36, i32** %10
%37 = load i32*, i32** %8
%38 = call i32 @BIO_reset(i32* %37)
%39 = load i32*, i32** %8
%40 = call i32* @PEM_read_bio_PrivateKey(i32* %39, i32* null, i32 0, i32* null)
store i32* %40, i32** %12
%41 = load i32*, i32** %10
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = load i32*, i32** %12
%45 = icmp ne i32* %44, null
br i1 %45, label %47, label %46
46: ; preds = %43, %34
br label %89
47: ; preds = %43
%48 = call i32* @BIO_new_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %48, i32** %6
%49 = load i32*, i32** %6
%50 = icmp ne i32* %49, null
br i1 %50, label %52, label %51
51: ; preds = %47
br label %89
52: ; preds = %47
%53 = load i32*, i32** %6
%54 = load i32, i32* @CMS_STREAM
%55 = load i32, i32* @CMS_PARTIAL
%56 = or i32 %54, %55
%57 = call i32* @CMS_sign(i32* null, i32* null, i32* null, i32* %53, i32 %56)
store i32* %57, i32** %13
%58 = load i32*, i32** %13
%59 = icmp ne i32* %58, null
br i1 %59, label %61, label %60
60: ; preds = %52
br label %89
61: ; preds = %52
%62 = load i32*, i32** %13
%63 = load i32*, i32** %9
%64 = load i32*, i32** %11
%65 = call i32 @CMS_add1_signer(i32* %62, i32* %63, i32* %64, i32* null, i32 0)
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %61
br label %89
68: ; preds = %61
%69 = load i32*, i32** %13
%70 = load i32*, i32** %10
%71 = load i32*, i32** %12
%72 = call i32 @CMS_add1_signer(i32* %69, i32* %70, i32* %71, i32* null, i32 0)
%73 = icmp ne i32 %72, 0
br i1 %73, label %75, label %74
74: ; preds = %68
br label %89
75: ; preds = %68
%76 = call i32* @BIO_new_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %76, i32** %7
%77 = load i32*, i32** %7
%78 = icmp ne i32* %77, null
br i1 %78, label %80, label %79
79: ; preds = %75
br label %89
80: ; preds = %75
%81 = load i32*, i32** %7
%82 = load i32*, i32** %13
%83 = load i32*, i32** %6
%84 = load i32, i32* @CMS_STREAM
%85 = call i32 @SMIME_write_CMS(i32* %81, i32* %82, i32* %83, i32 %84)
%86 = icmp ne i32 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %80
br label %89
88: ; preds = %80
store i32 0, i32* %14
br label %89
89: ; preds = %88, %87, %79, %74, %67, %60, %51, %46, %33, %20
%90 = load i32, i32* %14
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%95 = load i32, i32* @stderr
%96 = call i32 @ERR_print_errors_fp(i32 %95)
br label %97
97: ; preds = %92, %89
%98 = load i32*, i32** %13
%99 = call i32 @CMS_ContentInfo_free(i32* %98)
%100 = load i32*, i32** %9
%101 = call i32 @X509_free(i32* %100)
%102 = load i32*, i32** %11
%103 = call i32 @EVP_PKEY_free(i32* %102)
%104 = load i32*, i32** %10
%105 = call i32 @X509_free(i32* %104)
%106 = load i32*, i32** %12
%107 = call i32 @EVP_PKEY_free(i32* %106)
%108 = load i32*, i32** %6
%109 = call i32 @BIO_free(i32* %108)
%110 = load i32*, i32** %7
%111 = call i32 @BIO_free(i32* %110)
%112 = load i32*, i32** %8
%113 = call i32 @BIO_free(i32* %112)
%114 = load i32, i32* %14
ret i32 %114
}

LLVM IR (-O2):
@.str = [11 x i8] c"signer.pem\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"signer2.pem\00"
@.str.3 = [9 x i8] c"sign.txt\00"
@CMS_STREAM = global i32 0
@CMS_PARTIAL = global i32 0
@.str.4 = [10 x i8] c"smout.txt\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [20 x i8] c"Error Signing Data\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @OpenSSL_add_all_algorithms()
%4 = tail call i32 (...) @ERR_load_crypto_strings()
%5 = tail call i32* @BIO_new_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %43, label %7
7: ; preds = %2
%8 = tail call i32* @PEM_read_bio_X509(i32* %5, i32* null, i32 0, i32* null)
%9 = tail call i32 @BIO_reset(i32* %5)
%10 = tail call i32* @PEM_read_bio_PrivateKey(i32* %5, i32* null, i32 0, i32* null)
%11 = tail call i32 @BIO_free(i32* %5)
%12 = tail call i32* @BIO_new_file(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %43, label %14
14: ; preds = %7
%15 = tail call i32* @PEM_read_bio_X509(i32* %12, i32* null, i32 0, i32* null)
%16 = tail call i32 @BIO_reset(i32* %12)
%17 = tail call i32* @PEM_read_bio_PrivateKey(i32* %12, i32* null, i32 0, i32* null)
%18 = icmp ne i32* %15, null
%19 = icmp ne i32* %17, null
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %21, label %43
21: ; preds = %14
%22 = tail call i32* @BIO_new_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %43, label %24
24: ; preds = %21
%25 = load i32, i32* @CMS_STREAM
%26 = load i32, i32* @CMS_PARTIAL
%27 = or i32 %26, %25
%28 = tail call i32* @CMS_sign(i32* null, i32* null, i32* null, i32* %22, i32 %27)
%29 = icmp eq i32* %28, null
br i1 %29, label %43, label %30
30: ; preds = %24
%31 = tail call i32 @CMS_add1_signer(i32* %28, i32* %8, i32* %10, i32* null, i32 0)
%32 = icmp eq i32 %31, 0
br i1 %32, label %43, label %33
33: ; preds = %30
%34 = tail call i32 @CMS_add1_signer(i32* %28, i32* %15, i32* %17, i32* null, i32 0)
%35 = icmp eq i32 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %33
%37 = tail call i32* @BIO_new_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %43, label %39
39: ; preds = %36
%40 = load i32, i32* @CMS_STREAM
%41 = tail call i32 @SMIME_write_CMS(i32* %37, i32* %28, i32* %22, i32 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %2, %7, %14, %21, %24, %30, %33, %36, %39
%44 = phi i32* [ %28, %39 ], [ %28, %36 ], [ %28, %33 ], [ %28, %30 ], [ null, %24 ], [ null, %21 ], [ null, %14 ], [ null, %7 ], [ null, %2 ]
%45 = phi i32* [ %17, %39 ], [ %17, %36 ], [ %17, %33 ], [ %17, %30 ], [ %17, %24 ], [ %17, %21 ], [ %17, %14 ], [ null, %7 ], [ null, %2 ]
%46 = phi i32* [ %10, %39 ], [ %10, %36 ], [ %10, %33 ], [ %10, %30 ], [ %10, %24 ], [ %10, %21 ], [ %10, %14 ], [ %10, %7 ], [ null, %2 ]
%47 = phi i32* [ %15, %39 ], [ %15, %36 ], [ %15, %33 ], [ %15, %30 ], [ %15, %24 ], [ %15, %21 ], [ %15, %14 ], [ null, %7 ], [ null, %2 ]
%48 = phi i32* [ %8, %39 ], [ %8, %36 ], [ %8, %33 ], [ %8, %30 ], [ %8, %24 ], [ %8, %21 ], [ %8, %14 ], [ %8, %7 ], [ null, %2 ]
%49 = phi i32* [ %12, %39 ], [ %12, %36 ], [ %12, %33 ], [ %12, %30 ], [ %12, %24 ], [ %12, %21 ], [ %12, %14 ], [ null, %7 ], [ null, %2 ]
%50 = phi i32* [ %37, %39 ], [ null, %36 ], [ null, %33 ], [ null, %30 ], [ null, %24 ], [ null, %21 ], [ null, %14 ], [ null, %7 ], [ null, %2 ]
%51 = phi i32* [ %22, %39 ], [ %22, %36 ], [ %22, %33 ], [ %22, %30 ], [ %22, %24 ], [ null, %21 ], [ null, %14 ], [ null, %7 ], [ null, %2 ]
%52 = load i32, i32* @stderr
%53 = tail call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%54 = load i32, i32* @stderr
%55 = tail call i32 @ERR_print_errors_fp(i32 %54)
br label %56
56: ; preds = %43, %39
%57 = phi i32 [ 1, %43 ], [ 0, %39 ]
%58 = phi i32* [ %44, %43 ], [ %28, %39 ]
%59 = phi i32* [ %45, %43 ], [ %17, %39 ]
%60 = phi i32* [ %46, %43 ], [ %10, %39 ]
%61 = phi i32* [ %47, %43 ], [ %15, %39 ]
%62 = phi i32* [ %48, %43 ], [ %8, %39 ]
%63 = phi i32* [ %49, %43 ], [ %12, %39 ]
%64 = phi i32* [ %50, %43 ], [ %37, %39 ]
%65 = phi i32* [ %51, %43 ], [ %22, %39 ]
%66 = tail call i32 @CMS_ContentInfo_free(i32* %58)
%67 = tail call i32 @X509_free(i32* %62)
%68 = tail call i32 @EVP_PKEY_free(i32* %60)
%69 = tail call i32 @X509_free(i32* %61)
%70 = tail call i32 @EVP_PKEY_free(i32* %59)
%71 = tail call i32 @BIO_free(i32* %65)
%72 = tail call i32 @BIO_free(i32* %64)
%73 = tail call i32 @BIO_free(i32* %63)
ret i32 %57
}