#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 freeze(int freeze_mode) {
  int err;
  int frozen;
  err = FS460_image_request_freeze(freeze_mode, freeze_mode, 0);
  if (!err) {
    frozen = 0;
    while ((frozen != freeze_mode) && !err) {
      err = FS460_image_is_frozen(&frozen);
      frozen &= freeze_mode;
    }
  }
  return err;
}


x86 assembly (clang, -O0):
<freeze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
call   1030 <FS460_image_request_freeze@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1198 <freeze+0x78>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
je     1169 <freeze+0x49>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1179 <freeze+0x59>
jmp    1193 <freeze+0x73>
lea    -0xc(%rbp),%rdi
call   1040 <FS460_image_is_frozen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    114c <freeze+0x2c>
jmp    1198 <freeze+0x78>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeze>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%esi
xor    %edx,%edx
call   1030 <FS460_image_request_freeze@plt>
test   %eax,%eax
je     113b <freeze+0x1b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movl   $0x0,0x4(%rsp)
mov    $0x0,%eax
test   %ebx,%ebx
je     1133 <freeze+0x13>
lea    0x4(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <FS460_image_is_frozen@plt>
mov    0x4(%rsp),%ecx
and    %ebx,%ecx
mov    %ecx,0x4(%rsp)
cmp    %ebx,%ecx
je     1133 <freeze+0x13>
test   %eax,%eax
je     1160 <freeze+0x40>
jmp    1133 <freeze+0x13>

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

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