#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*/ exit(int);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ setup_demux(char *, int, int);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char *dmxdev = "/dev/dvb/adapter0/demux0";
  int video_pid, audio_pid;
  if (argc != 3) {
    printf("\nusage: %s <video pid> <audio pid>\n\n", argv[0]);
    exit(1);
  }
  if (getenv("DEMUX"))
    dmxdev = getenv("DEMUX");
  printf("setpid: using '%s'\n", dmxdev);
  video_pid = strtol(argv[1], NULL, 0);
  audio_pid = strtol(argv[2], NULL, 0);
  if (setup_demux(dmxdev, video_pid, audio_pid) < 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1198 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe9f(%rip),%rdi
call   1040 <getenv@plt>
cmp    $0x0,%rax
je     11be <main+0x6e>
lea    0xe89(%rip),%rdi
call   1040 <getenv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <setup_demux@plt>
cmp    $0x0,%rax
jge    121f <main+0xcf>
movl   $0x1,-0x4(%rbp)
jmp    1226 <main+0xd6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x3,%edi
jne    11b6 <main+0x66>
lea    0xedb(%rip),%rdi
call   1040 <getenv@plt>
test   %rax,%rax
lea    0xe8e(%rip),%rbx
cmovne %rax,%rbx
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    0x8(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    0x10(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <setup_demux@plt>
shr    $0x3f,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%r14),%rsi
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"/dev/dvb/adapter0/demux0\00"
@.str.1 = [37 x i8] c"\0Ausage: %s <video pid> <audio pid>\0A\0A\00"
@.str.2 = [6 x i8] c"DEMUX\00"
@.str.3 = [20 x i8] c"setpid: using '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %6
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %6
br label %22
22: ; preds = %20, %17
%23 = load i8*, i8** %6
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strtol(i8* %27, i32* null, i32 0)
store i32 %28, i32* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @strtol(i8* %31, i32* null, i32 0)
store i32 %32, i32* %8
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i64 @setup_demux(i8* %33, i32 %34, i32 %35)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %22
store i32 1, i32* %3
br label %40
39: ; preds = %22
store i32 0, i32* %3
br label %40
40: ; preds = %39, %38
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [25 x i8] c"/dev/dvb/adapter0/demux0\00"
@.str.1 = [37 x i8] c"\0Ausage: %s <video pid> <audio pid>\0A\0A\00"
@.str.2 = [6 x i8] c"DEMUX\00"
@.str.3 = [20 x i8] c"setpid: using '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
%11 = select i1 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9
%12 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @strtol(i8* nocapture %14, i32* null, i32 0)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @strtol(i8* nocapture %17, i32* null, i32 0)
%19 = tail call i64 @setup_demux(i8* %11, i32 %15, i32 %18)
%20 = lshr i64 %19, 63
%21 = trunc i64 %20 to i32
ret i32 %21
}