#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 surface_t {
  int dummy;
};

/* Variables and functions */
struct surface_t *duplicate_surface(struct surface_t *);
int /*<<< orphan*/ free_surface(struct surface_t *);
int /*<<< orphan*/ leave_main_lock();
struct surface_t *resize(struct surface_t *, int, int);
struct surface_t *
leave_main_lock_and_resize_surface(struct surface_t *in_surface, int width,
                                   int height) {
  struct surface_t *duplicate, *resized;
  duplicate = duplicate_surface(in_surface);
  leave_main_lock();
  resized = resize(duplicate, width, height);
  free_surface(duplicate);
  return resized;
}


x86 assembly (clang, -O0):
<leave_main_lock_and_resize_surface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <duplicate_surface@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <leave_main_lock@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <resize@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <free_surface@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leave_main_lock_and_resize_surface>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
call   1040 <duplicate_surface@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <leave_main_lock@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <resize@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1060 <free_surface@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.surface_t = type { i32 }
define %struct.surface_t* @leave_main_lock_and_resize_surface(%struct.surface_t* %0, i32 %1, i32 %2) {
%4 = alloca %struct.surface_t*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.surface_t*
%8 = alloca %struct.surface_t*
store %struct.surface_t* %0, %struct.surface_t** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load %struct.surface_t*, %struct.surface_t** %4
%10 = call %struct.surface_t* @duplicate_surface(%struct.surface_t* %9)
store %struct.surface_t* %10, %struct.surface_t** %7
%11 = call i32 (...) @leave_main_lock()
%12 = load %struct.surface_t*, %struct.surface_t** %7
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call %struct.surface_t* @resize(%struct.surface_t* %12, i32 %13, i32 %14)
store %struct.surface_t* %15, %struct.surface_t** %8
%16 = load %struct.surface_t*, %struct.surface_t** %7
%17 = call i32 @free_surface(%struct.surface_t* %16)
%18 = load %struct.surface_t*, %struct.surface_t** %8
ret %struct.surface_t* %18
}

LLVM IR (-O2):
%struct.surface_t = type { i32 }
define %struct.surface_t* @leave_main_lock_and_resize_surface(%struct.surface_t* %0, i32 %1, i32 %2) {
%4 = tail call %struct.surface_t* @duplicate_surface(%struct.surface_t* %0)
%5 = tail call i32 (...) @leave_main_lock()
%6 = tail call %struct.surface_t* @resize(%struct.surface_t* %4, i32 %1, i32 %2)
%7 = tail call i32 @free_surface(%struct.surface_t* %4)
ret %struct.surface_t* %6
}