#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*/ WINDOW;
typedef int /*<<< orphan*/ PANEL;

/* Variables and functions */
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ *new_panel(int /*<<< orphan*/ *);
int /*<<< orphan*/ *newwin(int, int, int, int);
PANEL *mkpanel(int rows, int cols, int tly, int tlx) {
  WINDOW *win = newwin(rows, cols, tly, tlx);
  PANEL *pan = (PANEL *)0;
  if (win) {
    pan = new_panel(win);
    if (!pan)
      delwin(win);
  }
  return pan;
}


x86 assembly (clang, -O0):
<mkpanel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <newwin@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1192 <mkpanel+0x62>
mov    -0x18(%rbp),%rdi
call   1040 <new_panel@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118d <mkpanel+0x5d>
mov    -0x18(%rbp),%rdi
call   1050 <delwin@plt>
jmp    1192 <mkpanel+0x62>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkpanel>:
push   %rbx
call   1030 <newwin@plt>
test   %rax,%rax
je     1155 <mkpanel+0x25>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <new_panel@plt>
test   %rax,%rax
je     114d <mkpanel+0x1d>
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <delwin@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32* @mkpanel(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32* @newwin(i32 %0, i32 %1, i32 %2, i32 %3)
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i32* @new_panel(i32* %5)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @delwin(i32* %5)
br label %12
12: ; preds = %7, %10, %4
%13 = phi i32* [ %8, %7 ], [ null, %10 ], [ null, %4 ]
ret i32* %13
}