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

/* Variables and functions */
int /*<<< orphan*/ PKCS12_F_PKCS12_NEWPASS;
int /*<<< orphan*/ PKCS12_R_INVALID_NULL_PKCS12_POINTER;
int /*<<< orphan*/ PKCS12_R_MAC_VERIFY_FAILURE;
int /*<<< orphan*/ PKCS12_R_PARSE_ERROR;
int /*<<< orphan*/ PKCS12_verify_mac(int /*<<< orphan*/ *, char const *, int);
int /*<<< orphan*/ PKCS12err(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ newpass_p12(int /*<<< orphan*/ *, char const *,
                               char const *);
int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass) {
  if (!p12) {
    PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_INVALID_NULL_PKCS12_POINTER);
    return 0;
  }
  if (!PKCS12_verify_mac(p12, oldpass, -1)) {
    PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_MAC_VERIFY_FAILURE);
    return 0;
  }
  if (!newpass_p12(p12, oldpass, newpass)) {
    PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_PARSE_ERROR);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<PKCS12_newpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1172 <PKCS12_newpass+0x42>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1040 <PKCS12err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <PKCS12_newpass+0xc4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xffffffff,%edx
call   1030 <PKCS12_verify_mac@plt>
cmp    $0x0,%eax
jne    11b0 <PKCS12_newpass+0x80>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
call   1040 <PKCS12err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <PKCS12_newpass+0xc4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <newpass_p12@plt>
cmp    $0x0,%eax
jne    11ed <PKCS12_newpass+0xbd>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
call   1040 <PKCS12err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <PKCS12_newpass+0xc4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS12_newpass>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1173 <PKCS12_newpass+0x43>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0xffffffff,%edx
call   1030 <PKCS12_verify_mac@plt>
test   %eax,%eax
je     117c <PKCS12_newpass+0x4c>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <newpass_p12@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1195 <PKCS12_newpass+0x65>
mov    0x2e77(%rip),%rax
jmp    1183 <PKCS12_newpass+0x53>
mov    0x2e66(%rip),%rax
jmp    1183 <PKCS12_newpass+0x53>
mov    0x2e4d(%rip),%rax
mov    0x2e3e(%rip),%rcx
mov    (%rcx),%edi
mov    (%rax),%esi
call   1040 <PKCS12err@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PKCS12_F_PKCS12_NEWPASS = global i32 0
@PKCS12_R_INVALID_NULL_PKCS12_POINTER = global i32 0
@PKCS12_R_MAC_VERIFY_FAILURE = global i32 0
@PKCS12_R_PARSE_ERROR = global i32 0
define i32 @PKCS12_newpass(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i32*, i32** %5
%9 = icmp ne i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i32, i32* @PKCS12_F_PKCS12_NEWPASS
%12 = load i32, i32* @PKCS12_R_INVALID_NULL_PKCS12_POINTER
%13 = call i32 @PKCS12err(i32 %11, i32 %12)
store i32 0, i32* %4
br label %34
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i8*, i8** %6
%17 = call i32 @PKCS12_verify_mac(i32* %15, i8* %16, i32 -1)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = load i32, i32* @PKCS12_F_PKCS12_NEWPASS
%21 = load i32, i32* @PKCS12_R_MAC_VERIFY_FAILURE
%22 = call i32 @PKCS12err(i32 %20, i32 %21)
store i32 0, i32* %4
br label %34
23: ; preds = %14
%24 = load i32*, i32** %5
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = call i32 @newpass_p12(i32* %24, i8* %25, i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %23
%30 = load i32, i32* @PKCS12_F_PKCS12_NEWPASS
%31 = load i32, i32* @PKCS12_R_PARSE_ERROR
%32 = call i32 @PKCS12err(i32 %30, i32 %31)
store i32 0, i32* %4
br label %34
33: ; preds = %23
store i32 1, i32* %4
br label %34
34: ; preds = %33, %29, %19, %10
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@PKCS12_F_PKCS12_NEWPASS = global i32 0
@PKCS12_R_INVALID_NULL_PKCS12_POINTER = global i32 0
@PKCS12_R_MAC_VERIFY_FAILURE = global i32 0
@PKCS12_R_PARSE_ERROR = global i32 0
define i32 @PKCS12_newpass(i32* %0, i8* %1, i8* %2) {
%4 = icmp eq i32* %0, null
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = tail call i32 @PKCS12_verify_mac(i32* %0, i8* %1, i32 -1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @newpass_p12(i32* %0, i8* %1, i8* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8, %5, %3
%12 = phi i32* [ @PKCS12_R_INVALID_NULL_PKCS12_POINTER, %3 ], [ @PKCS12_R_MAC_VERIFY_FAILURE, %5 ], [ @PKCS12_R_PARSE_ERROR, %8 ]
%13 = load i32, i32* @PKCS12_F_PKCS12_NEWPASS
%14 = load i32, i32* %12
%15 = tail call i32 @PKCS12err(i32 %13, i32 %14)
br label %16
16: ; preds = %11, %8
%17 = phi i32 [ 1, %8 ], [ 0, %11 ]
ret i32 %17
}