#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 boot_params {
  int /*<<< orphan*/ *_pad9;
  int /*<<< orphan*/ *_pad8;
  int /*<<< orphan*/ *eddbuf;
  int /*<<< orphan*/ *_pad7;
  int /*<<< orphan*/ *edd_mbr_sig_buffer;
  int /*<<< orphan*/ kbd_status;
  int /*<<< orphan*/ hdr;
  int /*<<< orphan*/ ext_ramdisk_image;
  int /*<<< orphan*/ efi_info;
  scalar_t__ acpi_rsdp_addr;
  scalar_t__ sentinel;
};

/* Variables and functions */
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
void sanitize_boot_params(struct boot_params *boot_params) {
  if (boot_params->sentinel) {
    boot_params->acpi_rsdp_addr = 0;
    memset(&boot_params->ext_ramdisk_image, 0,
           (char *)&boot_params->efi_info -
               (char *)&boot_params->ext_ramdisk_image);
    memset(&boot_params->kbd_status, 0,
           (char *)&boot_params->hdr - (char *)&boot_params->kbd_status);
    memset(&boot_params->_pad7[0], 0,
           (char *)&boot_params->edd_mbr_sig_buffer[0] -
               (char *)&boot_params->_pad7[0]);
    memset(&boot_params->_pad8[0], 0,
           (char *)&boot_params->eddbuf[0] - (char *)&boot_params->_pad8[0]);
    memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
  }
}


