#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 pqos_cap_mba {
  int dummy;
};
struct pqos_cap_l3ca {
  int dummy;
};
struct pqos_cap_l2ca {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ log_printf(int, char *);
int os_alloc_reset_cores();
int os_alloc_reset_schematas(struct pqos_cap_l3ca const *,
                             struct pqos_cap_l2ca const *,
                             struct pqos_cap_mba const *);
int os_alloc_reset_tasks();
int os_alloc_reset_light(const struct pqos_cap_l3ca *l3_cap,
                         const struct pqos_cap_l2ca *l2_cap,
                         const struct pqos_cap_mba *mba_cap) {
  int ret = 0;
  int step_result;
  log_printf((1 << 0), "INFO: "
                       "OS alloc reset - LIGHT\n");
  step_result = os_alloc_reset_cores();
  if (step_result != 0)
    ret = step_result;
  step_result = os_alloc_reset_schematas(l3_cap, l2_cap, mba_cap);
  if (step_result != 0)
    ret = step_result;
  step_result = os_alloc_reset_tasks();
  if (step_result != 0)
    ret = step_result;
  return ret;
}


x86 assembly (clang, -O0):
<os_alloc_reset_light>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x1,%edi
lea    0xe99(%rip),%rsi
call   1040 <log_printf@plt>
mov    $0x0,%al
call   1060 <os_alloc_reset_cores@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1186 <os_alloc_reset_light+0x46>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <os_alloc_reset_schematas@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11aa <os_alloc_reset_light+0x6a>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <os_alloc_reset_tasks@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11c4 <os_alloc_reset_light+0x84>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_alloc_reset_light>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea9(%rip),%rsi
mov    $0x1,%edi
call   1040 <log_printf@plt>
xor    %eax,%eax
call   1060 <os_alloc_reset_cores@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <os_alloc_reset_schematas@plt>
mov    %eax,%ebx
test   %eax,%eax
cmove  %ebp,%ebx
xor    %eax,%eax
call   1050 <os_alloc_reset_tasks@plt>
test   %eax,%eax
cmove  %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pqos_cap_l3ca = type { i32 }
%struct.pqos_cap_l2ca = type { i32 }
%struct.pqos_cap_mba = type { i32 }
@.str = [30 x i8] c"INFO: OS alloc reset - LIGHT\0A\00"
define i32 @os_alloc_reset_light(%struct.pqos_cap_l3ca* %0, %struct.pqos_cap_l2ca* %1, %struct.pqos_cap_mba* %2) {
%4 = alloca %struct.pqos_cap_l3ca*
%5 = alloca %struct.pqos_cap_l2ca*
%6 = alloca %struct.pqos_cap_mba*
%7 = alloca i32
%8 = alloca i32
store %struct.pqos_cap_l3ca* %0, %struct.pqos_cap_l3ca** %4
store %struct.pqos_cap_l2ca* %1, %struct.pqos_cap_l2ca** %5
store %struct.pqos_cap_mba* %2, %struct.pqos_cap_mba** %6
store i32 0, i32* %7
%9 = call i32 @log_printf(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @os_alloc_reset_cores()
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i32, i32* %8
store i32 %14, i32* %7
br label %15
15: ; preds = %13, %3
%16 = load %struct.pqos_cap_l3ca*, %struct.pqos_cap_l3ca** %4
%17 = load %struct.pqos_cap_l2ca*, %struct.pqos_cap_l2ca** %5
%18 = load %struct.pqos_cap_mba*, %struct.pqos_cap_mba** %6
%19 = call i32 @os_alloc_reset_schematas(%struct.pqos_cap_l3ca* %16, %struct.pqos_cap_l2ca* %17, %struct.pqos_cap_mba* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load i32, i32* %8
store i32 %23, i32* %7
br label %24
24: ; preds = %22, %15
%25 = call i32 (...) @os_alloc_reset_tasks()
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i32, i32* %8
store i32 %29, i32* %7
br label %30
30: ; preds = %28, %24
%31 = load i32, i32* %7
ret i32 %31
}

LLVM IR (-O2):
%struct.pqos_cap_l3ca = type { i32 }
%struct.pqos_cap_l2ca = type { i32 }
%struct.pqos_cap_mba = type { i32 }
@.str = [30 x i8] c"INFO: OS alloc reset - LIGHT\0A\00"
define i32 @os_alloc_reset_light(%struct.pqos_cap_l3ca* %0, %struct.pqos_cap_l2ca* %1, %struct.pqos_cap_mba* %2) {
%4 = tail call i32 @log_printf(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @os_alloc_reset_cores()
%6 = tail call i32 @os_alloc_reset_schematas(%struct.pqos_cap_l3ca* %0, %struct.pqos_cap_l2ca* %1, %struct.pqos_cap_mba* %2)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 %5, i32 %6
%9 = tail call i32 (...) @os_alloc_reset_tasks()
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 %8, i32 %9
ret i32 %11
}