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

/* Variables and functions */
int /*<<< orphan*/ gsm0710_write_frame(struct gsm0710_context *, int, int,
                                       int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ is_channel_used(struct gsm0710_context *, int);
int /*<<< orphan*/ mark_channel_unused(struct gsm0710_context *, int);
void gsm0710_close_channel(struct gsm0710_context *ctx, int channel) {
  if (channel <= 0 || channel > 63)
    return;
  if (!is_channel_used(ctx, channel))
    return;
  mark_channel_unused(ctx, channel);
  gsm0710_write_frame(ctx, channel, 0x53, 0, 0);
}


x86 assembly (clang, -O0):
<gsm0710_close_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1153 <gsm0710_close_channel+0x23>
cmpl   $0x3f,-0xc(%rbp)
jle    1158 <gsm0710_close_channel+0x28>
jmp    1195 <gsm0710_close_channel+0x65>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <is_channel_used@plt>
cmp    $0x0,%eax
jne    1172 <gsm0710_close_channel+0x42>
jmp    1195 <gsm0710_close_channel+0x65>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <mark_channel_unused@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x53,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <gsm0710_write_frame@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsm0710_close_channel>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
lea    -0x40(%rbx),%eax
cmp    $0xffffffc1,%eax
jb     1171 <gsm0710_close_channel+0x41>
mov    %rdi,%r14
mov    %ebx,%esi
call   1040 <is_channel_used@plt>
test   %eax,%eax
je     1171 <gsm0710_close_channel+0x41>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <mark_channel_unused@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x53,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <gsm0710_write_frame@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.gsm0710_context = type { i32 }
define void @gsm0710_close_channel(%struct.gsm0710_context* %0, i32 %1) {
%3 = alloca %struct.gsm0710_context*
%4 = alloca i32
store %struct.gsm0710_context* %0, %struct.gsm0710_context** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sle i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 63
br i1 %9, label %10, label %11
10: ; preds = %7, %2
br label %24
11: ; preds = %7
%12 = load %struct.gsm0710_context*, %struct.gsm0710_context** %3
%13 = load i32, i32* %4
%14 = call i32 @is_channel_used(%struct.gsm0710_context* %12, i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %11
br label %24
17: ; preds = %11
%18 = load %struct.gsm0710_context*, %struct.gsm0710_context** %3
%19 = load i32, i32* %4
%20 = call i32 @mark_channel_unused(%struct.gsm0710_context* %18, i32 %19)
%21 = load %struct.gsm0710_context*, %struct.gsm0710_context** %3
%22 = load i32, i32* %4
%23 = call i32 @gsm0710_write_frame(%struct.gsm0710_context* %21, i32 %22, i32 83, i32 0, i32 0)
br label %24
24: ; preds = %17, %16, %10
ret void
}

LLVM IR (-O2):
%struct.gsm0710_context = type { i32 }
define void @gsm0710_close_channel(%struct.gsm0710_context* %0, i32 %1) {
%3 = add i32 %1, -64
%4 = icmp ult i32 %3, -63
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32 @is_channel_used(%struct.gsm0710_context* %0, i32 %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @mark_channel_unused(%struct.gsm0710_context* %0, i32 %1)
%10 = tail call i32 @gsm0710_write_frame(%struct.gsm0710_context* %0, i32 %1, i32 83, i32 0, i32 0)
br label %11
11: ; preds = %5, %2, %8
ret void
}