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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char *, char *);
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ *PEM_read_bio_X509(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
long X509_get_pathlen(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int ac, char **av) {
  X509 *x = NULL;
  BIO *b = NULL;
  long pathlen;
  int ret = 1;
  if (ac != 2) {
    fprintf(stderr, "Usage error\n");
    goto end;
  }
  b = BIO_new_file(av[1], "r");
  if (b == NULL)
    goto end;
  x = PEM_read_bio_X509(b, NULL, NULL, NULL);
  if (x == NULL)
    goto end;
  pathlen = X509_get_pathlen(x);
  if (pathlen == 6)
    ret = 0;
end:
  ERR_print_errors_fp(stderr);
  BIO_free(b);
  X509_free(x);
  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)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c1 <main+0x51>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1234 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1090 <BIO_new_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e9 <main+0x79>
jmp    1234 <main+0xc4>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1070 <PEM_read_bio_X509@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1210 <main+0xa0>
jmp    1234 <main+0xc4>
mov    -0x18(%rbp),%rdi
call   1030 <X509_get_pathlen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x6,-0x28(%rbp)
jne    122f <main+0xbf>
movl   $0x0,-0x2c(%rbp)
jmp    1234 <main+0xc4>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    -0x20(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <X509_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11ca <main+0x5a>
mov    0x8(%rsi),%rdi
lea    0xe86(%rip),%rsi
call   1090 <BIO_new_file@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     11e5 <main+0x75>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1070 <PEM_read_bio_X509@plt>
test   %rax,%rax
je     11e9 <main+0x79>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <X509_get_pathlen@plt>
xor    %r14d,%r14d
cmp    $0x6,%rax
setne  %r14b
mov    %r15,%rbp
jmp    11e9 <main+0x79>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %rbp,%rdi
call   1060 <X509_free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"Usage error\0A\00"
@.str.1 = [2 x i8] c"r\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 i64
%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 1, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %36
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @BIO_new_file(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %15
br label %36
23: ; preds = %15
%24 = load i32*, i32** %7
%25 = call i32* @PEM_read_bio_X509(i32* %24, i32* null, i32* null, i32* null)
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23
br label %36
29: ; preds = %23
%30 = load i32*, i32** %6
%31 = call i64 @X509_get_pathlen(i32* %30)
store i64 %31, i64* %8
%32 = load i64, i64* %8
%33 = icmp eq i64 %32, 6
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 0, i32* %9
br label %35
35: ; preds = %34, %29
br label %36
36: ; preds = %35, %28, %22, %12
%37 = load i32, i32* @stderr
%38 = call i32 @ERR_print_errors_fp(i32 %37)
%39 = load i32*, i32** %7
%40 = call i32 @BIO_free(i32* %39)
%41 = load i32*, i32** %6
%42 = call i32 @X509_free(i32* %41)
%43 = load i32, i32* %9
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"Usage error\0A\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %19
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @BIO_new_file(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %19, label %12
12: ; preds = %7
%13 = tail call i32* @PEM_read_bio_X509(i32* %10, i32* null, i32* null, i32* null)
%14 = icmp eq i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call i64 @X509_get_pathlen(i32* %13)
%17 = icmp ne i64 %16, 6
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %7, %4
%20 = phi i32* [ null, %4 ], [ null, %7 ], [ %10, %12 ], [ %10, %15 ]
%21 = phi i32* [ null, %4 ], [ null, %7 ], [ null, %12 ], [ %13, %15 ]
%22 = phi i32 [ 1, %4 ], [ 1, %7 ], [ 1, %12 ], [ %18, %15 ]
%23 = load i32, i32* @stderr
%24 = tail call i32 @ERR_print_errors_fp(i32 %23)
%25 = tail call i32 @BIO_free(i32* %20)
%26 = tail call i32 @X509_free(i32* %21)
ret i32 %22
}