#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*/ exec(char **);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void setvolume(int v) {
  if (v > 100)
    v = 100;
  if (v < 0)
    v = 0;
  char *args[4] = {"mmusicd", "set-volume", NULL, NULL};
  args[2] = malloc(sizeof(char) * 4);
  sprintf(args[2], "%i", v);
  exec(args);
}


x86 assembly (clang, -O0):
<setvolume>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jle    114c <setvolume+0x1c>
movl   $0x64,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115d <setvolume+0x2d>
movl   $0x0,-0x4(%rbp)
mov    0x2c9c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c99(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c96(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c93(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe6e(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <exec@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setvolume>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x64,%edi
mov    $0x64,%eax
cmovl  %edi,%eax
xor    %ebx,%ebx
test   %eax,%eax
cmovns %eax,%ebx
movaps 0x2cc2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2ca6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%rsp)
lea    0xe9f(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1040 <sprintf@plt>
mov    %rsp,%rdi
call   1050 <exec@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"mmusicd\00"
@.str.1 = [11 x i8] c"set-volume\00"
@__const.setvolume.args = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* null, i8* null]
@.str.2 = [3 x i8] c"%i\00"
define void @setvolume(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8*]
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 100
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 100, i32* %2
br label %7
7: ; preds = %6, %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 0, i32* %2
br label %11
11: ; preds = %10, %7
%12 = bitcast [4 x i8*]* %3 to i8*
%13 = call i8* @malloc(i32 4)
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
store i8* %13, i8** %14
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
%16 = load i8*, i8** %15
%17 = load i32, i32* %2
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%20 = call i32 @exec(i8** %19)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"mmusicd\00"
@.str.1 = [11 x i8] c"set-volume\00"
@__const.setvolume.args = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* null, i8* null]
@.str.2 = [3 x i8] c"%i\00"
define void @setvolume(i32 %0) {
%2 = alloca [4 x i8*]
%3 = icmp slt i32 %0, 100
%4 = select i1 %3, i32 %0, i32 100
%5 = icmp sgt i32 %4, 0
%6 = select i1 %5, i32 %4, i32 0
%7 = bitcast [4 x i8*]* %2 to i8*
%8 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %8, i8** %9
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%12 = call i32 @exec(i8** %11)
ret void
}