#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 *, char *);
int /*<<< orphan*/ mvpstb_set_audio_sync(int);
int /*<<< orphan*/ mvpstb_set_video_sync(int);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int);
char tolower(char);
int set_sync(int argc, char **argv) {
  int on;
  if (argc < 3) {
    fprintf(stderr, "   %s  <a|v> <1=on|0=off>\n", argv[0]);
    return (0);
  }
  on = strtol((argv[2]), NULL, 10);
  if (tolower(argv[1][0]) == 'a') {
    mvpstb_set_audio_sync(on);
  } else if (tolower(argv[1][0]) == 'v') {
    mvpstb_set_video_sync(on);
  } else {
    fprintf(stderr, "   %s  <a|v> <1=on|0=off>\n", argv[0]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<set_sync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1191 <set_sync+0x41>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe80(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1224 <set_sync+0xd4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
movsbl %al,%eax
cmp    $0x61,%eax
jne    11d3 <set_sync+0x83>
mov    -0x14(%rbp),%edi
call   1040 <mvpstb_set_audio_sync@plt>
jmp    121d <set_sync+0xcd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
movsbl %al,%eax
cmp    $0x76,%eax
jne    11fc <set_sync+0xac>
mov    -0x14(%rbp),%edi
call   1030 <mvpstb_set_video_sync@plt>
jmp    1218 <set_sync+0xc8>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xded(%rip),%rsi
call   1050 <fprintf@plt>
jmp    121d <set_sync+0xcd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_sync>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    119f <set_sync+0x4f>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
cmp    $0x61,%al
jne    1186 <set_sync+0x36>
mov    %ebp,%edi
call   1040 <mvpstb_set_audio_sync@plt>
jmp    11b7 <set_sync+0x67>
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
cmp    $0x76,%al
jne    119f <set_sync+0x4f>
mov    %ebp,%edi
call   1030 <mvpstb_set_video_sync@plt>
jmp    11b7 <set_sync+0x67>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe4e(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c" %s <a|v> <1=on|0=off>\0A\00"
define i32 @set_sync(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
br label %51
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @strtol(i8* %18, i32* null, i32 10)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 97
br i1 %27, label %28, label %31
28: ; preds = %15
%29 = load i32, i32* %6
%30 = call i32 @mvpstb_set_audio_sync(i32 %29)
br label %50
31: ; preds = %15
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = call signext i8 @tolower(i8 signext %36)
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 118
br i1 %39, label %40, label %43
40: ; preds = %31
%41 = load i32, i32* %6
%42 = call i32 @mvpstb_set_video_sync(i32 %41)
br label %49
43: ; preds = %31
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %43, %40
br label %50
50: ; preds = %49, %28
store i32 0, i32* %3
br label %51
51: ; preds = %50, %9
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c" %s <a|v> <1=on|0=off>\0A\00"
define i32 @set_sync(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %30
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @strtol(i8* nocapture %10, i32* null, i32 10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = tail call signext i8 @tolower(i8 signext %14)
%16 = icmp eq i8 %15, 97
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @mvpstb_set_audio_sync(i32 %11)
br label %30
19: ; preds = %8
%20 = load i8*, i8** %12
%21 = load i8, i8* %20
%22 = tail call signext i8 @tolower(i8 signext %21)
%23 = icmp eq i8 %22, 118
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 @mvpstb_set_video_sync(i32 %11)
br label %30
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %17, %26, %24, %4
ret i32 0
}