#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*/ error_msg(char *);
int /*<<< orphan*/ player_set_soft_volume(long, long);
int str_to_int(char *, long *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
void set_softvol_state(unsigned int id, const char *buf) {
  char buffer[4096];
  char *ptr;
  long int l, r;
  strcpy(buffer, buf);
  ptr = strchr(buffer, ' ');
  if (!ptr)
    goto err;
  while (*ptr == ' ')
    *ptr++ = 0;
  if (str_to_int(buffer, &l) == -1 || l < 0 || l > 100)
    goto err;
  if (str_to_int(ptr, &r) == -1 || r < 0 || r > 100)
    goto err;
  player_set_soft_volume(l, r);
  return;
err:
  error_msg("two integers in range 0..100 expected");
}


x86 assembly (clang, -O0):
<set_softvol_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
jne    119d <set_softvol_state+0x4d>
jmp    1264 <set_softvol_state+0x114>
jmp    11a2 <set_softvol_state+0x52>
mov    -0x1018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11d2 <set_softvol_state+0x82>
mov    -0x1018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1018(%rbp)
movb   $0x0,(%rax)
jmp    11a2 <set_softvol_state+0x52>
lea    -0x1010(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1050 <str_to_int@plt>
cmp    $0xffffffff,%eax
je     120a <set_softvol_state+0xba>
cmpq   $0x0,-0x1020(%rbp)
jl     120a <set_softvol_state+0xba>
cmpq   $0x64,-0x1020(%rbp)
64
jle    120f <set_softvol_state+0xbf>
jmp    1264 <set_softvol_state+0x114>
mov    -0x1018(%rbp),%rdi
lea    -0x1028(%rbp),%rsi
call   1050 <str_to_int@plt>
cmp    $0xffffffff,%eax
je     1247 <set_softvol_state+0xf7>
cmpq   $0x0,-0x1028(%rbp)
jl     1247 <set_softvol_state+0xf7>
cmpq   $0x64,-0x1028(%rbp)
64
jle    124c <set_softvol_state+0xfc>
jmp    1264 <set_softvol_state+0x114>
mov    -0x1020(%rbp),%rdi
mov    -0x1028(%rbp),%rsi
call   1070 <player_set_soft_volume@plt>
jmp    1270 <set_softvol_state+0x120>
lea    0xd95(%rip),%rdi
call   1030 <error_msg@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_softvol_state>:
push   %rbx
sub    $0x1010,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11e3 <set_softvol_state+0x93>
cmpb   $0x20,(%rax)
jne    1192 <set_softvol_state+0x42>
nopl   0x0(%rax)
lea    0x1(%rax),%rbx
movb   $0x0,(%rax)
cmpb   $0x20,0x1(%rax)
mov    %rbx,%rax
je     1180 <set_softvol_state+0x30>
jmp    1195 <set_softvol_state+0x45>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <str_to_int@plt>
cmp    $0xffffffff,%eax
je     11e3 <set_softvol_state+0x93>
mov    (%rsp),%rax
test   %rax,%rax
js     11e3 <set_softvol_state+0x93>
cmp    $0x64,%rax
jg     11e3 <set_softvol_state+0x93>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <str_to_int@plt>
cmp    $0xffffffff,%eax
je     11e3 <set_softvol_state+0x93>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
js     11e3 <set_softvol_state+0x93>
cmp    $0x64,%rsi
jg     11e3 <set_softvol_state+0x93>
mov    (%rsp),%rdi
call   1070 <player_set_soft_volume@plt>
jmp    11ef <set_softvol_state+0x9f>
lea    0xe16(%rip),%rdi
call   1030 <error_msg@plt>
add    $0x1010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"two integers in range 0..100 expected\00"
define void @set_softvol_state(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [4096 x i8]
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%13 = call i8* @strchr(i8* %12, i8 signext 32)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %2
br label %52
17: ; preds = %2
br label %18
18: ; preds = %23, %17
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %6
store i8 0, i8* %24
br label %18
26: ; preds = %18
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%28 = call i32 @str_to_int(i8* %27, i64* %7)
%29 = icmp eq i32 %28, -1
br i1 %29, label %36, label %30
30: ; preds = %26
%31 = load i64, i64* %7
%32 = icmp slt i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i64, i64* %7
%35 = icmp sgt i64 %34, 100
br i1 %35, label %36, label %37
36: ; preds = %33, %30, %26
br label %52
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = call i32 @str_to_int(i8* %38, i64* %8)
%40 = icmp eq i32 %39, -1
br i1 %40, label %47, label %41
41: ; preds = %37
%42 = load i64, i64* %8
%43 = icmp slt i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i64, i64* %8
%46 = icmp sgt i64 %45, 100
br i1 %46, label %47, label %48
47: ; preds = %44, %41, %37
br label %52
48: ; preds = %44
%49 = load i64, i64* %7
%50 = load i64, i64* %8
%51 = call i32 @player_set_soft_volume(i64 %49, i64 %50)
br label %54
52: ; preds = %47, %36, %16
%53 = call i32 @error_msg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"two integers in range 0..100 expected\00"
define void @set_softvol_state(i32 %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i64* %4 to i8*
%8 = bitcast i64* %5 to i8*
%9 = call i32 @strcpy(i8* %6, i8* %1)
%10 = call i8* @strchr(i8* %6, i8 signext 32)
%11 = icmp eq i8* %10, null
br i1 %11, label %40, label %12
12: ; preds = %2
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 32
br i1 %14, label %15, label %20
15: ; preds = %12, %15
%16 = phi i8* [ %17, %15 ], [ %10, %12 ]
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 0, i8* %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %15, label %20
20: ; preds = %15, %12
%21 = phi i8* [ %10, %12 ], [ %17, %15 ]
%22 = call i32 @str_to_int(i8* %6, i64* %4)
%23 = icmp eq i32 %22, -1
%24 = load i64, i64* %4
%25 = icmp slt i64 %24, 0
%26 = select i1 %23, i1 true, i1 %25
%27 = icmp sgt i64 %24, 100
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %40, label %29
29: ; preds = %20
%30 = call i32 @str_to_int(i8* %21, i64* %5)
%31 = icmp eq i32 %30, -1
%32 = load i64, i64* %5
%33 = icmp slt i64 %32, 0
%34 = select i1 %31, i1 true, i1 %33
%35 = icmp sgt i64 %32, 100
%36 = select i1 %34, i1 true, i1 %35
br i1 %36, label %40, label %37
37: ; preds = %29
%38 = load i64, i64* %4
%39 = call i32 @player_set_soft_volume(i64 %38, i64 %32)
br label %42
40: ; preds = %29, %20, %2
%41 = call i32 @error_msg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
ret void
}