#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*/ VIDEO_SET_STREAMTYPE;
int atoi(char *);
int ioctl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int videoSetType(int fd, char *arg) {
  int type = 0;
  if (!arg)
    return -1;
  type = atoi(arg);
  if (ioctl(fd, VIDEO_SET_STREAMTYPE, type) == -1)
    perror("VIDEO_STOP");
  return 0;
}


x86 assembly (clang, -O0):
<videoSetType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115d <videoSetType+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1199 <videoSetType+0x69>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1192 <videoSetType+0x62>
lea    0xe73(%rip),%rdi
call   1040 <perror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<videoSetType>:
push   %rbx
test   %rsi,%rsi
je     1167 <videoSetType+0x37>
mov    %edi,%ebx
mov    %rsi,%rdi
call   1050 <atoi@plt>
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%esi
mov    %ebx,%edi
mov    %eax,%edx
call   1030 <ioctl@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
jne    116c <videoSetType+0x3c>
lea    0xea0(%rip),%rdi
call   1040 <perror@plt>
jmp    116c <videoSetType+0x3c>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@VIDEO_SET_STREAMTYPE = global i32 0
@.str = [11 x i8] c"VIDEO_STOP\00"
define i32 @videoSetType(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
store i32 0, i32* %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 -1, i32* %3
br label %21
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = load i32, i32* @VIDEO_SET_STREAMTYPE
%15 = load i32, i32* %6
%16 = call i32 @ioctl(i32 %13, i32 %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %10
store i32 0, i32* %3
br label %21
21: ; preds = %20, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@VIDEO_SET_STREAMTYPE = global i32 0
@.str = [11 x i8] c"VIDEO_STOP\00"
define i32 @videoSetType(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i32 @atoi(i8* %1)
%6 = load i32, i32* @VIDEO_SET_STREAMTYPE
%7 = tail call i32 @ioctl(i32 %0, i32 %6, i32 %5)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %4, %9, %2
%12 = phi i32 [ -1, %2 ], [ 0, %9 ], [ 0, %4 ]
ret i32 %12
}