#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_NAME;

/* Variables and functions */
int /*<<< orphan*/ *X509_NAME_dup(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_NAME_free(int /*<<< orphan*/ *);
int X509_NAME_set(X509_NAME **xn, X509_NAME *name) {
  X509_NAME *in;
  if (!xn || !name)
    return (0);
  if (*xn != name) {
    in = X509_NAME_dup(name);
    if (in != NULL) {
      X509_NAME_free(*xn);
      *xn = in;
    }
  }
  return (*xn != NULL);
}


x86 assembly (clang, -O0):
<X509_NAME_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <X509_NAME_set+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <X509_NAME_set+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11aa <X509_NAME_set+0x8a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
je     1197 <X509_NAME_set+0x77>
mov    -0x18(%rbp),%rdi
call   1030 <X509_NAME_dup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1192 <X509_NAME_set+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <X509_NAME_free@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1197 <X509_NAME_set+0x77>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_NAME_set>:
xor    %eax,%eax
test   %rdi,%rdi
je     1168 <X509_NAME_set+0x48>
test   %rsi,%rsi
je     1168 <X509_NAME_set+0x48>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    %rsi,(%rdi)
je     1159 <X509_NAME_set+0x39>
mov    %rsi,%rdi
call   1030 <X509_NAME_dup@plt>
mov    (%rbx),%rsi
test   %rax,%rax
je     1159 <X509_NAME_set+0x39>
mov    %rax,%r14
mov    %rsi,%rdi
call   1040 <X509_NAME_free@plt>
mov    %r14,(%rbx)
mov    %r14,%rsi
xor    %eax,%eax
test   %rsi,%rsi
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @X509_NAME_set(i32** %0, i32* %1) {
%3 = icmp ne i32** %0, null
%4 = icmp ne i32* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = load i32*, i32** %0
%8 = icmp eq i32* %7, %1
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32* @X509_NAME_dup(i32* %1)
%11 = icmp eq i32* %10, null
%12 = load i32*, i32** %0
br i1 %11, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @X509_NAME_free(i32* %12)
store i32* %10, i32** %0
br label %15
15: ; preds = %9, %13, %6
%16 = phi i32* [ %10, %13 ], [ %1, %6 ], [ %12, %9 ]
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %2, %15
%20 = phi i32 [ %18, %15 ], [ 0, %2 ]
ret i32 %20
}