#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 FS460_image_is_frozen(int *);
int FS460_image_request_freeze(int, int, int /*<<< orphan*/);
int FS460_set_freeze_video(int freeze) {
  int ret;
  int frozen;
  ret = FS460_image_request_freeze(freeze ? 0x0001 : 0, 0x0001, 0);
  if (!ret) {
    frozen = freeze ? 0 : 0x0001;
    while ((frozen != freeze) && !ret) {
      ret = FS460_image_is_frozen(&frozen);
      frozen &= 0x0001;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<FS460_set_freeze_video>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
xor    %edi,%edi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <FS460_image_request_freeze@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b3 <FS460_set_freeze_video+0x93>
mov    -0x4(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
je     1184 <FS460_set_freeze_video+0x64>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1194 <FS460_set_freeze_video+0x74>
jmp    11ae <FS460_set_freeze_video+0x8e>
lea    -0xc(%rbp),%rdi
call   1040 <FS460_image_is_frozen@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <FS460_set_freeze_video+0x47>
jmp    11b3 <FS460_set_freeze_video+0x93>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FS460_set_freeze_video>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
test   %ebx,%ebx
setne  %dil
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <FS460_image_request_freeze@plt>
test   %eax,%eax
jne    117b <FS460_set_freeze_video+0x5b>
xor    %ecx,%ecx
test   %ebx,%ebx
sete   %cl
mov    %ecx,0x4(%rsp)
mov    $0x0,%eax
cmp    %ebx,%ecx
je     117b <FS460_set_freeze_video+0x5b>
lea    0x4(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <FS460_image_is_frozen@plt>
mov    0x4(%rsp),%ecx
and    $0x1,%ecx
mov    %ecx,0x4(%rsp)
cmp    %ebx,%ecx
je     117b <FS460_set_freeze_video+0x5b>
test   %eax,%eax
je     1160 <FS460_set_freeze_video+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @FS460_set_freeze_video(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 1, i32 0
%9 = call i32 @FS460_image_request_freeze(i32 %8, i32 1, i32 0)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %32, label %12
12: ; preds = %1
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 0, i32 1
store i32 %16, i32* %4
br label %17
17: ; preds = %27, %12
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br label %25
25: ; preds = %21, %17
%26 = phi i1 [ false, %17 ], [ %24, %21 ]
br i1 %26, label %27, label %31
27: ; preds = %25
%28 = call i32 @FS460_image_is_frozen(i32* %4)
store i32 %28, i32* %3
%29 = load i32, i32* %4
%30 = and i32 %29, 1
store i32 %30, i32* %4
br label %17
31: ; preds = %25
br label %32
32: ; preds = %31, %1
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @FS460_set_freeze_video(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i32 %0, 0
%5 = xor i1 %4, true
%6 = zext i1 %5 to i32
%7 = tail call i32 @FS460_image_request_freeze(i32 %6, i32 1, i32 0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = zext i1 %4 to i32
store i32 %10, i32* %2
%11 = icmp eq i32 %10, %0
br i1 %11, label %19, label %12
12: ; preds = %9, %12
%13 = call i32 @FS460_image_is_frozen(i32* %2)
%14 = load i32, i32* %2
%15 = and i32 %14, 1
store i32 %15, i32* %2
%16 = icmp ne i32 %15, %0
%17 = icmp eq i32 %13, 0
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %12, label %19
19: ; preds = %12, %9, %1
%20 = phi i32 [ %7, %1 ], [ 0, %9 ], [ %13, %12 ]
ret i32 %20
}