#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 video_still_picture {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ VIDEO_STILLPICTURE;
scalar_t__ ioctl(int, int /*<<< orphan*/, struct video_still_picture *);
int /*<<< orphan*/ perror(char *);
int videoStillPicture(int fd, struct video_still_picture *sp) {
  int ans;
  if ((ans = ioctl(fd, VIDEO_STILLPICTURE, sp) < 0)) {
    perror("VIDEO STILLPICTURE: ");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<videoStillPicture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2eb7(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x14(%rbp)
test   $0x1,%al
jne    1163 <videoStillPicture+0x43>
jmp    117b <videoStillPicture+0x5b>
lea    0xe96(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1182 <videoStillPicture+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<videoStillPicture>:
push   %rax
mov    %rsi,%rdx
mov    0x2ec5(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     113e <videoStillPicture+0x1e>
pop    %rcx
ret
lea    0xebb(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.video_still_picture = type { i32 }
@VIDEO_STILLPICTURE = global i32 0
@.str = [21 x i8] c"VIDEO STILLPICTURE: \00"
define i32 @videoStillPicture(i32 %0, %struct.video_still_picture* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.video_still_picture*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.video_still_picture* %1, %struct.video_still_picture** %5
%7 = load i32, i32* %4
%8 = load i32, i32* @VIDEO_STILLPICTURE
%9 = load %struct.video_still_picture*, %struct.video_still_picture** %5
%10 = call i64 @ioctl(i32 %7, i32 %8, %struct.video_still_picture* %9)
%11 = icmp slt i64 %10, 0
%12 = zext i1 %11 to i32
store i32 %12, i32* %6
br i1 %11, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %16
15: ; preds = %2
store i32 0, i32* %3
br label %16
16: ; preds = %15, %13
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
%struct.video_still_picture = type { i32 }
@VIDEO_STILLPICTURE = global i32 0
@.str = [21 x i8] c"VIDEO STILLPICTURE: \00"
define i32 @videoStillPicture(i32 %0, %struct.video_still_picture* %1) {
%3 = load i32, i32* @VIDEO_STILLPICTURE
%4 = tail call i64 @ioctl(i32 %0, i32 %3, %struct.video_still_picture* %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %6
%9 = phi i32 [ -1, %6 ], [ 0, %2 ]
ret i32 %9
}