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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char *, char *);
int /*<<< orphan*/ CMS_ContentInfo_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ CMS_uncompress(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
int /*<<< orphan*/ *SMIME_read_CMS(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  BIO *in = NULL, *out = NULL;
  CMS_ContentInfo *cms = NULL;
  int ret = 1;
  OpenSSL_add_all_algorithms();
  ERR_load_crypto_strings();
  in = BIO_new_file("smcomp.txt", "r");
  if (!in)
    goto err;
  cms = SMIME_read_CMS(in, NULL);
  if (!cms)
    goto err;
  out = BIO_new_file("smuncomp.txt", "w");
  if (!out)
    goto err;
  if (!CMS_uncompress(cms, out, NULL, 0))
    goto err;
  ret = 0;
err:
  if (ret) {
    fprintf(stderr, "Error Uncompressing Data\n");
    ERR_print_errors_fp(stderr);
  }
  CMS_ContentInfo_free(cms);
  BIO_free(in);
  BIO_free(out);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
movl   $0x1,-0x2c(%rbp)
mov    $0x0,%al
call   1060 <OpenSSL_add_all_algorithms@plt>
mov    $0x0,%al
call   1080 <ERR_load_crypto_strings@plt>
lea    0xe26(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   10a0 <BIO_new_file@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fa <main+0x6a>
jmp    126a <main+0xda>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <SMIME_read_CMS@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    121b <main+0x8b>
jmp    126a <main+0xda>
lea    0xdeb(%rip),%rdi
lea    0xdf1(%rip),%rsi
call   10a0 <BIO_new_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1242 <main+0xb2>
jmp    126a <main+0xda>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1030 <CMS_uncompress@plt>
cmp    $0x0,%eax
jne    1263 <main+0xd3>
jmp    126a <main+0xda>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1297 <main+0x107>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <CMS_ContentInfo_free@plt>
mov    -0x18(%rbp),%rdi
call   1070 <BIO_free@plt>
mov    -0x20(%rbp),%rdi
call   1070 <BIO_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <OpenSSL_add_all_algorithms@plt>
xor    %eax,%eax
call   1080 <ERR_load_crypto_strings@plt>
lea    0xe4f(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10a0 <BIO_new_file@plt>
mov    %rax,%r14
test   %rax,%rax
je     1219 <main+0x89>
xor    %r13d,%r13d
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <SMIME_read_CMS@plt>
mov    $0x0,%r15d
test   %rax,%rax
je     121c <main+0x8c>
mov    %rax,%rbx
lea    0xe26(%rip),%rdi
lea    0xe2c(%rip),%rsi
call   10a0 <BIO_new_file@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1216 <main+0x86>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <CMS_uncompress@plt>
mov    %rbx,%r13
test   %eax,%eax
jne    1241 <main+0xb1>
jmp    121c <main+0x8c>
mov    %rbx,%r13
xor    %r15d,%r15d
mov    0x2dbd(%rip),%rbx
mov    (%rbx),%edi
lea    0xdf0(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1090 <ERR_print_errors_fp@plt>
mov    $0x1,%r12d
mov    %r13,%rbx
mov    %rbx,%rdi
call   10b0 <CMS_ContentInfo_free@plt>
mov    %r14,%rdi
call   1070 <BIO_free@plt>
mov    %r15,%rdi
call   1070 <BIO_free@plt>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"smcomp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"smuncomp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [26 x i8] c"Error Uncompressing 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
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 1, i32* %9
%10 = call i32 (...) @OpenSSL_add_all_algorithms()
%11 = call i32 (...) @ERR_load_crypto_strings()
%12 = 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* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %2
br label %34
16: ; preds = %2
%17 = load i32*, i32** %6
%18 = call i32* @SMIME_read_CMS(i32* %17, i32* null)
store i32* %18, i32** %8
%19 = load i32*, i32** %8
%20 = icmp ne i32* %19, null
br i1 %20, label %22, label %21
21: ; preds = %16
br label %34
22: ; preds = %16
%23 = call i32* @BIO_new_file(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp ne i32* %24, null
br i1 %25, label %27, label %26
26: ; preds = %22
br label %34
27: ; preds = %22
%28 = load i32*, i32** %8
%29 = load i32*, i32** %7
%30 = call i32 @CMS_uncompress(i32* %28, i32* %29, i32* null, i32 0)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %27
br label %34
33: ; preds = %27
store i32 0, i32* %9
br label %34
34: ; preds = %33, %32, %26, %21, %15
%35 = load i32, i32* %9
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* @stderr
%41 = call i32 @ERR_print_errors_fp(i32 %40)
br label %42
42: ; preds = %37, %34
%43 = load i32*, i32** %8
%44 = call i32 @CMS_ContentInfo_free(i32* %43)
%45 = load i32*, i32** %6
%46 = call i32 @BIO_free(i32* %45)
%47 = load i32*, i32** %7
%48 = call i32 @BIO_free(i32* %47)
%49 = load i32, i32* %9
ret i32 %49
}

LLVM IR (-O2):
@.str = [11 x i8] c"smcomp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"smuncomp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [26 x i8] c"Error Uncompressing 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 %16, label %7
7: ; preds = %2
%8 = tail call i32* @SMIME_read_CMS(i32* %5, i32* null)
%9 = icmp eq i32* %8, null
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = tail call i32* @BIO_new_file(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @CMS_uncompress(i32* %8, i32* %11, i32* null, i32 0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %2, %7, %10, %13
%17 = phi i32* [ %8, %13 ], [ %8, %10 ], [ null, %7 ], [ null, %2 ]
%18 = phi i32* [ %11, %13 ], [ null, %10 ], [ null, %7 ], [ null, %2 ]
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @ERR_print_errors_fp(i32 %21)
br label %23
23: ; preds = %16, %13
%24 = phi i32 [ 1, %16 ], [ 0, %13 ]
%25 = phi i32* [ %17, %16 ], [ %8, %13 ]
%26 = phi i32* [ %18, %16 ], [ %11, %13 ]
%27 = tail call i32 @CMS_ContentInfo_free(i32* %25)
%28 = tail call i32 @BIO_free(i32* %5)
%29 = tail call i32 @BIO_free(i32* %26)
ret i32 %24
}