#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 */

/* Variables and functions */
int /*<<< orphan*/ curs_set_volume(int);
int mpgedit_play_volume_get(void *, int *, int *);
int /*<<< orphan*/ mpgedit_play_volume_set(void *, int, int);
int curs_volume_increase(void *playctx) {
  int rvol;
  int lvol;
  int volume;
  int sts;
  if (!playctx) {
    return -1;
  }
  sts = mpgedit_play_volume_get(playctx, &lvol, &rvol);
  if (sts == -1) {
    return -1;
  }
  volume = (lvol + rvol) / 2;
  volume += 2;
  volume = (volume > 100) ? 100 : volume;
  mpgedit_play_volume_set(playctx, volume, volume);
  curs_set_volume(volume);
  return volume;
}


x86 assembly (clang, -O0):
<curs_volume_increase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <curs_volume_increase+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <curs_volume_increase+0xa7>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <mpgedit_play_volume_get@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    117d <curs_volume_increase+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <curs_volume_increase+0xa7>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jle    11ae <curs_volume_increase+0x7e>
mov    $0x64,%eax
mov    %eax,-0x24(%rbp)
jmp    11b4 <curs_volume_increase+0x84>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <mpgedit_play_volume_set@plt>
mov    -0x1c(%rbp),%edi
call   1050 <curs_set_volume@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curs_volume_increase>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     1184 <curs_volume_increase+0x54>
mov    %rdi,%r14
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1030 <mpgedit_play_volume_get@plt>
cmp    $0xffffffff,%eax
je     1184 <curs_volume_increase+0x54>
mov    0x4(%rsp),%eax
add    (%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cmp    $0x62,%ecx
mov    $0x62,%ebx
cmovl  %ecx,%ebx
add    $0x2,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
call   1040 <mpgedit_play_volume_set@plt>
mov    %ebx,%edi
call   1050 <curs_set_volume@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @curs_volume_increase(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 -1, i32* %2
br label %38
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @mpgedit_play_volume_get(i8* %12, i32* %5, i32* %4)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %2
br label %38
17: ; preds = %11
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = add nsw i32 %18, %19
%21 = sdiv i32 %20, 2
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 2
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 100
br i1 %25, label %26, label %27
26: ; preds = %17
br label %29
27: ; preds = %17
%28 = load i32, i32* %6
br label %29
29: ; preds = %27, %26
%30 = phi i32 [ 100, %26 ], [ %28, %27 ]
store i32 %30, i32* %6
%31 = load i8*, i8** %3
%32 = load i32, i32* %6
%33 = load i32, i32* %6
%34 = call i32 @mpgedit_play_volume_set(i8* %31, i32 %32, i32 %33)
%35 = load i32, i32* %6
%36 = call i32 @curs_set_volume(i32 %35)
%37 = load i32, i32* %6
store i32 %37, i32* %2
br label %38
38: ; preds = %29, %16, %10
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
define i32 @curs_volume_increase(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = icmp eq i8* %0, null
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = call i32 @mpgedit_play_volume_get(i8* %0, i32* %3, i32* %2)
%9 = icmp eq i32 %8, -1
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = add nsw i32 %12, %11
%14 = sdiv i32 %13, 2
%15 = icmp slt i32 %14, 98
%16 = select i1 %15, i32 %14, i32 98
%17 = add nsw i32 %16, 2
%18 = call i32 @mpgedit_play_volume_set(i8* %0, i32 %17, i32 %17)
%19 = call i32 @curs_set_volume(i32 %17)
br label %20
20: ; preds = %7, %1, %10
%21 = phi i32 [ %17, %10 ], [ -1, %1 ], [ -1, %7 ]
ret i32 %21
}