x86 assembly (clang, -O0):
<sanitize_boot_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x40(%rax)
je     11da <sanitize_boot_params+0xca>
mov    -0x8(%rbp),%rax
movq   $0x0,0x38(%rax)
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
mov    -0x8(%rbp),%rax
add    $0x34,%rax
mov    -0x8(%rbp),%rcx
add    $0x30,%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
add    $0x28,%rdi
mov    -0x8(%rbp),%rax
add    $0x2c,%rax
mov    -0x8(%rbp),%rcx
add    $0x28,%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x18(%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitize_boot_params>:
push   %rbx
cmpq   $0x0,0x40(%rdi)
je     1173 <sanitize_boot_params+0x63>
mov    %rdi,%rbx
movq   $0x0,0x38(%rdi)
add    $0x30,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    0x28(%rbx),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0x18(%rbx),%rdi
mov    0x20(%rbx),%edx
sub    %edi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%edx
sub    %edi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    (%rbx),%rdi
xor    %esi,%esi
mov    $0x8,%edx
pop    %rbx
jmp    1030 <memset@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.boot_params = type { i32*, i32*, i32*, i32*, i32*, i32, i32, i32, i32, i64, i64 }
define void @sanitize_boot_params(%struct.boot_params* %0) {
%2 = alloca %struct.boot_params*
store %struct.boot_params* %0, %struct.boot_params** %2
%3 = load %struct.boot_params*, %struct.boot_params** %2
%4 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %3, i32 0, i32 10
%5 = load i64, i64* %4
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %79
7: ; preds = %1
%8 = load %struct.boot_params*, %struct.boot_params** %2
%9 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %8, i32 0, i32 9
store i64 0, i64* %9
%10 = load %struct.boot_params*, %struct.boot_params** %2
%11 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %10, i32 0, i32 7
%12 = load %struct.boot_params*, %struct.boot_params** %2
%13 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %12, i32 0, i32 8
%14 = bitcast i32* %13 to i8*
%15 = load %struct.boot_params*, %struct.boot_params** %2
%16 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %15, i32 0, i32 7
%17 = bitcast i32* %16 to i8*
%18 = ptrtoint i8* %14 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
%22 = call i32 @memset(i32* %11, i32 0, i32 %21)
%23 = load %struct.boot_params*, %struct.boot_params** %2
%24 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %23, i32 0, i32 5
%25 = load %struct.boot_params*, %struct.boot_params** %2
%26 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %25, i32 0, i32 6
%27 = bitcast i32* %26 to i8*
%28 = load %struct.boot_params*, %struct.boot_params** %2
%29 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %28, i32 0, i32 5
%30 = bitcast i32* %29 to i8*
%31 = ptrtoint i8* %27 to i64
%32 = ptrtoint i8* %30 to i64
%33 = sub i64 %31, %32
%34 = trunc i64 %33 to i32
%35 = call i32 @memset(i32* %24, i32 0, i32 %34)
%36 = load %struct.boot_params*, %struct.boot_params** %2
%37 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %36, i32 0, i32 3
%38 = load i32*, i32** %37
%39 = getelementptr inbounds i32, i32* %38, i64 0
%40 = load %struct.boot_params*, %struct.boot_params** %2
%41 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %40, i32 0, i32 4
%42 = load i32*, i32** %41
%43 = getelementptr inbounds i32, i32* %42, i64 0
%44 = bitcast i32* %43 to i8*
%45 = load %struct.boot_params*, %struct.boot_params** %2
%46 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %45, i32 0, i32 3
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 0
%49 = bitcast i32* %48 to i8*
%50 = ptrtoint i8* %44 to i64
%51 = ptrtoint i8* %49 to i64
%52 = sub i64 %50, %51
%53 = trunc i64 %52 to i32
%54 = call i32 @memset(i32* %39, i32 0, i32 %53)
%55 = load %struct.boot_params*, %struct.boot_params** %2
%56 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %55, i32 0, i32 1
%57 = load i32*, i32** %56
%58 = getelementptr inbounds i32, i32* %57, i64 0
%59 = load %struct.boot_params*, %struct.boot_params** %2
%60 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %59, i32 0, i32 2
%61 = load i32*, i32** %60
%62 = getelementptr inbounds i32, i32* %61, i64 0
%63 = bitcast i32* %62 to i8*
%64 = load %struct.boot_params*, %struct.boot_params** %2
%65 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %64, i32 0, i32 1
%66 = load i32*, i32** %65
%67 = getelementptr inbounds i32, i32* %66, i64 0
%68 = bitcast i32* %67 to i8*
%69 = ptrtoint i8* %63 to i64
%70 = ptrtoint i8* %68 to i64
%71 = sub i64 %69, %70
%72 = trunc i64 %71 to i32
%73 = call i32 @memset(i32* %58, i32 0, i32 %72)
%74 = load %struct.boot_params*, %struct.boot_params** %2
%75 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %74, i32 0, i32 0
%76 = load i32*, i32** %75
%77 = getelementptr inbounds i32, i32* %76, i64 0
%78 = call i32 @memset(i32* %77, i32 0, i32 8)
br label %79
79: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
%struct.boot_params = type { i32*, i32*, i32*, i32*, i32*, i32, i32, i32, i32, i64, i64 }
define void @sanitize_boot_params(%struct.boot_params* %0) {
%2 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 10
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %1
%6 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 9
store i64 0, i64* %6
%7 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 7
%8 = tail call i32 @memset(i32* %7, i32 0, i32 4)
%9 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 5
%10 = tail call i32 @memset(i32* %9, i32 0, i32 4)
%11 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 3
%12 = load i32*, i32** %11
%13 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 4
%14 = bitcast i32** %13 to i8**
%15 = load i8*, i8** %14
%16 = ptrtoint i8* %15 to i64
%17 = ptrtoint i32* %12 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
%20 = tail call i32 @memset(i32* %12, i32 0, i32 %19)
%21 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 1
%22 = load i32*, i32** %21
%23 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 2
%24 = bitcast i32** %23 to i8**
%25 = load i8*, i8** %24
%26 = ptrtoint i8* %25 to i64
%27 = ptrtoint i32* %22 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = tail call i32 @memset(i32* %22, i32 0, i32 %29)
%31 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 0
%32 = load i32*, i32** %31
%33 = tail call i32 @memset(i32* %32, i32 0, i32 8)
br label %34
34: ; preds = %5, %1
ret void
}