#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*/ judas_setmastervolume(int, unsigned char);
void judas_preventdistortion(unsigned active_channels) {
  int count;
  unsigned char mastervol;
  if (active_channels < 2)
    mastervol = 255;
  else
    mastervol = 256 / active_channels;
  for (count = 0; count < 32; count++) {
    judas_setmastervolume(count, mastervol);
  }
}


x86 assembly (clang, -O0):
<judas_preventdistortion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jae    112e <judas_preventdistortion+0x1e>
movb   $0xff,-0x9(%rbp)
jmp    113b <judas_preventdistortion+0x2b>
mov    $0x100,%eax
xor    %edx,%edx
divl   -0x4(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    1166 <judas_preventdistortion+0x56>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%esi
call   1030 <judas_setmastervolume@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <judas_preventdistortion+0x32>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<judas_preventdistortion>:
mov    $0xff,%al
cmp    $0x2,%edi
jb     1120 <judas_preventdistortion+0x10>
mov    $0x100,%eax
xor    %edx,%edx
div    %edi
push   %rbx
movzbl %al,%ebx
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x4,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x5,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x6,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x7,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x8,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x9,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xa,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xb,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xc,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xd,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xe,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0xf,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x10,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x11,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x12,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x13,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x14,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x15,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x16,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x17,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x18,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x19,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1a,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1b,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1c,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1d,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1e,%edi
mov    %ebx,%esi
call   1030 <judas_setmastervolume@plt>
mov    $0x1f,%edi
mov    %ebx,%esi
pop    %rbx
jmp    1030 <judas_setmastervolume@plt>

LLVM IR (-O0):
define void @judas_preventdistortion(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ult i32 %5, 2
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 -1, i8* %4
br label %12
8: ; preds = %1
%9 = load i32, i32* %2
%10 = udiv i32 256, %9
%11 = trunc i32 %10 to i8
store i8 %11, i8* %4
br label %12
12: ; preds = %8, %7
store i32 0, i32* %3
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 32
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %3
%18 = load i8, i8* %4
%19 = call i32 @judas_setmastervolume(i32 %17, i8 zeroext %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %13
23: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @judas_preventdistortion(i32 %0) {
%2 = icmp ult i32 %0, 2
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = udiv i32 256, %0
%5 = trunc i32 %4 to i8
br label %6
6: ; preds = %1, %3
%7 = phi i8 [ %5, %3 ], [ -1, %1 ]
%8 = tail call i32 @judas_setmastervolume(i32 0, i8 zeroext %7)
%9 = tail call i32 @judas_setmastervolume(i32 1, i8 zeroext %7)
%10 = tail call i32 @judas_setmastervolume(i32 2, i8 zeroext %7)
%11 = tail call i32 @judas_setmastervolume(i32 3, i8 zeroext %7)
%12 = tail call i32 @judas_setmastervolume(i32 4, i8 zeroext %7)
%13 = tail call i32 @judas_setmastervolume(i32 5, i8 zeroext %7)
%14 = tail call i32 @judas_setmastervolume(i32 6, i8 zeroext %7)
%15 = tail call i32 @judas_setmastervolume(i32 7, i8 zeroext %7)
%16 = tail call i32 @judas_setmastervolume(i32 8, i8 zeroext %7)
%17 = tail call i32 @judas_setmastervolume(i32 9, i8 zeroext %7)
%18 = tail call i32 @judas_setmastervolume(i32 10, i8 zeroext %7)
%19 = tail call i32 @judas_setmastervolume(i32 11, i8 zeroext %7)
%20 = tail call i32 @judas_setmastervolume(i32 12, i8 zeroext %7)
%21 = tail call i32 @judas_setmastervolume(i32 13, i8 zeroext %7)
%22 = tail call i32 @judas_setmastervolume(i32 14, i8 zeroext %7)
%23 = tail call i32 @judas_setmastervolume(i32 15, i8 zeroext %7)
%24 = tail call i32 @judas_setmastervolume(i32 16, i8 zeroext %7)
%25 = tail call i32 @judas_setmastervolume(i32 17, i8 zeroext %7)
%26 = tail call i32 @judas_setmastervolume(i32 18, i8 zeroext %7)
%27 = tail call i32 @judas_setmastervolume(i32 19, i8 zeroext %7)
%28 = tail call i32 @judas_setmastervolume(i32 20, i8 zeroext %7)
%29 = tail call i32 @judas_setmastervolume(i32 21, i8 zeroext %7)
%30 = tail call i32 @judas_setmastervolume(i32 22, i8 zeroext %7)
%31 = tail call i32 @judas_setmastervolume(i32 23, i8 zeroext %7)
%32 = tail call i32 @judas_setmastervolume(i32 24, i8 zeroext %7)
%33 = tail call i32 @judas_setmastervolume(i32 25, i8 zeroext %7)
%34 = tail call i32 @judas_setmastervolume(i32 26, i8 zeroext %7)
%35 = tail call i32 @judas_setmastervolume(i32 27, i8 zeroext %7)
%36 = tail call i32 @judas_setmastervolume(i32 28, i8 zeroext %7)
%37 = tail call i32 @judas_setmastervolume(i32 29, i8 zeroext %7)
%38 = tail call i32 @judas_setmastervolume(i32 30, i8 zeroext %7)
%39 = tail call i32 @judas_setmastervolume(i32 31, i8 zeroext %7)
ret void
}