#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 *rotate_surface(struct surface_t *, int, int, double);
struct surface_t *
leave_main_lock_and_rotate_surface(struct surface_t *in_surface,
                                   int scale_width, int scale_height,
                                   double theta) {
  struct surface_t *duplicate, *rotated;
  duplicate = duplicate_surface(in_surface);
  leave_main_lock();
  rotated = rotate_surface(duplicate, scale_width, scale_height, theta);
  free_surface(duplicate);
  return rotated;
}


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

x86 assembly (clang, -O2):
<leave_main_lock_and_rotate_surface>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r14d
mov    %esi,%ebp
call   1050 <duplicate_surface@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <leave_main_lock@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
movsd  0x8(%rsp),%xmm0
call   1030 <rotate_surface@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1060 <free_surface@plt>
mov    %rbp,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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