#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 */
struct mixer_ctl {
  int dummy;
};
struct mixer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct mixer_ctl *get_ctl(struct mixer *, char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ mixer_close(struct mixer *);
int /*<<< orphan*/ mixer_ctl_get(struct mixer_ctl *, unsigned int *);
int mixer_ctl_select(struct mixer_ctl *, char *);
int mixer_ctl_set_value(struct mixer_ctl *, int, char **);
int /*<<< orphan*/ mixer_dump(struct mixer *);
struct mixer *mixer_open(char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct mixer *mixer;
  struct mixer_ctl *ctl;
  unsigned value;
  int r;
  const char *device = "/dev/snd/controlC0";
  mixer = mixer_open(device);
  if (!mixer) {
    fprintf(stderr, "oops: %s: %d\n", strerror(errno), 61);
    return -1;
  }
  if (argc == 1) {
    mixer_dump(mixer);
    mixer_close(mixer);
    return 0;
  }
  ctl = get_ctl(mixer, argv[1]);
  argc -= 2;
  argv += 2;
  if (!ctl) {
    fprintf(stderr, "can't find control\n");
    mixer_close(mixer);
    return -1;
  }
  if (argc) {
    if (isdigit(argv[0][0]))
      r = mixer_ctl_set_value(ctl, argc, argv);
    else
      r = mixer_ctl_select(ctl, argv[0]);
    if (r)
      fprintf(stderr, "oops: %s: %d\n", strerror(errno), 86);
  } else {
    mixer_ctl_get(ctl, &value);
  }
  mixer_close(mixer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   10b0 <mixer_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1218 <main+0x78>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xe13(%rip),%rsi
mov    $0x3d,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134e <main+0x1ae>
cmpl   $0x1,-0x8(%rbp)
jne    1240 <main+0xa0>
mov    -0x18(%rbp),%rdi
call   1070 <mixer_dump@plt>
mov    -0x18(%rbp),%rdi
call   1040 <mixer_close@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ae>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10c0 <get_ctl@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12a1 <main+0x101>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <mixer_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134e <main+0x1ae>
cmpl   $0x0,-0x8(%rbp)
je     1331 <main+0x191>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     12dc <main+0x13c>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <mixer_ctl_set_value@plt>
mov    %eax,-0x28(%rbp)
jmp    12ef <main+0x14f>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1090 <mixer_ctl_select@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     132c <main+0x18c>
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xcf3(%rip),%rsi
mov    $0x56,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    133e <main+0x19e>
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <mixer_ctl_get@plt>
mov    -0x18(%rbp),%rdi
call   1040 <mixer_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe4d(%rip),%rdi
call   10b0 <mixer_open@plt>
test   %rax,%rax
je     11d2 <main+0x32>
mov    %rax,%r14
cmp    $0x1,%ebp
jne    120b <main+0x6b>
mov    %r14,%rdi
call   1070 <mixer_dump@plt>
jmp    12be <main+0x11e>
mov    0x2e07(%rip),%rax
mov    (%rax),%ebx
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xe23(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
mov    $0x3d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    12c8 <main+0x128>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   10c0 <get_ctl@plt>
test   %rax,%rax
je     124b <main+0xab>
mov    %rax,%r15
add    $0xfffffffe,%ebp
je     1271 <main+0xd1>
add    $0x10,%rbx
mov    (%rbx),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1280 <main+0xe0>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <mixer_ctl_set_value@plt>
test   %eax,%eax
jne    128f <main+0xef>
jmp    12be <main+0x11e>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,%rdi
call   1040 <mixer_close@plt>
mov    $0xffffffff,%eax
jmp    12c8 <main+0x128>
lea    0x4(%rsp),%rsi
mov    %r15,%rdi
call   1050 <mixer_ctl_get@plt>
jmp    12be <main+0x11e>
mov    (%rbx),%rsi
mov    %r15,%rdi
call   1090 <mixer_ctl_select@plt>
test   %eax,%eax
je     12be <main+0x11e>
mov    0x2d4a(%rip),%rax
mov    (%rax),%ebx
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd66(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
mov    $0x56,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,%rdi
call   1040 <mixer_close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mixer = type { i32 }
%struct.mixer_ctl = type { i32 }
@.str = [19 x i8] c"/dev/snd/controlC0\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"oops: %s: %d\0A\00"
@errno = global i32 0
@.str.2 = [20 x i8] c"can't find control\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.mixer*
%7 = alloca %struct.mixer_ctl*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i8*, i8** %10
%12 = call %struct.mixer* @mixer_open(i8* %11)
store %struct.mixer* %12, %struct.mixer** %6
%13 = load %struct.mixer*, %struct.mixer** %6
%14 = icmp ne %struct.mixer* %13, null
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 61)
store i32 -1, i32* %3
br label %82
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load %struct.mixer*, %struct.mixer** %6
%25 = call i32 @mixer_dump(%struct.mixer* %24)
%26 = load %struct.mixer*, %struct.mixer** %6
%27 = call i32 @mixer_close(%struct.mixer* %26)
store i32 0, i32* %3
br label %82
28: ; preds = %20
%29 = load %struct.mixer*, %struct.mixer** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call %struct.mixer_ctl* @get_ctl(%struct.mixer* %29, i8* %32)
store %struct.mixer_ctl* %33, %struct.mixer_ctl** %7
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 2
store i32 %35, i32* %4
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
store i8** %37, i8*** %5
%38 = load %struct.mixer_ctl*, %struct.mixer_ctl** %7
%39 = icmp ne %struct.mixer_ctl* %38, null
br i1 %39, label %45, label %40
40: ; preds = %28
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%43 = load %struct.mixer*, %struct.mixer** %6
%44 = call i32 @mixer_close(%struct.mixer* %43)
store i32 -1, i32* %3
br label %82
45: ; preds = %28
%46 = load i32, i32* %4
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %76
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = call i64 @isdigit(i8 signext %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %48
%57 = load %struct.mixer_ctl*, %struct.mixer_ctl** %7
%58 = load i32, i32* %4
%59 = load i8**, i8*** %5
%60 = call i32 @mixer_ctl_set_value(%struct.mixer_ctl* %57, i32 %58, i8** %59)
store i32 %60, i32* %9
br label %67
61: ; preds = %48
%62 = load %struct.mixer_ctl*, %struct.mixer_ctl** %7
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = call i32 @mixer_ctl_select(%struct.mixer_ctl* %62, i8* %65)
store i32 %66, i32* %9
br label %67
67: ; preds = %61, %56
%68 = load i32, i32* %9
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %73, i32 86)
br label %75
75: ; preds = %70, %67
br label %79
76: ; preds = %45
%77 = load %struct.mixer_ctl*, %struct.mixer_ctl** %7
%78 = call i32 @mixer_ctl_get(%struct.mixer_ctl* %77, i32* %8)
br label %79
79: ; preds = %76, %75
%80 = load %struct.mixer*, %struct.mixer** %6
%81 = call i32 @mixer_close(%struct.mixer* %80)
store i32 0, i32* %3
br label %82
82: ; preds = %79, %40, %23, %15
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
%struct.mixer = type { i32 }
%struct.mixer_ctl = type { i32 }
@.str = [19 x i8] c"/dev/snd/controlC0\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"oops: %s: %d\0A\00"
@errno = global i32 0
@.str.2 = [20 x i8] c"can't find control\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call %struct.mixer* @mixer_open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq %struct.mixer* %5, null
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 61)
br label %52
12: ; preds = %2
%13 = icmp eq i32 %0, 1
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 @mixer_dump(%struct.mixer* %5)
%16 = tail call i32 @mixer_close(%struct.mixer* %5)
br label %52
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call %struct.mixer_ctl* @get_ctl(%struct.mixer* %5, i8* %19)
%21 = add nsw i32 %0, -2
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = icmp eq %struct.mixer_ctl* %20, null
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @mixer_close(%struct.mixer* %5)
br label %52
28: ; preds = %17
%29 = icmp eq i32 %21, 0
br i1 %29, label %48, label %30
30: ; preds = %28
%31 = load i8*, i8** %22
%32 = load i8, i8* %31
%33 = tail call i64 @isdigit(i8 signext %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = tail call i32 @mixer_ctl_set_value(%struct.mixer_ctl* %20, i32 %21, i8** %22)
br label %40
37: ; preds = %30
%38 = load i8*, i8** %22
%39 = tail call i32 @mixer_ctl_select(%struct.mixer_ctl* %20, i8* %38)
br label %40
40: ; preds = %37, %35
%41 = phi i32 [ %36, %35 ], [ %39, %37 ]
%42 = icmp eq i32 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = tail call i8* @strerror(i32 %45)
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %46, i32 86)
br label %50
48: ; preds = %28
%49 = call i32 @mixer_ctl_get(%struct.mixer_ctl* %20, i32* %3)
br label %50
50: ; preds = %40, %43, %48
%51 = call i32 @mixer_close(%struct.mixer* %5)
br label %52
52: ; preds = %50, %24, %14, %7
%53 = phi i32 [ 0, %14 ], [ 0, %50 ], [ -1, %24 ], [ -1, %7 ]
ret i32 %53
}