#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
int vol_iterate(int newval) {
  static int val = 0;
  char command[100];
  if (val == newval)
    return (0);
  if (val < newval) {
    val += 8;
    if (val > newval)
      val = newval;
  } else {
    val -= 8;
    if (val < newval)
      val = newval;
  }
  sprintf(command, "/usr/bin/aumix -v %d", val);
  fprintf(stderr, "Setting volume to %d\n", val);
  system(command);
  return (1);
}


x86 assembly (clang, -O0):
<vol_iterate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2efb(%rip),%eax
cmp    -0x8(%rbp),%eax
jne    1156 <vol_iterate+0x26>
movl   $0x0,-0x4(%rbp)
jmp    11fe <vol_iterate+0xce>
mov    0x2ee0(%rip),%eax
cmp    -0x8(%rbp),%eax
jge    1191 <vol_iterate+0x61>
mov    0x2ed1(%rip),%eax
add    $0x8,%eax
mov    %eax,0x2ec8(%rip)
mov    0x2ec2(%rip),%eax
cmp    -0x8(%rbp),%eax
jle    118c <vol_iterate+0x5c>
mov    -0x8(%rbp),%eax
mov    %eax,0x2eb0(%rip)
jmp    11bd <vol_iterate+0x8d>
mov    0x2ea5(%rip),%eax
sub    $0x8,%eax
mov    %eax,0x2e9c(%rip)
mov    0x2e96(%rip),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <vol_iterate+0x88>
mov    -0x8(%rbp),%eax
mov    %eax,0x2e84(%rip)
jmp    11bd <vol_iterate+0x8d>
lea    -0x70(%rbp),%rdi
mov    0x2e75(%rip),%edx
lea    0xe32(%rip),%rsi
call   1050 <sprintf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%edx
lea    0xe2c(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <system@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vol_iterate>:
push   %rbx
sub    $0x70,%rsp
mov    0x2f01(%rip),%edx
xor    %eax,%eax
cmp    %edi,%edx
je     1195 <vol_iterate+0x65>
jge    114d <vol_iterate+0x1d>
add    $0x8,%edx
cmp    %edi,%edx
cmovg  %edi,%edx
jmp    1155 <vol_iterate+0x25>
add    $0xfffffff8,%edx
cmp    %edi,%edx
cmovl  %edi,%edx
mov    %edx,0x2ee1(%rip)
lea    0xe9e(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    0x2ec0(%rip),%edx
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@vol_iterate.val = internal global i32 0
@.str = [21 x i8] c"/usr/bin/aumix -v %d\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Setting volume to %d\0A\00"
define i32 @vol_iterate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* @vol_iterate.val
%6 = load i32, i32* %3
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %40
9: ; preds = %1
%10 = load i32, i32* @vol_iterate.val
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* @vol_iterate.val
%15 = add nsw i32 %14, 8
store i32 %15, i32* @vol_iterate.val
%16 = load i32, i32* @vol_iterate.val
%17 = load i32, i32* %3
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i32, i32* %3
store i32 %20, i32* @vol_iterate.val
br label %21
21: ; preds = %19, %13
br label %31
22: ; preds = %9
%23 = load i32, i32* @vol_iterate.val
%24 = sub nsw i32 %23, 8
store i32 %24, i32* @vol_iterate.val
%25 = load i32, i32* @vol_iterate.val
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* %3
store i32 %29, i32* @vol_iterate.val
br label %30
30: ; preds = %28, %22
br label %31
31: ; preds = %30, %21
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%33 = load i32, i32* @vol_iterate.val
%34 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @stderr
%36 = load i32, i32* @vol_iterate.val
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%39 = call i32 @system(i8* %38)
store i32 1, i32* %2
br label %40
40: ; preds = %31, %8
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@vol_iterate.val = internal unnamed_addr global i32 0
@.str = [21 x i8] c"/usr/bin/aumix -v %d\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Setting volume to %d\0A\00"
define i32 @vol_iterate(i32 %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @vol_iterate.val
%5 = icmp eq i32 %4, %0
br i1 %5, label %23, label %6
6: ; preds = %1
%7 = icmp slt i32 %4, %0
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = add nsw i32 %4, 8
%10 = icmp sgt i32 %9, %0
%11 = select i1 %10, i32 %0, i32 %9
br label %16
12: ; preds = %6
%13 = add nsw i32 %4, -8
%14 = icmp slt i32 %13, %0
%15 = select i1 %14, i32 %0, i32 %13
br label %16
16: ; preds = %12, %8
%17 = phi i32 [ %15, %12 ], [ %11, %8 ]
store i32 %17, i32* @vol_iterate.val
%18 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stderr
%20 = load i32, i32* @vol_iterate.val
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @system(i8* %3)
br label %23
23: ; preds = %1, %16
%24 = phi i32 [ 1, %16 ], [ 0, %1 ]
ret i32 %24
}