#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 */
typedef int /*<<< orphan*/ uint32_t;
struct user_desc {
  int contents;
  int /*<<< orphan*/ seg_not_present;
  scalar_t__ seg_32bit;
};

/* Variables and functions */
int install_valid_mode(struct user_desc const *, int /*<<< orphan*/, int, int);
bool install_valid(const struct user_desc *desc, uint32_t ar) {
  bool ret = install_valid_mode(desc, ar, false, true);
  if (desc->contents <= 1 && desc->seg_32bit && !desc->seg_not_present) {
    install_valid_mode(desc, ar, false, false);
  }
  return ret;
}


x86 assembly (clang, -O0):
<install_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <install_valid_mode@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jg     116f <install_valid+0x5f>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     116f <install_valid+0x5f>
mov    -0x8(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    116f <install_valid+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <install_valid_mode@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<install_valid>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <install_valid_mode@plt>
mov    %eax,%ebp
cmpl   $0x1,(%rbx)
jg     1149 <install_valid+0x39>
cmpq   $0x0,0x8(%rbx)
je     1149 <install_valid+0x39>
cmpl   $0x0,0x4(%rbx)
jne    1149 <install_valid+0x39>
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <install_valid_mode@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.user_desc = type { i32, i32, i64 }
define i32 @install_valid(%struct.user_desc* %0, i32 %1) {
%3 = alloca %struct.user_desc*
%4 = alloca i32
%5 = alloca i32
store %struct.user_desc* %0, %struct.user_desc** %3
store i32 %1, i32* %4
%6 = load %struct.user_desc*, %struct.user_desc** %3
%7 = load i32, i32* %4
%8 = call i32 @install_valid_mode(%struct.user_desc* %6, i32 %7, i32 0, i32 1)
store i32 %8, i32* %5
%9 = load %struct.user_desc*, %struct.user_desc** %3
%10 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %27
13: ; preds = %2
%14 = load %struct.user_desc*, %struct.user_desc** %3
%15 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %14, i32 0, i32 2
%16 = load i64, i64* %15
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = load %struct.user_desc*, %struct.user_desc** %3
%20 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = load %struct.user_desc*, %struct.user_desc** %3
%25 = load i32, i32* %4
%26 = call i32 @install_valid_mode(%struct.user_desc* %24, i32 %25, i32 0, i32 0)
br label %27
27: ; preds = %23, %18, %13, %2
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
%struct.user_desc = type { i32, i32, i64 }
define i32 @install_valid(%struct.user_desc* %0, i32 %1) {
%3 = tail call i32 @install_valid_mode(%struct.user_desc* %0, i32 %1, i32 0, i32 1)
%4 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %0, i64 0, i32 2
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.user_desc, %struct.user_desc* %0, i64 0, i32 1
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @install_valid_mode(%struct.user_desc* %0, i32 %1, i32 0, i32 0)
br label %17
17: ; preds = %15, %11, %7, %2
ret i32 %3
}