#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*/ runcmd(char *);
char *smprintf(char *, int, char *);
int /*<<< orphan*/ sscanf(int /*<<< orphan*/, char *, ...);
char *getvolume() {
  int volume;
  char mute;
  char *mute_str = "";
  sscanf(runcmd("amixer | grep -A 6 Master | grep 'Front Left: Playback'       "
                " | grep -o '[0-9%]*%'"),
         "%i%%", &volume);
  sscanf(runcmd("amixer | grep -A 6 Master | grep 'Front Left: Playback'       "
                " | grep -P -o '(\\[on)|(\\[of)'"),
         "[o%c", &mute);
  if (mute == 'f')
    mute_str = "(M)";
  return smprintf("%d %% %s", volume, mute_str);
}


x86 assembly (clang, -O0):
<getvolume>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf19(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb6(%rip),%rdi
call   1040 <runcmd@plt>
mov    %eax,%edi
lea    0xefc(%rip),%rsi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
lea    0xeef(%rip),%rdi
call   1040 <runcmd@plt>
mov    %eax,%edi
lea    0xf3d(%rip),%rsi
lea    -0x5(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jne    119b <getvolume+0x6b>
lea    0xf23(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xf15(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getvolume>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <runcmd@plt>
lea    0xf10(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %eax,%edi
xor    %eax,%eax
call   1050 <sscanf@plt>
lea    0xf00(%rip),%rdi
call   1040 <runcmd@plt>
lea    0xf50(%rip),%rsi
lea    0x3(%rsp),%rdx
mov    %eax,%edi
xor    %eax,%eax
call   1050 <sscanf@plt>
cmpb   $0x66,0x3(%rsp)
lea    0xf3b(%rip),%rax
lea    0xed2(%rip),%rdx
cmove  %rax,%rdx
mov    0x4(%rsp),%esi
lea    0xf29(%rip),%rdi
call   1030 <smprintf@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [84 x i8] c"amixer | grep -A 6 Master | grep 'Front Left: Playback' | grep -o '[0-9%]*%'\00"
@.str.2 = [5 x i8] c"%i%%\00"
@.str.3 = [92 x i8] c"amixer | grep -A 6 Master | grep 'Front Left: Playback' | grep -P -o '(\\[on)|(\\[of)'\00"
@.str.4 = [5 x i8] c"[o%c\00"
@.str.5 = [4 x i8] c"(M)\00"
@.str.6 = [9 x i8] c"%d %% %s\00"
define i8* @getvolume() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8*
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = call i32 @runcmd(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i32, i8*, ...) @sscanf(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = call i32 @runcmd(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (i32, i8*, ...) @sscanf(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 102
br i1 %10, label %11, label %12
11: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %12
12: ; preds = %11, %0
%13 = load i32, i32* %1
%14 = load i8*, i8** %3
%15 = call i8* @smprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %13, i8* %14)
ret i8* %15
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [84 x i8] c"amixer | grep -A 6 Master | grep 'Front Left: Playback' | grep -o '[0-9%]*%'\00"
@.str.2 = [5 x i8] c"%i%%\00"
@.str.3 = [92 x i8] c"amixer | grep -A 6 Master | grep 'Front Left: Playback' | grep -P -o '(\\[on)|(\\[of)'\00"
@.str.4 = [5 x i8] c"[o%c\00"
@.str.5 = [4 x i8] c"(M)\00"
@.str.6 = [9 x i8] c"%d %% %s\00"
define i8* @getvolume() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @runcmd(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i32, i8*, ...) @sscanf(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = call i32 @runcmd(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (i32, i8*, ...) @sscanf(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 102
%10 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%11 = load i32, i32* %1
%12 = call i8* @smprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %11, i8* %10)
ret i8* %12
}