#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 */
struct sx_prefix {
  int dummy;
};

/* Variables and functions */
struct sx_prefix *sx_prefix_alloc(int /*<<< orphan*/ *);
int /*<<< orphan*/ sx_prefix_destroy(struct sx_prefix *);
int /*<<< orphan*/ sx_prefix_parse(struct sx_prefix *, int, char *);
struct sx_prefix *sx_prefix_new(int af, char *text) {
  struct sx_prefix *p = NULL;
  if (!text)
    return NULL;
  p = sx_prefix_alloc(NULL);
  if (!p)
    return NULL;
  if (!sx_prefix_parse(p, af, text)) {
    sx_prefix_destroy(p);
    return NULL;
  };
  return p;
}


x86 assembly (clang, -O0):
<sx_prefix_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115f <sx_prefix_new+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    11bb <sx_prefix_new+0x8b>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <sx_prefix_alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1184 <sx_prefix_new+0x54>
movq   $0x0,-0x8(%rbp)
jmp    11bb <sx_prefix_new+0x8b>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <sx_prefix_parse@plt>
cmp    $0x0,%eax
jne    11b3 <sx_prefix_new+0x83>
mov    -0x20(%rbp),%rdi
call   1050 <sx_prefix_destroy@plt>
movq   $0x0,-0x8(%rbp)
jmp    11bb <sx_prefix_new+0x8b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sx_prefix_new>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1170 <sx_prefix_new+0x40>
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <sx_prefix_alloc@plt>
test   %rax,%rax
je     1172 <sx_prefix_new+0x42>
mov    %rax,%r15
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1030 <sx_prefix_parse@plt>
test   %eax,%eax
je     1168 <sx_prefix_new+0x38>
mov    %r15,%rbx
jmp    1172 <sx_prefix_new+0x42>
mov    %r15,%rdi
call   1050 <sx_prefix_destroy@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sx_prefix = type { i32 }
define %struct.sx_prefix* @sx_prefix_new(i32 %0, i8* %1) {
%3 = alloca %struct.sx_prefix*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.sx_prefix*
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.sx_prefix* null, %struct.sx_prefix** %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store %struct.sx_prefix* null, %struct.sx_prefix** %3
br label %26
10: ; preds = %2
%11 = call %struct.sx_prefix* @sx_prefix_alloc(i32* null)
store %struct.sx_prefix* %11, %struct.sx_prefix** %6
%12 = load %struct.sx_prefix*, %struct.sx_prefix** %6
%13 = icmp ne %struct.sx_prefix* %12, null
br i1 %13, label %15, label %14
14: ; preds = %10
store %struct.sx_prefix* null, %struct.sx_prefix** %3
br label %26
15: ; preds = %10
%16 = load %struct.sx_prefix*, %struct.sx_prefix** %6
%17 = load i32, i32* %4
%18 = load i8*, i8** %5
%19 = call i32 @sx_prefix_parse(%struct.sx_prefix* %16, i32 %17, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = load %struct.sx_prefix*, %struct.sx_prefix** %6
%23 = call i32 @sx_prefix_destroy(%struct.sx_prefix* %22)
store %struct.sx_prefix* null, %struct.sx_prefix** %3
br label %26
24: ; preds = %15
%25 = load %struct.sx_prefix*, %struct.sx_prefix** %6
store %struct.sx_prefix* %25, %struct.sx_prefix** %3
br label %26
26: ; preds = %24, %21, %14, %9
%27 = load %struct.sx_prefix*, %struct.sx_prefix** %3
ret %struct.sx_prefix* %27
}

LLVM IR (-O2):
%struct.sx_prefix = type { i32 }
define %struct.sx_prefix* @sx_prefix_new(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call %struct.sx_prefix* @sx_prefix_alloc(i32* null)
%6 = icmp eq %struct.sx_prefix* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i32 @sx_prefix_parse(%struct.sx_prefix* %5, i32 %0, i8* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @sx_prefix_destroy(%struct.sx_prefix* %5)
br label %12
12: ; preds = %7, %4, %2, %10
%13 = phi %struct.sx_prefix* [ null, %10 ], [ null, %2 ], [ null, %4 ], [ %5, %7 ]
ret %struct.sx_prefix* %13
}